-
Notifications
You must be signed in to change notification settings - Fork 0
/
token_test.go
54 lines (39 loc) · 1 KB
/
token_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
49
50
51
52
53
54
package humantoken
import (
"github.com/stretchr/testify/assert"
"math/rand"
"testing"
)
func TestZeroSizeToken(t *testing.T) {
got := Generate(0, nil)
assert.Len(t, got, 0)
}
func TestSpecificSizeToken(t *testing.T) {
got := Generate(10, nil)
assert.Len(t, got, 10)
}
func TestRespectUseOfRand(t *testing.T) {
want := Generate(50, rand.New(rand.NewSource(0)))
got := Generate(50, rand.New(rand.NewSource(0)))
assert.Equal(t, got, want)
}
func TestReusingRandDiffResults(t *testing.T) {
r := rand.New(rand.NewSource(0))
want := Generate(50, r)
got := Generate(50, r)
assert.NotEqual(t, got, want)
}
func TestGenerateWithSameIndices(t *testing.T) {
idx0 := []int{1, 1, 1}
idx1 := []int{1, 1, 1}
want := GenerateWithIndices(idx0)
got := GenerateWithIndices(idx1)
assert.Equal(t, got, want)
}
func TestGenerateWithDifferentIndices(t *testing.T) {
idx0 := []int{1, 1, 1}
idx1 := []int{2, 2, 2}
want := GenerateWithIndices(idx0)
got := GenerateWithIndices(idx1)
assert.NotEqual(t, got, want)
}