-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathrebecca_test.go
65 lines (63 loc) · 1.05 KB
/
rebecca_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
package rebecca
import (
"strconv"
"testing"
)
func TestExtractSections(t *testing.T) {
comment := "foo. bar. baz. qux. quz."
tests := []struct {
sections string
expected string
}{
{
sections: "0",
expected: "foo.",
},
{
sections: "0:1",
expected: "foo.",
},
{
sections: "0:2",
expected: "foo. bar.",
},
{
sections: "1:2",
expected: "bar.",
},
{
sections: "2:4",
expected: "baz. qux.",
},
{
sections: "4:",
expected: "quz.",
},
{
sections: "1:",
expected: "bar. baz. qux. quz.",
},
{
sections: "2:",
expected: "baz. qux. quz.",
},
{
sections: ":1",
expected: "foo.",
},
{
sections: ":2",
expected: "foo. bar.",
},
{
sections: ":4",
expected: "foo. bar. baz. qux.",
},
}
for _, test := range tests {
found := extractSections("Spec["+test.sections+"]", test.sections, comment)
if found != test.expected {
t.Fatalf("SectionSpec: %s. Expected %s. Found %s.", strconv.Quote(test.sections), strconv.Quote(test.expected), strconv.Quote(found))
}
}
}