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

Function runDeleteTests

parser_test.go:1316–1349  ·  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

1314
1315// Test helper for SYS-REQ-010.
1316func runDeleteTests(t *testing.T, testKind string, tests []DeleteTest, runner func(DeleteTest) (interface{}, []byte), resultChecker func(DeleteTest, interface{}) (bool, interface{})) {
1317 for _, test := range tests {
1318 if activeTest != "" && test.desc != activeTest {
1319 continue
1320 }
1321
1322 original := make([]byte, len(test.json))
1323 copy(original, test.json)
1324
1325 fmt.Println("Running:", test.desc)
1326
1327 value, bytes := runner(test)
1328
1329 if string(original) != string(bytes) {
1330 t.Errorf("ORIGINAL DATA MALFORMED: %v, %v", string(original), string(bytes))
1331 continue
1332 }
1333
1334 if test.data == nil {
1335 t.Errorf("MALFORMED TEST: %v", test)
1336 continue
1337 }
1338
1339 if ok, expected := resultChecker(test, value); !ok {
1340 if expectedBytes, ok := expected.([]byte); ok {
1341 expected = string(expectedBytes)
1342 }
1343 if valueBytes, ok := value.([]byte); ok {
1344 value = string(valueBytes)
1345 }
1346 t.Errorf("%s test '%s' expected to return value %v, but did returned %v instead", testKind, test.desc, expected, value)
1347 }
1348 }
1349}
1350
1351// Verifies: SYS-REQ-010 [example]
1352// STK-REQ-005:AC-2:acceptance

Callers 1

TestDeleteFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected