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