-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathline_test.go
89 lines (77 loc) · 2.43 KB
/
line_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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package specfile
import (
"reflect"
"testing"
)
func TestNewLineWithSingleLine(t *testing.T) {
line := NewLine(0, "test")
if line.Last != "test" || line.Offset != 0 || line.Len != 1 {
t.Error("[line]NewLine with single line test failed")
}
}
func TestNewLineWithMultipleLines(t *testing.T) {
line := NewLine(0, "test", "test1")
if !reflect.DeepEqual(line.Lines, []string{"test", "test1"}) || line.Last != "test1" || line.Offset != 0 || line.Len != 2 {
t.Error("[line]NewLine with multiple lines test failed")
}
}
func TestConditionalLine(t *testing.T) {
for _, c := range conditionalIndicators {
line := NewLine(0, c)
if !line.isConditional() {
t.Error("[line]Conditional test failed")
}
}
}
func TestSectionLine(t *testing.T) {
line := NewLine(0, "%description\n")
if !line.isSection() {
t.Error("[line]Section test failed")
}
}
func TestMacroLine(t *testing.T) {
line := NewLine(0, "%define fcitx5_version 5.0.1\n")
if !line.isMacro() {
t.Error("[line]Macro test failed")
}
}
func TestDependencyLine(t *testing.T) {
line := NewLine(0, "BuildRequires: xz\n")
if !line.isDependency() {
t.Error("[line]dependency test failed")
}
}
func TestTagLine(t *testing.T) {
line := NewLine(0, "Name: xz\n")
if !line.isTag() {
t.Error("[line]Tag test failed")
}
}
func TestAppendLineWithSingleLine(t *testing.T) {
line := NewLine(0, "test")
line.Concat(false, "test1")
if !reflect.DeepEqual(line.Lines, []string{"test", "test1"}) || line.Last != "test1" || line.Len != 2 {
t.Error("[line]Line.Concat with single line append test failed")
}
}
func TestAppendLineWithMultipleLines(t *testing.T) {
line := NewLine(0, "test")
line.Concat(false, "test1", "test2")
if !reflect.DeepEqual(line.Lines, []string{"test", "test1", "test2"}) || line.Last != "test2" || line.Len != 3 {
t.Error("[line]Line.Concat with multiple lines append test failed")
}
}
func TestPrependLineWithSingleLine(t *testing.T) {
line := NewLine(0, "test")
line.Concat(true, "test1")
if !reflect.DeepEqual(line.Lines, []string{"test1", "test"}) || line.Last != "test" || line.Len != 2 {
t.Error("[line]Line.Concat with single line prepend test failed")
}
}
func TestPrependLineWithMultipleLines(t *testing.T) {
line := NewLine(0, "test")
line.Concat(true, "test1", "test2")
if !reflect.DeepEqual(line.Lines, []string{"test1", "test2", "test"}) || line.Last != "test" || line.Len != 3 {
t.Error("[line]Line.Concat with multiple lines prepend test failed")
}
}