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

Function runGetTests

parser_test.go:1233–1260  ·  view source on GitHub ↗

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{}))

Source from the content-addressed store, hash-verified

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

Callers 7

TestGetFunction · 0.85
TestGetStringFunction · 0.85
TestGetUnsafeStringFunction · 0.85
TestGetIntFunction · 0.85
TestGetFloatFunction · 0.85
TestGetBooleanFunction · 0.85
TestGetSliceFunction · 0.85

Calls 1

Tested by

no test coverage detected