Changed match func strategy; added tests
As it turns out, closures are very hard to validate without running them. Since table-driven tests tend to rely on value types that can be compared directly, using structs that adhere to a generic callback interface is more work, but is more easily tested. * Changed jsonpath match functions to structs with Call() methods * Added tests to verify the generation of jsonpath QueryPath data * Added tests to verify jsonpath lexer * Fixed jsonpath whitespace handling bug * Fixed numerous flaws in jsonpath parser
This commit is contained in:
@@ -29,9 +29,14 @@ func assertValue(t *testing.T, result, ref interface{}, location string) {
|
||||
t.Errorf("{%s} result value not of type %T: %T",
|
||||
location, node, resultNode)
|
||||
} else {
|
||||
for i, v := range node {
|
||||
assertValue(t, resultNode[i], v, fmt.Sprintf("%s[%d]", location, i))
|
||||
}
|
||||
if len(node) != len(resultNode) {
|
||||
t.Errorf("{%s} lengths do not match: %v vs %v",
|
||||
location, node, resultNode)
|
||||
} else {
|
||||
for i, v := range node {
|
||||
assertValue(t, resultNode[i], v, fmt.Sprintf("%s[%d]", location, i))
|
||||
}
|
||||
}
|
||||
}
|
||||
case map[string]interface{}:
|
||||
if resultNode, ok := result.(*TomlTree); !ok {
|
||||
|
||||
Reference in New Issue
Block a user