Fix up the recursive descent

Again I guess?
This commit is contained in:
2025-03-25 15:17:55 +01:00
parent d904f8ec13
commit 08d5d707d0
2 changed files with 31 additions and 5 deletions

View File

@@ -5,7 +5,7 @@ import (
"testing"
)
var testData = map[string]interface{}{
var testData = map[string]interface{}{
"store": map[string]interface{}{
"book": []interface{}{
map[string]interface{}{
@@ -70,7 +70,7 @@ func TestParser(t *testing.T) {
wantErr: true,
},
{
path: "$.store.book[abc]",
path: "$.store.book[abc]",
wantErr: true,
},
}
@@ -125,7 +125,7 @@ func TestEvaluator(t *testing.T) {
name: "wildcard_recursive",
path: "$..*",
expected: []interface{}{
testData["store"], // Root element
// testData["store"], // Root element
// Store children
testData["store"].(map[string]interface{})["book"],
testData["store"].(map[string]interface{})["bicycle"],
@@ -164,7 +164,7 @@ func TestEvaluator(t *testing.T) {
}
result := EvaluateJSONPath(testData, steps)
// Special handling for wildcard recursive test
if tt.name == "wildcard_recursive" {
if len(result) != len(tt.expected) {
@@ -221,4 +221,4 @@ func TestEdgeCases(t *testing.T) {
t.Errorf("Expected 'answer', got %v", result)
}
})
}
}