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

Function getTestCheckFoundAndNoError

parser_test.go:1192–1214  ·  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

1190// Returns true the test should proceed to checking the actual data returned from Get*(), or false if the test is finished.
1191// Test helper for SYS-REQ-001, SYS-REQ-002, SYS-REQ-003, SYS-REQ-004, SYS-REQ-005, and SYS-REQ-011.
1192func getTestCheckFoundAndNoError(t *testing.T, testKind string, test GetTest, jtype ValueType, value interface{}, err error) bool {
1193 isFound := (err != KeyPathNotFoundError)
1194 isErr := (err != nil && err != KeyPathNotFoundError)
1195
1196 if test.isErr != isErr {
1197 // If the call didn't match the error expectation, fail
1198 t.Errorf("%s test '%s' isErr mismatch: expected %t, obtained %t (err %v). Value: %v", testKind, test.desc, test.isErr, isErr, err, value)
1199 return false
1200 } else if isErr {
1201 // Else, if there was an error, don't fail and don't check isFound or the value
1202 return false
1203 } else if test.isFound != isFound {
1204 // Else, if the call didn't match the is-found expectation, fail
1205 t.Errorf("%s test '%s' isFound mismatch: expected %t, obtained %t", testKind, test.desc, test.isFound, isFound)
1206 return false
1207 } else if !isFound {
1208 // Else, if no value was found, don't fail and don't check the value
1209 return false
1210 } else {
1211 // Else, there was no error and a value was found, so check the value
1212 return true
1213 }
1214}
1215
1216// Test helper for SYS-REQ-001, SYS-REQ-002, SYS-REQ-003, SYS-REQ-004, SYS-REQ-005, and SYS-REQ-011.
1217func 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…