Test helper for SYS-REQ-001, SYS-REQ-002, SYS-REQ-003, SYS-REQ-004, SYS-REQ-005, and SYS-REQ-011.
(t *testing.T, testKind string, tests []GetTest, runner func(GetTest) (interface{}, ValueType, error), resultChecker func(GetTest, interface{}) (bool, interface{}))
| 1232 | |
| 1233 | // Test helper for SYS-REQ-001, SYS-REQ-002, SYS-REQ-003, SYS-REQ-004, SYS-REQ-005, and SYS-REQ-011. |
| 1234 | func runGetTests(t *testing.T, testKind string, tests []GetTest, runner func(GetTest) (interface{}, ValueType, error), resultChecker func(GetTest, interface{}) (bool, interface{})) { |
| 1235 | for _, test := range tests { |
| 1236 | if activeTest != "" && test.desc != activeTest { |
| 1237 | continue |
| 1238 | } |
| 1239 | |
| 1240 | fmt.Println("Running:", test.desc) |
| 1241 | |
| 1242 | value, dataType, err := runner(test) |
| 1243 | |
| 1244 | if getTestCheckFoundAndNoError(t, testKind, test, dataType, value, err) { |
| 1245 | if test.data == nil { |
| 1246 | t.Errorf("MALFORMED TEST: %v", test) |
| 1247 | continue |
| 1248 | } |
| 1249 | |
| 1250 | if ok, expected := resultChecker(test, value); !ok { |
| 1251 | if expectedBytes, ok := expected.([]byte); ok { |
| 1252 | expected = string(expectedBytes) |
| 1253 | } |
| 1254 | if valueBytes, ok := value.([]byte); ok { |
| 1255 | value = string(valueBytes) |
| 1256 | } |
| 1257 | t.Errorf("%s test '%s' expected to return value %v, but did returned %v instead", testKind, test.desc, expected, value) |
| 1258 | } |
| 1259 | } |
| 1260 | } |
| 1261 | } |
| 1262 | |
| 1263 | // Test helper for SYS-REQ-009. |
| 1264 | func setTestCheckFoundAndNoError(t *testing.T, testKind string, test SetTest, value interface{}, err error) bool { |
no test coverage detected