forked from go-ego/gse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
token_test.go
58 lines (46 loc) · 871 Bytes
/
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
55
56
57
58
package gse
import (
"fmt"
"testing"
"github.com/vcaesar/tt"
)
var token = Token{
text: []Text{
[]byte("one"),
[]byte("two"),
},
}
func TestTokenEquals(t *testing.T) {
tt.True(t, token.Equals("onetwo"))
}
func TestTokenNotEquals(t *testing.T) {
tt.False(t, token.Equals("one-two"))
}
var strs = []Text{
Text("one"),
Text("two"),
Text("three"),
Text("four"),
}
func TextSliceToString(b *testing.B) {
for i := 0; i < b.N; i++ {
textSliceToString(strs)
}
}
func TextToString(b *testing.B) {
for i := 0; i < b.N; i++ {
textToString(strs)
}
}
func TestBenchmark(t *testing.T) {
fmt.Println("textToString: ")
fmt.Println(testing.Benchmark(TextToString))
fmt.Println("textSliceToString: ")
fmt.Println(testing.Benchmark(TextSliceToString))
}
func BenchmarkEquals(t *testing.B) {
fn := func() {
token.Equals("onetwo")
}
tt.BM(t, fn)
}