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{}))
| 1215 | |
| 1216 | // Test helper for SYS-REQ-001, SYS-REQ-002, SYS-REQ-003, SYS-REQ-004, SYS-REQ-005, and SYS-REQ-011. |
| 1217 | func runGetTests(t *testing.T, testKind string, tests []GetTest, runner func(GetTest) (interface{}, ValueType, error), resultChecker func(GetTest, interface{}) (bool, interface{})) { |
| 1218 | for _, test := range tests { |
| 1219 | if activeTest != "" && test.desc != activeTest { |
| 1220 | continue |
| 1221 | } |
| 1222 | |
| 1223 | fmt.Println("Running:", test.desc) |
| 1224 | |
| 1225 | value, dataType, err := runner(test) |
| 1226 | |
| 1227 | if getTestCheckFoundAndNoError(t, testKind, test, dataType, value, err) { |
| 1228 | if test.data == nil { |
| 1229 | t.Errorf("MALFORMED TEST: %v", test) |
| 1230 | continue |
| 1231 | } |
| 1232 | |
| 1233 | if ok, expected := resultChecker(test, value); !ok { |
| 1234 | if expectedBytes, ok := expected.([]byte); ok { |
| 1235 | expected = string(expectedBytes) |
| 1236 | } |
| 1237 | if valueBytes, ok := value.([]byte); ok { |
| 1238 | value = string(valueBytes) |
| 1239 | } |
| 1240 | t.Errorf("%s test '%s' expected to return value %v, but did returned %v instead", testKind, test.desc, expected, value) |
| 1241 | } |
| 1242 | } |
| 1243 | } |
| 1244 | } |
| 1245 | |
| 1246 | // Test helper for SYS-REQ-009. |
| 1247 | func setTestCheckFoundAndNoError(t *testing.T, testKind string, test SetTest, value interface{}, err error) bool { |
no test coverage detected
searching dependent graphs…