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

Function TestSetStringSpecialChars

escape_test.go:480–507  ·  view source on GitHub ↗

Verifies: SYS-REQ-002 (GetString) Verifies: SYS-REQ-009 (Set) Verifies: SYS-REQ-009 (Set) reqproof:proptest:skip targeted witness/regression test; not a property-test subject

(t *testing.T)

Source from the content-addressed store, hash-verified

478// Verifies: SYS-REQ-009 (Set)
479// reqproof:proptest:skip targeted witness/regression test; not a property-test subject
480func TestSetStringSpecialChars(t *testing.T) {
481 tests := []string{
482 `a\b`,
483 `a"b`,
484 "a\nb",
485 "a\tb",
486 }
487
488 for _, want := range tests {
489 t.Run(want, func(t *testing.T) {
490 data, err := SetString([]byte(`{"key":""}`), want, "key")
491 if err != nil {
492 t.Fatalf("SetString(%q) returned error: %v", want, err)
493 }
494 if !json.Valid(data) {
495 t.Fatalf("SetString(%q) returned invalid JSON: %s", want, data)
496 }
497
498 got, err := GetString(data, "key")
499 if err != nil {
500 t.Fatalf("GetString after SetString(%q) returned error: %v", want, err)
501 }
502 if got != want {
503 t.Fatalf("GetString after SetString(%q) = %q; want %q", want, got, want)
504 }
505 })
506 }
507}

Callers

nothing calls this directly

Calls 2

SetStringFunction · 0.85
GetStringFunction · 0.85

Tested by

no test coverage detected