|
| 1 | +package io.sentry |
| 2 | + |
| 3 | +import java.math.BigDecimal |
| 4 | +import java.math.BigInteger |
| 5 | +import java.util.concurrent.atomic.AtomicInteger |
| 6 | +import java.util.concurrent.atomic.AtomicLong |
| 7 | +import kotlin.test.Test |
| 8 | +import kotlin.test.assertEquals |
| 9 | + |
| 10 | +class SentryAttributeTypeTest { |
| 11 | + |
| 12 | + @Test |
| 13 | + fun `inferFrom returns BOOLEAN for Boolean`() { |
| 14 | + assertEquals(SentryAttributeType.BOOLEAN, SentryAttributeType.inferFrom(true)) |
| 15 | + assertEquals(SentryAttributeType.BOOLEAN, SentryAttributeType.inferFrom(false)) |
| 16 | + } |
| 17 | + |
| 18 | + @Test |
| 19 | + fun `inferFrom returns INTEGER for Integer`() { |
| 20 | + assertEquals(SentryAttributeType.INTEGER, SentryAttributeType.inferFrom(42)) |
| 21 | + } |
| 22 | + |
| 23 | + @Test |
| 24 | + fun `inferFrom returns INTEGER for Long`() { |
| 25 | + assertEquals(SentryAttributeType.INTEGER, SentryAttributeType.inferFrom(42L)) |
| 26 | + } |
| 27 | + |
| 28 | + @Test |
| 29 | + fun `inferFrom returns INTEGER for Short`() { |
| 30 | + assertEquals(SentryAttributeType.INTEGER, SentryAttributeType.inferFrom(42.toShort())) |
| 31 | + } |
| 32 | + |
| 33 | + @Test |
| 34 | + fun `inferFrom returns INTEGER for Byte`() { |
| 35 | + assertEquals(SentryAttributeType.INTEGER, SentryAttributeType.inferFrom(42.toByte())) |
| 36 | + } |
| 37 | + |
| 38 | + @Test |
| 39 | + fun `inferFrom returns INTEGER for BigInteger`() { |
| 40 | + assertEquals(SentryAttributeType.INTEGER, SentryAttributeType.inferFrom(BigInteger.valueOf(42))) |
| 41 | + } |
| 42 | + |
| 43 | + @Test |
| 44 | + fun `inferFrom returns INTEGER for AtomicInteger`() { |
| 45 | + assertEquals(SentryAttributeType.INTEGER, SentryAttributeType.inferFrom(AtomicInteger(42))) |
| 46 | + } |
| 47 | + |
| 48 | + @Test |
| 49 | + fun `inferFrom returns INTEGER for AtomicLong`() { |
| 50 | + assertEquals(SentryAttributeType.INTEGER, SentryAttributeType.inferFrom(AtomicLong(42))) |
| 51 | + } |
| 52 | + |
| 53 | + @Test |
| 54 | + fun `inferFrom returns DOUBLE for Double`() { |
| 55 | + assertEquals(SentryAttributeType.DOUBLE, SentryAttributeType.inferFrom(3.14)) |
| 56 | + } |
| 57 | + |
| 58 | + @Test |
| 59 | + fun `inferFrom returns DOUBLE for Float`() { |
| 60 | + assertEquals(SentryAttributeType.DOUBLE, SentryAttributeType.inferFrom(3.14f)) |
| 61 | + } |
| 62 | + |
| 63 | + @Test |
| 64 | + fun `inferFrom returns DOUBLE for BigDecimal`() { |
| 65 | + assertEquals( |
| 66 | + SentryAttributeType.DOUBLE, |
| 67 | + SentryAttributeType.inferFrom(BigDecimal.valueOf(3.14)), |
| 68 | + ) |
| 69 | + } |
| 70 | + |
| 71 | + @Test |
| 72 | + fun `inferFrom returns STRING for String`() { |
| 73 | + assertEquals(SentryAttributeType.STRING, SentryAttributeType.inferFrom("hello")) |
| 74 | + } |
| 75 | + |
| 76 | + @Test |
| 77 | + fun `inferFrom returns STRING for null`() { |
| 78 | + assertEquals(SentryAttributeType.STRING, SentryAttributeType.inferFrom(null)) |
| 79 | + } |
| 80 | +} |
0 commit comments