-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsanitize_test.go
More file actions
81 lines (78 loc) · 1.77 KB
/
Copy pathsanitize_test.go
File metadata and controls
81 lines (78 loc) · 1.77 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package main
import "testing"
func TestSanitizeTitle(t *testing.T) {
tests := []struct {
name string
input string
expected string
}{
{
name: "HTML entity apostrophe with possessive",
input: "World's 1st Coding Monitor",
expected: "World 1st Coding Monitor",
},
{
name: "HTML entity double quote",
input: "Hello "World"",
expected: "Hello World",
},
{
name: "HTML entity ampersand",
input: "Tom & Jerry",
expected: "Tom & Jerry",
},
{
name: "Contraction don't",
input: "I don't know",
expected: "I do not know",
},
{
name: "Contraction doesn't",
input: "It doesn't work",
expected: "It does not work",
},
{
name: "Contraction can't",
input: "You can't do this",
expected: "You cannot do this",
},
{
name: "Contraction won't",
input: "They won't come",
expected: "They will not come",
},
{
name: "Contraction it's",
input: "it's great",
expected: "it is great",
},
{
name: "Possessive 's dropped",
input: "World's best",
expected: "World best",
},
{
name: "Smart quotes removed",
input: "Hello \u201cWorld\u201d and \u2018test\u2019",
expected: "Hello World and test",
},
{
name: "Mixed HTML entities and contractions",
input: "World's 1st Monitor that doesn't break",
expected: "World 1st Monitor that does not break",
},
{
name: "Plain title unchanged",
input: "A Simple Title",
expected: "A Simple Title",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := sanitizeTitle(tt.input)
if got != tt.expected {
t.Errorf("sanitizeTitle(%q) = %q, want %q", tt.input, got, tt.expected)
}
})
}
}