Skip to content

Commit 1f1aa69

Browse files
committed
More tests
1 parent 52114c8 commit 1f1aa69

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

android_sdk/src/main/java/co/optable/android_sdk/OptableSDK.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ class OptableSDK(context: Context, host: String, app: String, insecure: Boolean
206206
* gaid(gaid) is a helper that returns the type-prefixed Google Advertising ID
207207
*/
208208
fun gaid(gaid: String): String {
209-
return "g:" + gaid.trim()
209+
return "g:" + gaid.toLowerCase().trim()
210210
}
211211

212212
/*

android_sdk/src/test/java/co/optable/android_sdk/OptableSDKUnitTest.kt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,32 @@ class OptableSDKUnitTest {
3333
assertEquals(eid, OptableSDK.eid(var3))
3434
assertEquals(eid, OptableSDK.eid(var4))
3535
}
36+
37+
@Test
38+
fun gaid_isCorrectAndIgnoresCase() {
39+
val expected = "g:38400000-8cf0-11bd-b23e-10b96e40000d"
40+
41+
assertEquals(expected, OptableSDK.gaid("38400000-8cf0-11bd-b23e-10b96e40000d"))
42+
assertEquals(expected, OptableSDK.gaid(" 38400000-8cf0-11bd-b23e-10b96e40000d"))
43+
assertEquals(expected, OptableSDK.gaid("38400000-8cf0-11bd-b23e-10b96e40000d "))
44+
assertEquals(expected, OptableSDK.gaid(" 38400000-8cf0-11bd-b23e-10b96e40000d "))
45+
assertEquals(expected, OptableSDK.gaid("38400000-8CF0-11BD-B23E-10B96E40000D"))
46+
}
47+
48+
@Test
49+
fun cid_isCorrect() {
50+
val expected = "c:FooBarBAZ-01234#98765.!!!"
51+
52+
assertEquals(expected, OptableSDK.cid("FooBarBAZ-01234#98765.!!!"))
53+
assertEquals(expected, OptableSDK.cid(" FooBarBAZ-01234#98765.!!!"))
54+
assertEquals(expected, OptableSDK.cid("FooBarBAZ-01234#98765.!!! "))
55+
assertEquals(expected, OptableSDK.cid(" FooBarBAZ-01234#98765.!!! "))
56+
}
57+
58+
@Test
59+
fun cid_isCaseSensitive() {
60+
val unexpected = "c:FooBarBAZ-01234#98765.!!!"
61+
62+
assertNotEquals(unexpected, OptableSDK.cid("foobarBAZ-01234#98765.!!!"))
63+
}
3664
}

0 commit comments

Comments
 (0)