-
Notifications
You must be signed in to change notification settings - Fork 10
/
gensym_test.go
46 lines (37 loc) · 769 Bytes
/
gensym_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
package main
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestGensym(t *testing.T) {
g := gensym()
assert.Equal(t, g, "G1")
}
func TestSymbolGenerator_Next(t *testing.T) {
s := symbolGenerator{
Prefix: "A",
Suffix: "Z",
}
n := s.next()
n2 := s.next()
assert.Equal(t, n, "A1Z")
assert.Equal(t, n2, "A2Z")
}
func TestSymbolGenerator_Reset(t *testing.T) {
s := symbolGenerator{
Prefix: "A",
Suffix: "Z",
}
preCount := s.count
n := s.next()
onceCount := s.count
n2 := s.next()
twiceCount := s.count
s.reset()
assert.Equal(t, n, "A1Z")
assert.Equal(t, n2, "A2Z")
assert.Equal(t, s.count, uint64(0))
assert.Equal(t, preCount, uint64(0))
assert.Equal(t, onceCount, uint64(1))
assert.Equal(t, twiceCount, uint64(2))
}