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

Function runDeleteTests

parser_test.go:1315–1348  ·  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

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

Callers 1

TestDeleteFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected