Compare commits
No commits in common. "9189babe209946073c87b7983db7157ca94da279" and "feec6e96d00ba2ebda5b55735f9a2e7fc01faf9c" have entirely different histories.
9189babe20
...
feec6e96d0
|
@ -123,6 +123,6 @@ func parseParameter(data interface{}) (interface{}, error) {
|
|||
}
|
||||
|
||||
/* (3) NIL if unknown type */
|
||||
return dvalue.Interface(), nil
|
||||
return dvalue, ErrUnknownType
|
||||
|
||||
}
|
||||
|
|
|
@ -32,68 +32,6 @@ func TestSimpleString(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestSimpleFloat(t *testing.T) {
|
||||
tcases := []float64{12.3456789, -12.3456789, 0.0000001, -0.0000001}
|
||||
|
||||
for i, tcase := range tcases {
|
||||
t.Run("case "+string(i), func(t *testing.T) {
|
||||
p := Parameter{Parsed: false, File: false, Value: tcase}
|
||||
|
||||
if err := p.Parse(); err != nil {
|
||||
t.Errorf("unexpected error: <%s>", err)
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
if !p.Parsed {
|
||||
t.Errorf("expected parameter to be parsed")
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
cast, canCast := p.Value.(float64)
|
||||
if !canCast {
|
||||
t.Errorf("expected parameter to be a float64")
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
if math.Abs(cast-tcase) > 0.00000001 {
|
||||
t.Errorf("expected parameter to equal '%f', got '%f'", tcase, cast)
|
||||
t.FailNow()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestSimpleBool(t *testing.T) {
|
||||
tcases := []bool{true, false}
|
||||
|
||||
for i, tcase := range tcases {
|
||||
t.Run("case "+string(i), func(t *testing.T) {
|
||||
p := Parameter{Parsed: false, File: false, Value: tcase}
|
||||
|
||||
if err := p.Parse(); err != nil {
|
||||
t.Errorf("unexpected error: <%s>", err)
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
if !p.Parsed {
|
||||
t.Errorf("expected parameter to be parsed")
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
cast, canCast := p.Value.(bool)
|
||||
if !canCast {
|
||||
t.Errorf("expected parameter to be a bool")
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
if cast != tcase {
|
||||
t.Errorf("expected parameter to equal '%t', got '%t'", tcase, cast)
|
||||
t.FailNow()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestJsonStringSlice(t *testing.T) {
|
||||
p := Parameter{Parsed: false, File: false, Value: `["str1", "str2"]`}
|
||||
|
||||
|
|
Loading…
Reference in New Issue