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

Function TestGetBooleanPartialLiteral

deep_spec_test.go:783–795  ·  view source on GitHub ↗

============================================================================= GetBoolean partial literal (SYS-REQ-079) ============================================================================= Verifies: SYS-REQ-079 [boundary] GetBoolean on partial boolean literal shall return error.

(t *testing.T)

Source from the content-addressed store, hash-verified

781// Verifies: SYS-REQ-079 [boundary]
782// GetBoolean on partial boolean literal shall return error.
783func TestGetBooleanPartialLiteral(t *testing.T) {
784 // When a value is something like "tru" (not a real boolean), Get classifies it
785 // differently (Number or Unknown) and GetBoolean returns a type error.
786 _, err := GetBoolean([]byte(`{"a":1}`), "a")
787 if err == nil {
788 t.Fatal("GetBoolean on numeric value should return error")
789 }
790
791 _, err = GetBoolean([]byte(`{"a":"true"}`), "a")
792 if err == nil {
793 t.Fatal("GetBoolean on string 'true' should return error")
794 }
795}
796
797// =============================================================================
798// GetUnsafeString edge cases (SYS-REQ-080, SYS-REQ-081, SYS-REQ-082)

Callers

nothing calls this directly

Calls 1

GetBooleanFunction · 0.85

Tested by

no test coverage detected