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

Function setTestCheckFoundAndNoError

parser_test.go:1263–1285  ·  view source on GitHub ↗

Test helper for SYS-REQ-009.

(t *testing.T, testKind string, test SetTest, value interface{}, err error)

Source from the content-addressed store, hash-verified

1261
1262// Test helper for SYS-REQ-009.
1263func setTestCheckFoundAndNoError(t *testing.T, testKind string, test SetTest, value interface{}, err error) bool {
1264 isFound := (err != KeyPathNotFoundError)
1265 isErr := (err != nil && err != KeyPathNotFoundError)
1266
1267 if test.isErr != isErr {
1268 // If the call didn't match the error expectation, fail
1269 t.Errorf("%s test '%s' isErr mismatch: expected %t, obtained %t (err %v). Value: %v", testKind, test.desc, test.isErr, isErr, err, value)
1270 return false
1271 } else if isErr {
1272 // Else, if there was an error, don't fail and don't check isFound or the value
1273 return false
1274 } else if test.isFound != isFound {
1275 // Else, if the call didn't match the is-found expectation, fail
1276 t.Errorf("%s test '%s' isFound mismatch: expected %t, obtained %t", testKind, test.desc, test.isFound, isFound)
1277 return false
1278 } else if !isFound {
1279 // Else, if no value was found, don't fail and don't check the value
1280 return false
1281 } else {
1282 // Else, there was no error and a value was found, so check the value
1283 return true
1284 }
1285}
1286
1287// Test helper for SYS-REQ-009.
1288func runSetTests(t *testing.T, testKind string, tests []SetTest, runner func(SetTest) (interface{}, ValueType, error), resultChecker func(SetTest, interface{}) (bool, interface{})) {

Callers 1

runSetTestsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected