filebrowser/frontmatter/types_test.go

50 lines
1.3 KiB
Go
Raw Normal View History

2017-06-19 16:10:03 +00:00
package frontmatter
import "testing"
type interfaceToBool struct {
Value interface{}
Result bool
}
var testIsMap = []*interfaceToBool{
&interfaceToBool{"teste", false},
&interfaceToBool{453478, false},
&interfaceToBool{-984512, false},
&interfaceToBool{true, false},
&interfaceToBool{map[string]bool{}, true},
&interfaceToBool{map[int]bool{}, true},
&interfaceToBool{map[interface{}]bool{}, true},
&interfaceToBool{[]string{}, false},
}
func TestIsMap(t *testing.T) {
for _, test := range testIsMap {
2017-06-19 16:10:03 +00:00
if isMap(test.Value) != test.Result {
t.Errorf("Incorrect value on IsMap for %v; want: %v; got: %v", test.Value, test.Result, !test.Result)
}
}
}
var testIsSlice = []*interfaceToBool{
&interfaceToBool{"teste", false},
&interfaceToBool{453478, false},
&interfaceToBool{-984512, false},
&interfaceToBool{true, false},
&interfaceToBool{map[string]bool{}, false},
&interfaceToBool{map[int]bool{}, false},
&interfaceToBool{map[interface{}]bool{}, false},
&interfaceToBool{[]string{}, true},
&interfaceToBool{[]int{}, true},
&interfaceToBool{[]bool{}, true},
&interfaceToBool{[]interface{}{}, true},
}
func TestIsSlice(t *testing.T) {
for _, test := range testIsSlice {
2017-06-19 16:10:03 +00:00
if isSlice(test.Value) != test.Result {
t.Errorf("Incorrect value on IsSlice for %v; want: %v; got: %v", test.Value, test.Result, !test.Result)
}
}
}