-
Notifications
You must be signed in to change notification settings - Fork 0
/
section_test.go
45 lines (33 loc) · 1.28 KB
/
section_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
package configure
import "testing"
var contentWithDefault = []string{"# test1", "key = 1", "# test2", "key2 = 2"}
//var contentWithoutDefault = []string{"[sec0]","# test1","key = 1","[sec1]","key2 = aaa","key3 = bbb","key4 = ccc","[sec2]","# desdes","key5=adsfeq1234"}
var contentEmpty = []string{}
func TestSection_Name(t *testing.T) {
testSection, _ := NewSection("test", nil, nil)
r := testSection.Name()
expected := "test"
if r != expected {
t.Errorf("expected '%s' but got '%s'", expected, r)
}
}
func TestSection_ItemKeyVal(t *testing.T) {
testSection, _ := NewSection("test", contentWithDefault, nil)
len_r := len(testSection.items)
firstName := testSection.items[0].Name()
expected_r := 2
expected_name := "key1"
if expected_r != len_r && expected_name != firstName {
t.Errorf("expected length '%d','%s' but got, '%d' '%s'", expected_r, expected_name, len_r, firstName)
}
}
func TestSection_Description(t *testing.T) {
var testSection, _ = NewSection("test", contentWithDefault, nil)
len_r := len(testSection.items)
firstName := testSection.items[1].Description()
expected_r := 2
expected_name := "test2"
if expected_r != len_r && expected_name != firstName {
t.Errorf("expected length '%d','%s' but got, '%d' '%s'", expected_r, expected_name, len_r, firstName)
}
}