-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy patheditstruct_test.go
More file actions
55 lines (51 loc) · 1.06 KB
/
editstruct_test.go
File metadata and controls
55 lines (51 loc) · 1.06 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
package frontend_test
import (
"testing"
"github.com/IPA-CyberLab/kmgm/frontend"
)
func TestStripErrorText(t *testing.T) {
testcases := []struct {
Input string
Expected string
}{
{"abcd", "abcd"},
{"", ""},
{`before
# *** LINES ABOVE WILL BE AUTOMATICALLY DELETED ***
after`,
"after"},
{`before
before2
# *** LINES ABOVE WILL BE AUTOMATICALLY DELETED ***
after
after2`,
"after\nafter2"},
{`before
# *** LINES ABOVE WILL BE AUTOMATICALLY DELETED ***`,
""},
}
for _, tc := range testcases {
actual := frontend.StripErrorText(tc.Input)
if actual != tc.Expected {
t.Errorf("Expected: %q Actual: %q", tc.Expected, actual)
}
}
}
func TestYamlEscapeString(t *testing.T) {
testcases := []struct {
Input string
Expected string
}{
{"abcd", "abcd"},
{"こんにちは", "こんにちは"},
{"💯", `"\U0001F4AF"`},
{"", `""`},
{"\t ", `"\t "`},
}
for _, tc := range testcases {
actual := frontend.YamlEscapeString(tc.Input)
if actual != tc.Expected {
t.Errorf("Expected: %q Actual: %q", tc.Expected, actual)
}
}
}