-
Notifications
You must be signed in to change notification settings - Fork 2
/
util_test.go
48 lines (40 loc) · 897 Bytes
/
util_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package atoll
import (
"testing"
)
func TestBufferPool(t *testing.T) {
text := "bufferpool test"
buf := getBuf()
buf.WriteString(text)
if buf.String() != text {
t.Error("The buffer contains erroneous text")
}
putBuf(buf)
if buf.Len() != 0 {
t.Error("The buffer is not empty")
}
}
func TestGetFuncName(t *testing.T) {
cases := []struct {
List func(p *Passphrase, length int)
Expected string
}{
{List: NoList, Expected: "NoList"},
{List: WordList, Expected: "WordList"},
{List: SyllableList, Expected: "SyllableList"},
}
for _, tc := range cases {
got := getFuncName(tc.List)
if got != tc.Expected {
t.Errorf("Expected %q, got %q", tc.Expected, got)
}
}
}
func TestShuffle(t *testing.T) {
p := "%A$Ks#a0t14|&23"
password := []byte(p)
shuffle(password)
if p == string(password) {
t.Errorf("Expected something different, got: %s", password)
}
}