-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrackInfo_test.go
38 lines (32 loc) · 1.04 KB
/
TrackInfo_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
package radiowatch
import "testing"
var (
tests = []struct {
input string
expected string
}{
{"already_normalized", "already_normalized"},
{"NoSpecialChars", "nospecialchars"},
{"Some White Space", "some_white_space"},
{"Moar!?Oh, yeah!<.<", "moar_oh_yeah"},
}
)
func TestTrackInfo_NormalizedStationName(t *testing.T) {
for _, tl := range tests {
ti := TrackInfo{Station:tl.input}
actual := ti.NormalizedStationName()
if actual != tl.expected {
t.Errorf("NormalizedStationName(%v): Expected %v, got %v", tl.input, tl.expected, actual)
}
}
}
func benchNormalize(input string, b *testing.B) {
ti := TrackInfo{Station:input}
for i := 0; i < b.N; i++ {
ti.NormalizedStationName()
}
}
func BenchmarkTI_NormalizedAlready(b *testing.B) {benchNormalize(tests[0].input, b)}
func BenchmarkTI_NormalizedUpper(b *testing.B) {benchNormalize(tests[1].input, b)}
func BenchmarkTI_NormalizedWhitespace(b *testing.B) {benchNormalize(tests[2].input, b)}
func BenchmarkTI_NormalizedSpecialchars(b *testing.B) {benchNormalize(tests[3].input, b)}