-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdowncase_test.go
60 lines (56 loc) · 1.1 KB
/
downcase_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
package downcase
import (
"testing"
)
var testCases = []struct {
input string
expected string
}{
{
input: "",
expected: "",
},
{
input: "Hello World",
expected: "hello world",
},
{
input: "HeliOS",
expected: "helios",
},
{
input: "barong is oauth server for peatio.tech stack.",
expected: "barong is oauth server for peatio.tech stack.",
},
{
input: "tag 2.0.34",
expected: "tag 2.0.34",
},
{
input: "CryptoCurrency Exange PEATIO",
expected: "cryptocurrency exange peatio",
},
}
func TestDowncase(t *testing.T) {
for _, tt := range testCases {
actual, err := Downcase(tt.input)
// We don't expect errors for any of the test cases
if err != nil {
t.Fatalf("Downcase(%q) returned error %q. Error not expected.", tt.input, err)
}
if actual != tt.expected {
t.Fatalf("Downcase(%q) was expected to return %v but returned %v.",
tt.input, tt.expected, actual)
}
}
}
func BenchmarkDowncase(b *testing.B) {
b.StopTimer()
for _, tt := range testCases {
b.StartTimer()
for i := 0; i < b.N; i++ {
Downcase(tt.input)
}
b.StopTimer()
}
}