MCPcopy
hub / github.com/kubernetes/client-go / TestParser

Function TestParser

util/jsonpath/parser_test.go:106–129  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

104}
105
106func TestParser(t *testing.T) {
107 for _, test := range parserTests {
108 parser, err := Parse(test.name, test.text)
109 if test.shouldError {
110 if err == nil {
111 t.Errorf("unexpected non-error when parsing %s", test.name)
112 }
113 continue
114 }
115 if err != nil {
116 t.Errorf("parse %s error %v", test.name, err)
117 }
118 result := collectNode([]Node{}, parser.Root)[1:]
119 if len(result) != len(test.nodes) {
120 t.Errorf("in %s, expect to get %d nodes, got %d nodes", test.name, len(test.nodes), len(result))
121 t.Error(result)
122 }
123 for i, expect := range test.nodes {
124 if result[i].String() != expect.String() {
125 t.Errorf("in %s, %dth node, expect %v, got %v", test.name, i, expect, result[i])
126 }
127 }
128 }
129}
130
131type failParserTest struct {
132 name string

Callers

nothing calls this directly

Calls 5

ParseFunction · 0.85
collectNodeFunction · 0.85
ErrorfMethod · 0.65
ErrorMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected