MCPcopy Create free account
hub / github.com/buger/jsonparser / TestPropertyNoPanicOnArbitraryBytes

Function TestPropertyNoPanicOnArbitraryBytes

property_test.go:1014–1051  ·  view source on GitHub ↗

--------------------------------------------------------------------------- Property: every public surface is panic-free on random bytes (universal) --------------------------------------------------------------------------- This is the universal OSS-Fuzz invariant asserted across the entire parser

(t *testing.T)

Source from the content-addressed store, hash-verified

1012// reqproof:proptest parser.Get
1013// Verifies: SYS-REQ-035 [property]
1014func TestPropertyNoPanicOnArbitraryBytes(t *testing.T) {
1015 r := newRNG(jsonSeed + 15)
1016 const iterations = 3000
1017 for i := 0; i < iterations; i++ {
1018 raw := randomBytes(r, 64)
1019 keys := []string{randKey(r)}
1020 _ = recoverNoPanic(func() { _, _, _, _ = Get(raw, keys...) })
1021 _ = recoverNoPanic(func() { _, _, _, _ = Get(raw) })
1022 _ = recoverNoPanic(func() { _, _ = GetString(raw, keys...) })
1023 _ = recoverNoPanic(func() { _, _ = GetInt(raw, keys...) })
1024 _ = recoverNoPanic(func() { _, _ = GetFloat(raw, keys...) })
1025 _ = recoverNoPanic(func() { _, _ = GetBoolean(raw, keys...) })
1026 _ = recoverNoPanic(func() { _, _ = GetUnsafeString(raw, keys...) })
1027 _ = recoverNoPanic(func() {
1028 ArrayEach(raw, func(value []byte, dataType ValueType, offset int, err error) {})
1029 })
1030 _ = recoverNoPanic(func() {
1031 ObjectEach(raw, func(key, value []byte, dataType ValueType, offset int) error { return nil })
1032 })
1033 _ = recoverNoPanic(func() {
1034 EachKey(raw, func(idx int, value []byte, vt ValueType, err error) {}, keys)
1035 })
1036 _ = recoverNoPanic(func() {
1037 assertInputUnchanged(t, raw, func() {
1038 _ = Delete(raw, keys...)
1039 })
1040 })
1041 _ = recoverNoPanic(func() {
1042 assertInputUnchanged(t, raw, func() {
1043 _, _ = Set(raw, []byte(`"x"`), keys...)
1044 })
1045 })
1046 _ = recoverNoPanic(func() { _, _ = ParseInt(raw) })
1047 _ = recoverNoPanic(func() { _, _ = ParseFloat(raw) })
1048 _ = recoverNoPanic(func() { _, _ = ParseBoolean(raw) })
1049 _ = recoverNoPanic(func() { _, _ = ParseString(raw) })
1050 }
1051}
1052
1053// ---------------------------------------------------------------------------
1054// Property: thread-safety — concurrent reads are panic-free and deterministic

Callers

nothing calls this directly

Calls 15

newRNGFunction · 0.85
randomBytesFunction · 0.85
randKeyFunction · 0.85
recoverNoPanicFunction · 0.85
GetFunction · 0.85
GetStringFunction · 0.85
GetIntFunction · 0.85
GetFloatFunction · 0.85
GetBooleanFunction · 0.85
GetUnsafeStringFunction · 0.85
ArrayEachFunction · 0.85
ObjectEachFunction · 0.85

Tested by

no test coverage detected