-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslug_test.go
65 lines (58 loc) · 1.61 KB
/
slug_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
package slug
import (
"testing"
"github.com/goloop/slug/lang"
)
// TestObjMake tests Make method.
func TestObjMake(t *testing.T) {
tests := []struct {
value string
expected string
}{
{
"Starlink Ілона Маска відкриє офіс в Україні",
"Starlink-Ilona-Maska-vidkryie-ofis-v-Ukraini",
},
{"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"},
}
s := New()
s.Lang(lang.UK)
for _, test := range tests {
if v := s.Make(test.value); v != test.expected {
t.Errorf("expected %s but %s", test.expected, v)
}
}
}
// TestObjLower tests Lower method.
func TestObjLower(t *testing.T) {
tests := []struct {
value string
lowerExpected string
upperExpected string
}{
{
"Starlink Ілона Маска відкриє офіс в Україні",
"starlink-ilona-maska-vidkryie-ofis-v-ukraini",
"STARLINK-ILONA-MASKA-VIDKRYIE-OFIS-V-UKRAINI",
},
{"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"},
}
s := New()
s.Lang(lang.UK)
for _, test := range tests {
if v := s.Lower(test.value); v != test.lowerExpected {
t.Errorf("expected %s but %s", test.lowerExpected, v)
}
if v := s.Upper(test.value); v != test.upperExpected {
t.Errorf("expected %s but %s", test.upperExpected, v)
}
}
}