-
Notifications
You must be signed in to change notification settings - Fork 20
/
log_test.go
77 lines (57 loc) · 1.08 KB
/
log_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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package srt
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestHasTopic(t *testing.T) {
l := NewLogger([]string{
"packet:recv:dump",
})
ok := l.HasTopic("foobar")
require.False(t, ok)
ok = l.HasTopic("packet:recv:dump")
require.True(t, ok)
ok = l.HasTopic("packet:recv")
require.False(t, ok)
ok = l.HasTopic("packet")
require.False(t, ok)
}
var result bool
func BenchmarkHasTopicNil(b *testing.B) {
l := NewLogger(nil)
var r bool
for n := 0; n < b.N; n++ {
r = l.HasTopic("foobar")
}
result = r
}
func BenchmarkHasTopicD1(b *testing.B) {
l := NewLogger([]string{
"packet:recv:dump",
})
var r bool
for n := 0; n < b.N; n++ {
r = l.HasTopic("packet")
}
result = r
}
func BenchmarkHasTopicD2(b *testing.B) {
l := NewLogger([]string{
"packet:recv:dump",
})
var r bool
for n := 0; n < b.N; n++ {
r = l.HasTopic("packet:recv")
}
result = r
}
func BenchmarkHasTopicD3(b *testing.B) {
l := NewLogger([]string{
"packet:recv:dump",
})
var r bool
for n := 0; n < b.N; n++ {
r = l.HasTopic("packet:recv:dump")
}
result = r
}