diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/gobang.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/gobang.go b/tests/gobang.go index 46cc9c5..324a155 100644 --- a/tests/gobang.go +++ b/tests/gobang.go @@ -10,6 +10,7 @@ import ( "fmt" "hash" "log/slog" + "os" "time" ) @@ -345,6 +346,42 @@ func test_scrypt() { }) } +func test_Random() { + TestStart("Random()") + + Testing("we get the desired output size", func() { + for i := 0; i < 100; i++ { + buffer := Random(i) + AssertEqual(len(buffer), i) + } + }) +} + +func test_Salt() { + TestStart("Salt()") + + Testing("we generate a random salt of a fixed size", func() { + salt := Salt() + AssertEqual(len(salt), scryptSaltMinLength) + + var buffer [scryptSaltMinLength * 2]byte + hex.Encode(buffer[:], salt) + fmt.Fprintf(os.Stderr, "%s ", string(buffer[:])) + }) +} + +func test_Hash() { + TestStart("Hash()") + + Testing("same input, same output", func() { + password := Random(16) + salt := Salt() + hash1 := Hash(password, salt) + hash2 := Hash(password, salt) + AssertEqual(hash1, hash2) + }) +} + func test_newUUIDFrom() { TestStart("newUUIDFrom()") @@ -480,6 +517,9 @@ func TestSetLoggerOutput() { func MainTest() { test__PBKDF() test_scrypt() + test_Hash() + test_Random() + test_Salt() test_newUUIDFrom() test_NewUUID() test_UUIDString() |