(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func TestString(t *testing.T) { |
| 10 | testCases := []struct { |
| 11 | nodes []SelectorNode |
| 12 | want string |
| 13 | }{ |
| 14 | { |
| 15 | nodes: []SelectorNode{ |
| 16 | NewItemSelector("a"), |
| 17 | NewArraySelector("b", 1), |
| 18 | NewItemSelector("c"), |
| 19 | }, |
| 20 | want: "a.b[1].c", |
| 21 | }, |
| 22 | } |
| 23 | |
| 24 | a := require.New(t) |
| 25 | |
| 26 | for _, tc := range testCases { |
| 27 | if len(tc.nodes) == 0 { |
| 28 | continue |
| 29 | } |
| 30 | |
| 31 | ast := NewPathAST(tc.nodes[0]) |
| 32 | next := ast.Root |
| 33 | for i := 1; i < len(tc.nodes); i++ { |
| 34 | next.SetNext(tc.nodes[i]) |
| 35 | next = next.GetNext() |
| 36 | } |
| 37 | |
| 38 | got, err := ast.String() |
| 39 | a.NoError(err) |
| 40 | a.Equal(tc.want, got) |
| 41 | } |
| 42 | } |
nothing calls this directly
no test coverage detected