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

Function runGetTests

parser_test.go:1217–1244  ·  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

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{})) {
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.
1247func 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…