aboutsummaryrefslogtreecommitdiff
path: root/app/src/test
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2019-08-13 23:49:04 -0700
committerAllan Wang <me@allanwang.ca>2019-08-13 23:49:04 -0700
commit06408157dfde2f40c6368c5ab03e46479428f566 (patch)
treefcfd2d6b273b9f5ce905b433cbdf1b0d540f1425 /app/src/test
parentca9eff5efe56e4ac1d65fda6e3d91dc6235986ac (diff)
downloadfrost-06408157dfde2f40c6368c5ab03e46479428f566.tar.gz
frost-06408157dfde2f40c6368c5ab03e46479428f566.tar.bz2
frost-06408157dfde2f40c6368c5ab03e46479428f566.zip
Use one stringbuilder per tag creation and add test
Diffstat (limited to 'app/src/test')
-rw-r--r--app/src/test/kotlin/com/pitchedapps/frost/injectors/TagObfuscatorTest.kt22
1 files changed, 22 insertions, 0 deletions
diff --git a/app/src/test/kotlin/com/pitchedapps/frost/injectors/TagObfuscatorTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/injectors/TagObfuscatorTest.kt
new file mode 100644
index 00000000..5c316a4a
--- /dev/null
+++ b/app/src/test/kotlin/com/pitchedapps/frost/injectors/TagObfuscatorTest.kt
@@ -0,0 +1,22 @@
+package com.pitchedapps.frost.injectors
+
+import java.util.UUID
+import kotlin.test.Test
+import kotlin.test.assertEquals
+
+class TagObfuscatorTest {
+
+ /**
+ * The same key should result in the same tag per session
+ */
+ @Test
+ fun consistentTags() {
+ val keys = generateSequence { UUID.randomUUID().toString() }.take(10).toSet()
+ val tags = keys.map {
+ val tag = generateSequence { TagObfuscator.obfuscateTag(it) }.take(10).toSet()
+ assertEquals(1, tag.size, "Key $it produced multiple tags: $tag")
+ tag.first()
+ }
+ assertEquals(keys.size, tags.size, "Key set and tag set have different sizes")
+ }
+}