-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathstrings_test.go
More file actions
64 lines (55 loc) · 1.32 KB
/
Copy pathstrings_test.go
File metadata and controls
64 lines (55 loc) · 1.32 KB
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
package strings_funcs
import (
"testing"
)
func TestLowercase(t *testing.T) {
if Lowercase("Hello") != "hello" {
t.Errorf("expected 'hello', got '%s'", Lowercase("Hello"))
}
}
func TestUppercase(t *testing.T) {
if Uppercase("Hello") != "HELLO" {
t.Errorf("expected 'HELLO', got '%s'", Uppercase("Hello"))
}
}
func TestReplaceAll(t *testing.T) {
if ReplaceAll("hello world", "o", "a") != "hella warld" {
t.Errorf("expected 'hella warld', got '%s'", ReplaceAll("hello world", "o", "a"))
}
}
func TestContains(t *testing.T) {
if !Contains("hello", "ell") {
t.Error("expected true")
}
if Contains("hello", "xyz") {
t.Error("expected false")
}
}
func TestHasPrefix(t *testing.T) {
if !HasPrefix("hello", "hel") {
t.Error("expected true")
}
if HasPrefix("hello", "world") {
t.Error("expected false")
}
}
func TestHasSuffix(t *testing.T) {
if !HasSuffix("hello", "llo") {
t.Error("expected true")
}
if HasSuffix("hello", "xyz") {
t.Error("expected false")
}
}
func TestSplit(t *testing.T) {
expected := []string{"a", "b", "c"}
result := Split("a,b,c", ",")
if len(result) != len(expected) {
t.Errorf("expected %v, got %v", expected, result)
}
}
func TestJoin(t *testing.T) {
if Join([]string{"a", "b", "c"}, "-") != "a-b-c" {
t.Errorf("expected 'a-b-c', got '%s'", Join([]string{"a", "b", "c"}, "-"))
}
}