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

Function isSameMemory

escape_test.go:156–168  ·  view source on GitHub ↗

isSameMemory checks if two slices contain the same memory pointer (meaning one is a subslice of the other, with possibly differing lengths/capacities). Test helper for SYS-REQ-014.

(a, b []byte)

Source from the content-addressed store, hash-verified

154// subslice of the other, with possibly differing lengths/capacities).
155// Test helper for SYS-REQ-014.
156func isSameMemory(a, b []byte) bool {
157 if cap(a) == 0 || cap(b) == 0 {
158 return cap(a) == cap(b)
159 } else if a, b = a[:1], b[:1]; a[0] != b[0] {
160 return false
161 } else {
162 a[0]++
163 same := (a[0] == b[0])
164 a[0]--
165 return same
166 }
167
168}
169
170// Verifies: SYS-REQ-014 [malformed]
171// MCDC SYS-REQ-014: N/A

Callers 1

TestUnescapeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected