0.2.0 #9

Manually merged
xdrm-brackets merged 43 commits from 0.2.0 into master 2020-03-08 15:28:42 +00:00
1 changed files with 45 additions and 1 deletions
Showing only changes of commit 5dad0ecc39 - Show all commits

View File

@ -32,7 +32,7 @@ func TestSimpleString(t *testing.T) {
} }
} }
func TestStringSlice(t *testing.T) { func TestJsonStringSlice(t *testing.T) {
p := Parameter{Parsed: false, File: false, Value: `["str1", "str2"]`} p := Parameter{Parsed: false, File: false, Value: `["str1", "str2"]`}
err := p.Parse() err := p.Parse()
@ -76,6 +76,50 @@ func TestStringSlice(t *testing.T) {
} }
func TestStringSlice(t *testing.T) {
p := Parameter{Parsed: false, File: false, Value: []string{"str1", "str2"}}
err := p.Parse()
if err != nil {
t.Errorf("unexpected error: <%s>", err)
t.FailNow()
}
if !p.Parsed {
t.Errorf("expected parameter to be parsed")
t.FailNow()
}
slice, canCast := p.Value.([]interface{})
if !canCast {
t.Errorf("expected parameter to be a []interface{}")
t.FailNow()
}
if len(slice) != 2 {
t.Errorf("expected 2 values, got %d", len(slice))
t.FailNow()
}
results := []string{"str1", "str2"}
for i, res := range results {
cast, canCast := slice[i].(string)
if !canCast {
t.Errorf("expected parameter %d to be a []string", i)
continue
}
if cast != res {
t.Errorf("expected first value to be '%s', got '%s'", res, cast)
continue
}
}
}
func TestJsonPrimitiveBool(t *testing.T) { func TestJsonPrimitiveBool(t *testing.T) {
tcases := []struct { tcases := []struct {
Raw string Raw string