aboutsummaryrefslogtreecommitdiff
path: root/passgen/diceware/src/test/kotlin/dev
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2022-07-15 00:53:48 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2022-07-15 01:13:47 +0530
commit549ee790d3e52bc62565ddf92e6a556e98b5195e (patch)
treed5758e5eb80093704e683c8da926838e18182588 /passgen/diceware/src/test/kotlin/dev
parent010c6e227c9cc27f4d01bc912311f977b2aeb3a7 (diff)
all: re-do package structure yet again
Diffstat (limited to 'passgen/diceware/src/test/kotlin/dev')
-rw-r--r--passgen/diceware/src/test/kotlin/dev/msfjarvis/aps/passgen/diceware/DicewarePassphraseGeneratorTest.kt29
-rw-r--r--passgen/diceware/src/test/kotlin/dev/msfjarvis/aps/passgen/diceware/DieTest.kt47
-rw-r--r--passgen/diceware/src/test/kotlin/dev/msfjarvis/aps/passgen/diceware/WordListParserTest.kt37
3 files changed, 0 insertions, 113 deletions
diff --git a/passgen/diceware/src/test/kotlin/dev/msfjarvis/aps/passgen/diceware/DicewarePassphraseGeneratorTest.kt b/passgen/diceware/src/test/kotlin/dev/msfjarvis/aps/passgen/diceware/DicewarePassphraseGeneratorTest.kt
deleted file mode 100644
index 236be708..00000000
--- a/passgen/diceware/src/test/kotlin/dev/msfjarvis/aps/passgen/diceware/DicewarePassphraseGeneratorTest.kt
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
- * SPDX-License-Identifier: GPL-3.0-only
- */
-
-package dev.msfjarvis.aps.passgen.diceware
-
-import kotlin.random.Random
-import kotlin.test.assertEquals
-import org.junit.Test
-
-class DicewarePassphraseGeneratorTest {
- /** Pre-seeded [Random] instance to ensure tests are deterministic. */
- private val random = Random(1_00_000)
-
- private val intGenerator = RandomIntGenerator { it.random(random) }
- @Test
- fun generatePassphrase() {
- val die = Die(6, intGenerator)
-
- val generator =
- DicewarePassphraseGenerator(
- die,
- WordListParserTest.getDefaultWordList(),
- )
-
- assertEquals("salvation_cozily_croon_trustee_fidgety", generator.generatePassphrase(5, '_'))
- }
-}
diff --git a/passgen/diceware/src/test/kotlin/dev/msfjarvis/aps/passgen/diceware/DieTest.kt b/passgen/diceware/src/test/kotlin/dev/msfjarvis/aps/passgen/diceware/DieTest.kt
deleted file mode 100644
index 7f6398f6..00000000
--- a/passgen/diceware/src/test/kotlin/dev/msfjarvis/aps/passgen/diceware/DieTest.kt
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
- * SPDX-License-Identifier: GPL-3.0-only
- */
-
-package dev.msfjarvis.aps.passgen.diceware
-
-import kotlin.random.Random
-import kotlin.test.Test
-import kotlin.test.assertEquals
-
-class DieTest {
-
- /** Pre-seeded [Random] instance to ensure tests are deterministic. */
- private val random = Random(1_00_000)
-
- private val intGenerator = RandomIntGenerator { it.random(random) }
-
- @Test
- fun oneRoll() {
- val die = Die(6, intGenerator)
- assertEquals(5, die.roll())
- }
-
- @Test
- fun multipleRolls() {
- val die = Die(6, intGenerator)
- assertEquals(526242, die.rollMultiple(6))
- }
-
- @Test
- fun consecutiveRolls() {
- val die = Die(6, intGenerator)
- assertEquals(5, die.roll())
- assertEquals(2, die.roll())
- assertEquals(6, die.roll())
- assertEquals(2, die.roll())
- assertEquals(4, die.roll())
- assertEquals(2, die.roll())
- }
-
- @Test
- fun hundredSides() {
- val die = Die(100, intGenerator)
- assertEquals(67, die.roll())
- }
-}
diff --git a/passgen/diceware/src/test/kotlin/dev/msfjarvis/aps/passgen/diceware/WordListParserTest.kt b/passgen/diceware/src/test/kotlin/dev/msfjarvis/aps/passgen/diceware/WordListParserTest.kt
deleted file mode 100644
index 9364085d..00000000
--- a/passgen/diceware/src/test/kotlin/dev/msfjarvis/aps/passgen/diceware/WordListParserTest.kt
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
- * SPDX-License-Identifier: GPL-3.0-only
- */
-
-package dev.msfjarvis.aps.passgen.diceware
-
-import java.io.InputStream
-import kotlin.test.Test
-import kotlin.test.assertEquals
-
-class WordListParserTest {
- @Test
- fun parseWordList() {
- val stream = "11111\tabcde\n22222\tfghij".byteInputStream()
- val parsedMap = WordListParser.parse(stream)
- assertEquals(2, parsedMap.size)
- assertEquals("abcde", parsedMap[11111])
- assertEquals("fghij", parsedMap[22222])
- }
-
- @Test
- fun parseDefaultWordList() {
- val wordlist = getDefaultWordList()
- val parsedMap = WordListParser.parse(wordlist)
- assertEquals(7776, parsedMap.size)
- assertEquals("zoom", parsedMap[66666])
- assertEquals("salute", parsedMap[52621])
- }
-
- companion object {
- fun getDefaultWordList(): InputStream {
- return requireNotNull(this::class.java.classLoader)
- .getResourceAsStream("diceware_wordlist.txt")
- }
- }
-}