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

Function runDeleteTests

parser_test.go:1299–1332  ·  view source on GitHub ↗

Test helper for SYS-REQ-010.

(t *testing.T, testKind string, tests []DeleteTest, runner func(DeleteTest) (interface{}, []byte), resultChecker func(DeleteTest, interface{}) (bool, interface{}))

Source from the content-addressed store, hash-verified

1297
1298// Test helper for SYS-REQ-010.
1299func runDeleteTests(t *testing.T, testKind string, tests []DeleteTest, runner func(DeleteTest) (interface{}, []byte), resultChecker func(DeleteTest, interface{}) (bool, interface{})) {
1300 for _, test := range tests {
1301 if activeTest != "" && test.desc != activeTest {
1302 continue
1303 }
1304
1305 original := make([]byte, len(test.json))
1306 copy(original, test.json)
1307
1308 fmt.Println("Running:", test.desc)
1309
1310 value, bytes := runner(test)
1311
1312 if string(original) != string(bytes) {
1313 t.Errorf("ORIGINAL DATA MALFORMED: %v, %v", string(original), string(bytes))
1314 continue
1315 }
1316
1317 if test.data == nil {
1318 t.Errorf("MALFORMED TEST: %v", test)
1319 continue
1320 }
1321
1322 if ok, expected := resultChecker(test, value); !ok {
1323 if expectedBytes, ok := expected.([]byte); ok {
1324 expected = string(expectedBytes)
1325 }
1326 if valueBytes, ok := value.([]byte); ok {
1327 value = string(valueBytes)
1328 }
1329 t.Errorf("%s test '%s' expected to return value %v, but did returned %v instead", testKind, test.desc, expected, value)
1330 }
1331 }
1332}
1333
1334// Verifies: SYS-REQ-010 [example]
1335// MCDC SYS-REQ-010: delete_path_is_provided=F, delete_returns_empty_document_without_path=T => TRUE

Callers 1

TestDeleteFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…