MCPcopy
hub / github.com/buger/jsonparser / TestTokenEndSentinel

Function TestTokenEndSentinel

deep_spec_test.go:112–133  ·  view source on GitHub ↗

============================================================================= Sentinel-value tests (SYS-REQ-044, SYS-REQ-045, SYS-REQ-046) ============================================================================= Verifies: SYS-REQ-044 [boundary] tokenEnd returns len(data) when no delimiter found

(t *testing.T)

Source from the content-addressed store, hash-verified

110// Verifies: SYS-REQ-044 [boundary]
111// tokenEnd returns len(data) when no delimiter found. Callers must bounds-check.
112func TestTokenEndSentinel(t *testing.T) {
113 // tokenEnd on a value with no terminator returns len(data)
114 data := []byte(`123`)
115 end := tokenEnd(data)
116 if end != len(data) {
117 t.Fatalf("tokenEnd(%q) = %d, want %d (sentinel)", string(data), end, len(data))
118 }
119
120 // Verify tokenEnd returns correct index when delimiter exists
121 data2 := []byte(`123,`)
122 end2 := tokenEnd(data2)
123 if end2 != 3 {
124 t.Fatalf("tokenEnd(%q) = %d, want 3", string(data2), end2)
125 }
126
127 // Empty input
128 data3 := []byte(``)
129 end3 := tokenEnd(data3)
130 if end3 != 0 {
131 t.Fatalf("tokenEnd(empty) = %d, want 0", end3)
132 }
133}
134
135// Verifies: SYS-REQ-045 [boundary]
136// stringEnd returns -1 when no closing quote found. Callers must handle.

Callers

nothing calls this directly

Calls 1

tokenEndFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…