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

Function TestTokenStart

parser_test.go:2292–2309  ·  view source on GitHub ↗

Verifies: STK-REQ-001 [boundary] MCDC STK-REQ-001: N/A

(t *testing.T)

Source from the content-addressed store, hash-verified

2290// Verifies: STK-REQ-001 [boundary]
2291// MCDC STK-REQ-001: N/A
2292func TestTokenStart(t *testing.T) {
2293 cases := []struct {
2294 name string
2295 input string
2296 expected int
2297 }{
2298 {name: "comma separator", input: `{"a":1,"b":2`, expected: 6},
2299 {name: "array separator", input: `[1,2`, expected: 2},
2300 {name: "opening object", input: `{"a":1`, expected: 0},
2301 {name: "no separator", input: `value`, expected: 0},
2302 }
2303
2304 for _, tc := range cases {
2305 if got := tokenStart([]byte(tc.input)); got != tc.expected {
2306 t.Fatalf("%s: tokenStart(%q) = %d, want %d", tc.name, tc.input, got, tc.expected)
2307 }
2308 }
2309}
2310
2311var parseStringTest = []ParseTest{
2312 {

Callers

nothing calls this directly

Calls 1

tokenStartFunction · 0.85

Tested by

no test coverage detected