-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptimization_test.go
More file actions
71 lines (67 loc) · 1.98 KB
/
optimization_test.go
File metadata and controls
71 lines (67 loc) · 1.98 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
package strings2
import (
"testing"
)
func TestOptimizationCorrectness(t *testing.T) {
// This test specifically targets the SingleCaseWord optimization path
// to ensure that mixed-case inputs are handled identically to the original
// implementation (which normalized to lowercase via .String() first).
tests := []struct {
name string
input []Word
options []Option
expected string
}{
{
name: "MixedCase Default (Implied Lower)",
input: []Word{SingleCaseWord("HeLLo"), SingleCaseWord("WoRLd")},
options: []Option{OptionDelimiter("-")},
expected: "hello-world",
},
{
name: "MixedCase Screaming",
input: []Word{SingleCaseWord("HeLLo"), SingleCaseWord("WoRLd")},
options: []Option{OptionDelimiter("-"), OptionCaseMode(CMScreaming)},
expected: "HELLO-WORLD",
},
{
name: "MixedCase Whispering",
input: []Word{SingleCaseWord("HeLLo"), SingleCaseWord("WoRLd")},
options: []Option{OptionDelimiter("-"), OptionCaseMode(CMWhispering)},
expected: "hello-world",
},
{
name: "MixedCase AllTitle",
input: []Word{SingleCaseWord("HeLLo"), SingleCaseWord("WoRLd")},
options: []Option{OptionDelimiter("-"), OptionCaseMode(CMAllTitle)},
expected: "Hello-World",
},
{
name: "MixedCase FirstTitle",
input: []Word{SingleCaseWord("HeLLo"), SingleCaseWord("WoRLd")},
options: []Option{OptionDelimiter("-"), OptionCaseMode(CMFirstTitle)},
expected: "Hello-world",
},
// Edge cases
{
name: "Empty String",
input: []Word{SingleCaseWord("")},
options: []Option{OptionDelimiter("-")},
expected: "",
},
{
name: "All Caps Input Default",
input: []Word{SingleCaseWord("HELLO")},
options: []Option{OptionDelimiter("-")},
expected: "hello",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := ToFormattedCase(tt.input, tt.options...)
if result != tt.expected {
t.Errorf("got %q, want %q", result, tt.expected)
}
})
}
}