-
Notifications
You must be signed in to change notification settings - Fork 0
/
methods_test.go
59 lines (53 loc) · 1.51 KB
/
methods_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
package slug
import (
"testing"
)
// TestMake tests Make function.
func TestMake(t *testing.T) {
tests := []struct {
value string
expected string
}{
{
"Starlink Ілона Маска відкриє офіс в Україні",
"Starlink-Ilona-Maska-vidkriie-ofis-v-Ukrayini",
},
{"Hellö Wörld", "Hello-World"},
{"你好世界", "Ni-Hao-Shi-Jie"},
{"[^你好世界$]", "Ni-Hao-Shi-Jie"},
{"This & that", "This-and-that"},
{"\tHellö \t Wörld\n ", "Hello-World"},
}
for _, test := range tests {
if v := Make(test.value); v != test.expected {
t.Errorf("expected %s but %s", test.expected, v)
}
}
}
// TestLower tests Lower function.
func TestLower(t *testing.T) {
tests := []struct {
value string
lowerExpected string
upperExpected string
}{
{
"Starlink Ілона Маска відкриє офіс в Україні",
"starlink-ilona-maska-vidkriie-ofis-v-ukrayini",
"STARLINK-ILONA-MASKA-VIDKRIIE-OFIS-V-UKRAYINI",
},
{"Hellö Wörld", "hello-world", "HELLO-WORLD"},
{"你好世界", "ni-hao-shi-jie", "NI-HAO-SHI-JIE"},
{"[^你好世界$]", "ni-hao-shi-jie", "NI-HAO-SHI-JIE"},
{"This & that", "this-and-that", "THIS-AND-THAT"},
{"\tHellö \t Wörld\n ", "hello-world", "HELLO-WORLD"},
}
for _, test := range tests {
if v := Lower(test.value); v != test.lowerExpected {
t.Errorf("expected %s but %s", test.lowerExpected, v)
}
if v := Upper(test.value); v != test.upperExpected {
t.Errorf("expected %s but %s", test.upperExpected, v)
}
}
}