Former-commit-id: 9c36dea485ddd16a90f0a615e20baddaee6b9cde
This commit is contained in:
Henrique Dias
2017-06-24 12:12:15 +01:00
parent b0e81a80a0
commit 850c4a10e1
23 changed files with 2408 additions and 0 deletions

49
variables/types_test.go Normal file
View File

@@ -0,0 +1,49 @@
package variables
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 {
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 {
if IsSlice(test.Value) != test.Result {
t.Errorf("Incorrect value on IsSlice for %v; want: %v; got: %v", test.Value, test.Result, !test.Result)
}
}
}