-
Notifications
You must be signed in to change notification settings - Fork 15
/
strings_test.go
68 lines (64 loc) · 1.22 KB
/
strings_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
66
67
68
package main
import (
"testing"
)
func TestCapitalizeWords(t *testing.T) {
if capitalizeWords("bob john") != "Bob John" {
t.Fail()
}
}
func TestWithinBackticks(t *testing.T) {
tests := []struct {
line string
what string
expected bool
}{
{
line: "This is a test `hello` string",
what: "hello",
expected: true,
},
{
line: "This is a test `hello world` string",
what: "world",
expected: true,
},
{
line: "This is a test `hello` string",
what: "world",
expected: false,
},
{
line: "This is a test `hello world` string",
what: "hello world",
expected: true,
},
{
line: "This is a test `hello world` string",
what: "test",
expected: false,
},
{
line: "`hello` world",
what: "hello",
expected: true,
},
{
line: "`hello` world",
what: "world",
expected: false,
},
{
line: "This is `a` test",
what: "a",
expected: true,
},
}
for _, tt := range tests {
t.Run(tt.line, func(t *testing.T) {
if got := withinBackticks(tt.line, tt.what); got != tt.expected {
t.Errorf("withinBackticks(%q, %q) = %v; expected %v", tt.line, tt.what, got, tt.expected)
}
})
}
}