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

Function getTestCheckFoundAndNoError

parser_test.go:1209–1231  ·  view source on GitHub ↗

checkFoundAndNoError checks the dataType and error return from Get*() against the test case expectations. Returns true the test should proceed to checking the actual data returned from Get*(), or false if the test is finished. Test helper for SYS-REQ-001, SYS-REQ-002, SYS-REQ-003, SYS-REQ-004, SYS-R

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

Source from the content-addressed store, hash-verified

1207// Returns true the test should proceed to checking the actual data returned from Get*(), or false if the test is finished.
1208// Test helper for SYS-REQ-001, SYS-REQ-002, SYS-REQ-003, SYS-REQ-004, SYS-REQ-005, and SYS-REQ-011.
1209func getTestCheckFoundAndNoError(t *testing.T, testKind string, test GetTest, jtype ValueType, value interface{}, err error) bool {
1210 isFound := (err != KeyPathNotFoundError)
1211 isErr := (err != nil && err != KeyPathNotFoundError)
1212
1213 if test.isErr != isErr {
1214 // If the call didn't match the error expectation, fail
1215 t.Errorf("%s test '%s' isErr mismatch: expected %t, obtained %t (err %v). Value: %v", testKind, test.desc, test.isErr, isErr, err, value)
1216 return false
1217 } else if isErr {
1218 // Else, if there was an error, don't fail and don't check isFound or the value
1219 return false
1220 } else if test.isFound != isFound {
1221 // Else, if the call didn't match the is-found expectation, fail
1222 t.Errorf("%s test '%s' isFound mismatch: expected %t, obtained %t", testKind, test.desc, test.isFound, isFound)
1223 return false
1224 } else if !isFound {
1225 // Else, if no value was found, don't fail and don't check the value
1226 return false
1227 } else {
1228 // Else, there was no error and a value was found, so check the value
1229 return true
1230 }
1231}
1232
1233// Test helper for SYS-REQ-001, SYS-REQ-002, SYS-REQ-003, SYS-REQ-004, SYS-REQ-005, and SYS-REQ-011.
1234func runGetTests(t *testing.T, testKind string, tests []GetTest, runner func(GetTest) (interface{}, ValueType, error), resultChecker func(GetTest, interface{}) (bool, interface{})) {

Callers 1

runGetTestsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected