Skip to content

Commit dd3baff

Browse files
Merge pull request #312 from spf13/fix-tests
tests: fix tests after reverting map behavior
2 parents fc73346 + 27ebcdd commit dd3baff

1 file changed

Lines changed: 22 additions & 22 deletions

File tree

map_test.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,12 @@ func TestStringMapStringSlice(t *testing.T) {
181181
{jsonStringMapStringArray, jsonStringMapStringArrayResult, false},
182182

183183
// Failure cases
184-
{nil, nil, true},
185-
{testing.T{}, nil, true},
186-
{map[any]any{"foo": testing.T{}}, nil, true},
187-
{map[any]any{Key{"foo"}: "bar"}, nil, true}, // ToStringE(Key{"foo"}) should fail
188-
{jsonStringMapString, nil, true},
189-
{"", nil, true},
184+
{nil, map[string][]string{}, true},
185+
{testing.T{}, map[string][]string{}, true},
186+
{map[any]any{"foo": testing.T{}}, map[string][]string{}, true},
187+
{map[any]any{Key{"foo"}: "bar"}, map[string][]string{}, true}, // ToStringE(Key{"foo"}) should fail
188+
{jsonStringMapString, map[string][]string{"key 1": nil, "key 2": nil}, true},
189+
{"", map[string][]string{}, true},
190190
}
191191

192192
runMapTests(t, testCases, cast.ToStringMapStringSlice, cast.ToStringMapStringSliceE)
@@ -200,9 +200,9 @@ func TestStringMap(t *testing.T) {
200200
{`{"tag": "tags", "group": true}`, map[string]any{"tag": "tags", "group": true}, false},
201201

202202
// Failure cases
203-
{nil, nil, true},
204-
{testing.T{}, nil, true},
205-
{"", nil, true},
203+
{nil, map[string]any{}, true},
204+
{testing.T{}, map[string]any{}, true},
205+
{"", map[string]any{}, true},
206206
}
207207

208208
runMapTests(t, testCases, cast.ToStringMap, cast.ToStringMapE)
@@ -216,9 +216,9 @@ func TestStringMapBool(t *testing.T) {
216216
{`{"v1": true, "v2": false}`, map[string]bool{"v1": true, "v2": false}, false},
217217

218218
// Failure cases
219-
{nil, nil, true},
220-
{testing.T{}, nil, true},
221-
{"", nil, true},
219+
{nil, map[string]bool{}, true},
220+
{testing.T{}, map[string]bool{}, true},
221+
{"", map[string]bool{}, true},
222222
}
223223

224224
runMapTests(t, testCases, cast.ToStringMapBool, cast.ToStringMapBoolE)
@@ -235,9 +235,9 @@ func TestStringMapInt(t *testing.T) {
235235
{`{"v1": 67, "v2": 56}`, map[string]int{"v1": 67, "v2": 56}, false},
236236

237237
// Failure cases
238-
{nil, nil, true},
239-
{testing.T{}, nil, true},
240-
{"", nil, true},
238+
{nil, map[string]int{}, true},
239+
{testing.T{}, map[string]int{}, true},
240+
{"", map[string]int{}, true},
241241
}
242242

243243
runMapTests(t, testCases, cast.ToStringMapInt, cast.ToStringMapIntE)
@@ -255,9 +255,9 @@ func TestStringMapInt64(t *testing.T) {
255255
{`{"v1": 67, "v2": 56}`, map[string]int64{"v1": 67, "v2": 56}, false},
256256

257257
// Failure cases
258-
{nil, nil, true},
259-
{testing.T{}, nil, true},
260-
{"", nil, true},
258+
{nil, map[string]int64{}, true},
259+
{testing.T{}, map[string]int64{}, true},
260+
{"", map[string]int64{}, true},
261261
}
262262

263263
runMapTests(t, testCases, cast.ToStringMapInt64, cast.ToStringMapInt64E)
@@ -280,10 +280,10 @@ func TestStringMapString(t *testing.T) {
280280
{jsonString, stringMapString, false},
281281

282282
// Failure cases
283-
{nil, nil, true},
284-
{testing.T{}, nil, true},
285-
{invalidJsonString, nil, true},
286-
{emptyString, nil, true},
283+
{nil, map[string]string{}, true},
284+
{testing.T{}, map[string]string{}, true},
285+
{invalidJsonString, map[string]string{}, true},
286+
{emptyString, map[string]string{}, true},
287287
}
288288

289289
runMapTests(t, testCases, cast.ToStringMapString, cast.ToStringMapStringE)

0 commit comments

Comments
 (0)