@@ -27,26 +27,24 @@ func TestMain(m *testing.M) {
27
27
}
28
28
29
29
func TestReadMap_simple (t * testing.T ) {
30
- result := readMap (parsedData , "b" , []string {"c" })
31
- if result != 2 {
32
- t .Error ("Excpted 2 but got " , result )
33
- }
30
+ assertResult (t , 2 , readMap (parsedData , "b" , []string {"c" }))
34
31
}
35
32
36
33
func TestReadMap_array (t * testing.T ) {
37
- result := readMap (parsedData , "b" , []string {"d" , "1" })
38
- if result != 4 {
39
- t .Error ("Excpted 4 but got " , result )
40
- }
34
+ assertResult (t , 4 , readMap (parsedData , "b" , []string {"d" , "1" }))
41
35
}
42
36
43
37
func TestWrite_simple (t * testing.T ) {
44
38
45
39
write (parsedData , "b" , []string {"c" }, "4" )
46
40
47
41
b := parsedData ["b" ].(map [interface {}]interface {})
48
- c := b ["c" ].(string )
49
- if c != "4" {
50
- t .Error ("Excepted 4 but got " , c )
42
+ assertResult (t , "4" , b ["c" ].(string ))
43
+ }
44
+
45
+
46
+ func assertResult (t * testing.T , expectedValue interface {}, actualValue interface {}) {
47
+ if (expectedValue != actualValue ) {
48
+ t .Error ("Expected <" , expectedValue , "> but got <" , actualValue , ">" )
51
49
}
52
50
}
0 commit comments