diff --git a/android-core/src/androidTest/kotlin/com.mparticle/MPUserTest.kt b/android-core/src/androidTest/kotlin/com.mparticle/MPUserTest.kt index 92ccec49d..332b5b591 100644 --- a/android-core/src/androidTest/kotlin/com.mparticle/MPUserTest.kt +++ b/android-core/src/androidTest/kotlin/com.mparticle/MPUserTest.kt @@ -61,11 +61,11 @@ class MPUserTest : BaseCleanStartedEachTest() { ) { assertEquals(6, userAttributes.size) assertEquals("bar", userAttributes["foo"]) - assertEquals(123L, userAttributes["fooInt"]) - assertEquals(12345L, userAttributes["fooLong"]) + assertEquals(123, userAttributes["fooInt"]) + assertEquals(12345, userAttributes["fooLong"]) assertEquals(10.15, userAttributes["fooDouble"]) - assertEquals(-10L, userAttributes["fooNegInt"]) - assertEquals(-1010L, userAttributes["fooNegLong"]) + assertEquals(-10, userAttributes["fooNegInt"]) + assertEquals(-1010, userAttributes["fooNegLong"]) assertEquals(null, userAttributes["fooNull"]) } }) @@ -83,12 +83,12 @@ class MPUserTest : BaseCleanStartedEachTest() { incrementUserAttribute("foo", 3) android_test_hack() - assertEquals(4L, userAttributes["foo"]) + assertEquals(4, userAttributes["foo"]) // test negative increment incrementUserAttribute("foo", -2) android_test_hack() - assertEquals(2L, userAttributes["foo"]) + assertEquals(2, userAttributes["foo"]) // test remove incremented attribute removeUserAttribute("foo") @@ -130,20 +130,20 @@ class MPUserTest : BaseCleanStartedEachTest() { fun testIncrementLongAttribute() { MParticle.getInstance()!!.Identity().currentUser!!.apply { assertTrue { getUserAttributes().isEmpty() } - setUserAttribute("foo", 10L) + setUserAttribute("foo", 10) android_test_hack() assertEquals(1, userAttributes.size) - assertEquals(10L, userAttributes["foo"]) - incrementUserAttribute("foo", 37L) + assertEquals(10, userAttributes["foo"]) + incrementUserAttribute("foo", 37) android_test_hack() - assertEquals(47L, userAttributes["foo"]) + assertEquals(47, userAttributes["foo"]) // test negative increment - incrementUserAttribute("foo", -21L) + incrementUserAttribute("foo", -21) android_test_hack() - assertEquals(26L, userAttributes["foo"]) + assertEquals(26, userAttributes["foo"]) // test remove incremented attribute removeUserAttribute("foo") diff --git a/android-core/src/androidTest/kotlin/com.mparticle/MParticleTest.kt b/android-core/src/androidTest/kotlin/com.mparticle/MParticleTest.kt index bda2aa4b6..f54e082be 100644 --- a/android-core/src/androidTest/kotlin/com.mparticle/MParticleTest.kt +++ b/android-core/src/androidTest/kotlin/com.mparticle/MParticleTest.kt @@ -169,13 +169,6 @@ class MParticleTest : BaseCleanStartedEachTest() { } } - @OrchestratorOnly - @Test - @Throws(JSONException::class, InterruptedException::class) - fun testResetSync() { - testReset { MParticle.reset(mContext) } - } - @OrchestratorOnly @Test @Throws(JSONException::class, InterruptedException::class) diff --git a/android-core/src/main/java/com/mparticle/internal/MPUtility.java b/android-core/src/main/java/com/mparticle/internal/MPUtility.java index aebeec65d..1eb623638 100644 --- a/android-core/src/main/java/com/mparticle/internal/MPUtility.java +++ b/android-core/src/main/java/com/mparticle/internal/MPUtility.java @@ -833,7 +833,7 @@ public static Number addNumbers(Number number1, Number number2) { public static Object toNumberOrString(String stringValue) { if (stringValue == null) { - return stringValue; + return null; } for (Character c : stringValue.toCharArray()) { if (!Character.isDigit(c) && c != '.' && c != '-') { @@ -841,9 +841,12 @@ public static Object toNumberOrString(String stringValue) { } } try { - return NumberFormat.getInstance().parse(stringValue); - } catch (ParseException e) { - } + return Integer.parseInt(stringValue); + } catch (NumberFormatException ignored){} + try { + return Double.parseDouble(stringValue); + } catch (NumberFormatException ignored){} + return stringValue; } diff --git a/android-core/src/test/kotlin/com/mparticle/internal/MPUtilityTest.kt b/android-core/src/test/kotlin/com/mparticle/internal/MPUtilityTest.kt index 91ffbb9b2..058e66ac7 100644 --- a/android-core/src/test/kotlin/com/mparticle/internal/MPUtilityTest.kt +++ b/android-core/src/test/kotlin/com/mparticle/internal/MPUtilityTest.kt @@ -236,10 +236,10 @@ class MPUtilityTest { @Test fun testNumberDetection() { - Assert.assertEquals(12L, MPUtility.toNumberOrString("12")) + Assert.assertEquals(12, MPUtility.toNumberOrString("12")) Assert.assertEquals(1.5, MPUtility.toNumberOrString("1.5")) Assert.assertEquals(-1.5, MPUtility.toNumberOrString("-1.5")) - Assert.assertEquals(0L, MPUtility.toNumberOrString("0")) + Assert.assertEquals(0, MPUtility.toNumberOrString("0")) // too big for a Long, should return a String Assert.assertEquals( 3.245987293478593E47,