优化 CK 导入和监控配置
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package gui
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestSplitCookieLinesNormalizesLineBreaks(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input string
|
||||
want []string
|
||||
}{
|
||||
{
|
||||
name: "crlf_and_cr",
|
||||
input: "ck-a\r\nck-b\rck-c",
|
||||
want: []string{"ck-a", "ck-b", "ck-c"},
|
||||
},
|
||||
{
|
||||
name: "escaped_line_breaks",
|
||||
input: `ck-a\r\nck-b\rck-c\nck-d`,
|
||||
want: []string{"ck-a", "ck-b", "ck-c", "ck-d"},
|
||||
},
|
||||
{
|
||||
name: "slash_r_line_breaks",
|
||||
input: "ck-a/r/nck-b/rck-c/nck-d",
|
||||
want: []string{"ck-a", "ck-b", "ck-c", "ck-d"},
|
||||
},
|
||||
{
|
||||
name: "slash_n_only_is_preserved",
|
||||
input: "ck-a/nck-b",
|
||||
want: []string{"ck-a/nck-b"},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
lines := splitCookieLines(tt.input)
|
||||
if len(lines) != len(tt.want) {
|
||||
t.Fatalf("len(splitCookieLines()) = %d, want %d", len(lines), len(tt.want))
|
||||
}
|
||||
for i, line := range lines {
|
||||
if line.text != tt.want[i] {
|
||||
t.Fatalf("line[%d] = %q, want %q", i, line.text, tt.want[i])
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user