Skip to content

Commit ec45224

Browse files
committed
Add more fuzz seeds, log data that unmarshal to nil.
1 parent bedaaff commit ec45224

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

bson/decode_value_fuzz_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ func FuzzDecodeValue(f *testing.F) {
2727
int64(0), math.MaxInt64, math.MinInt64,
2828
// string, including empty and large string.
2929
"", strings.Repeat("z", 10_000),
30+
// map
31+
map[string]any{"nested": []any{1, "two", map[string]any{"three": 3}}},
32+
// array
33+
[]any{1, 2, 3, "four"},
3034
}
3135

3236
for _, v := range values {
@@ -48,6 +52,7 @@ func FuzzDecodeValue(f *testing.F) {
4852
// to "nil". It's not clear if MarshalValue should support "nil", but
4953
// for now we skip it.
5054
if v == nil {
55+
t.Logf("data unmarshaled to nil: %v", data)
5156
return
5257
}
5358

@@ -56,7 +61,8 @@ func FuzzDecodeValue(f *testing.F) {
5661
t.Fatalf("failed to marshal: %v", err)
5762
}
5863

59-
if err := UnmarshalValue(typ, encoded, &v); err != nil {
64+
var v2 any
65+
if err := UnmarshalValue(typ, encoded, &v2); err != nil {
6066
t.Fatalf("failed to unmarshal: %v", err)
6167
}
6268
})

0 commit comments

Comments
 (0)