From 06408157dfde2f40c6368c5ab03e46479428f566 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Tue, 13 Aug 2019 23:49:04 -0700 Subject: Use one stringbuilder per tag creation and add test --- .../frost/injectors/TagObfuscatorTest.kt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 app/src/test/kotlin/com/pitchedapps/frost/injectors/TagObfuscatorTest.kt (limited to 'app/src/test/kotlin') 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") + } +} -- cgit v1.2.3