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

Function TestPropertyNoPanicOnArbitraryBytes

property_test.go:901–930  ·  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

899// reqproof:proptest Get
900// Verifies: SYS-REQ-035 [property]
901func TestPropertyNoPanicOnArbitraryBytes(t *testing.T) {
902 r := newRNG(jsonSeed + 15)
903 const iterations = 3000
904 for i := 0; i < iterations; i++ {
905 raw := randomBytes(r, 64)
906 keys := []string{randKey(r)}
907 _ = recoverNoPanic(func() { _, _, _, _ = Get(raw, keys...) })
908 _ = recoverNoPanic(func() { _, _, _, _ = Get(raw) })
909 _ = recoverNoPanic(func() { _, _ = GetString(raw, keys...) })
910 _ = recoverNoPanic(func() { _, _ = GetInt(raw, keys...) })
911 _ = recoverNoPanic(func() { _, _ = GetFloat(raw, keys...) })
912 _ = recoverNoPanic(func() { _, _ = GetBoolean(raw, keys...) })
913 _ = recoverNoPanic(func() { _, _ = GetUnsafeString(raw, keys...) })
914 _ = recoverNoPanic(func() {
915 ArrayEach(raw, func(value []byte, dataType ValueType, offset int, err error) {})
916 })
917 _ = recoverNoPanic(func() {
918 ObjectEach(raw, func(key, value []byte, dataType ValueType, offset int) error { return nil })
919 })
920 _ = recoverNoPanic(func() {
921 EachKey(raw, func(idx int, value []byte, vt ValueType, err error) {}, keys)
922 })
923 _ = recoverNoPanic(func() { _ = Delete(raw, keys...) })
924 _ = recoverNoPanic(func() { _, _ = Set(raw, []byte(`"x"`), keys...) })
925 _ = recoverNoPanic(func() { _, _ = ParseInt(raw) })
926 _ = recoverNoPanic(func() { _, _ = ParseFloat(raw) })
927 _ = recoverNoPanic(func() { _, _ = ParseBoolean(raw) })
928 _ = recoverNoPanic(func() { _, _ = ParseString(raw) })
929 }
930}
931
932// ---------------------------------------------------------------------------
933// 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