Skip to content

Commit

Permalink
Add UTF-8 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zah committed Oct 16, 2020
1 parent 359b774 commit ea6de34
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/test_all.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import
../zxcvbn

proc passwordEntropy(x: string): float =
result = zxcvbn.passwordEntropy(x)
echo x, " = ", result

# ASCII passwords:
let
a = passwordEntropy "a"
cat = passwordEntropy "cat"
Expand All @@ -21,4 +26,18 @@ doAssert remixedQwerty > cat
doAssert remixedQwerty > a
doAssert remixedQwerty > longRepeatingSequence

# UTF-8 Passwords:
let
bulgarianPassword = passwordEntropy("парола")
bulgarianRepeatingSeq = passwordEntropy("яяяяяя")
japanesePassword = passwordEntropy("パスワード")
japaneseRepeatingSeq = passwordEntropy("パパパパパ")
chinesePassword = passwordEntropy("密碼")
chineseFourWords = passwordEntropy("正確的馬電池釘書釘")

doAssert bulgarianPassword > bulgarianRepeatingSeq
doAssert japanesePassword > japaneseRepeatingSeq
doAssert chineseFourWords > chinesePassword

echo "SUCCESS"

0 comments on commit ea6de34

Please sign in to comment.