-
Notifications
You must be signed in to change notification settings - Fork 0
/
xcase_test.go
49 lines (40 loc) · 1.18 KB
/
xcase_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
package scs
import (
"strings"
"testing"
)
// TestGetChunks tests getChunks function.
func TestGetChunks(t *testing.T) {
var expected = []string{"russian", "warship", "go", "fuck", "yourself"}
chunks := getChunks("Russian warship, go fuck yourself!")
for i, r := range chunks {
if e := expected[i]; e != r {
t.Errorf("expected %s but %s", e, r)
}
}
if len(chunks) != len(expected) {
t.Error("incorrect getChunk's result")
}
}
// TestToUnited tests toUnited function.
func TestToUnited(t *testing.T) {
var expected = "russianWarshipGoFuckYourself"
// The camelCase
result := toUnited("Russian warship, go fuck yourself!", true)
if result != expected {
t.Errorf("expected %s but %s", expected, result)
}
// The PascalCase
result = toUnited("Russian warship, go fuck yourself!", false)
if result != strings.Title(expected) {
t.Errorf("expected %s but %s", strings.Title(expected), result)
}
}
// TestToSeparate tests toSeparate function.
func TestToSeparate(t *testing.T) {
var expected = "russian:warship:go:fuck:yourself"
result := toSeparate("Russian warship, go fuck yourself!", ":")
if result != expected {
t.Errorf("expected %s but %s", expected, result)
}
}