(t *testing.T)
| 102 | } |
| 103 | |
| 104 | func TestGetStatementRanges(t *testing.T) { |
| 105 | testCases := []struct { |
| 106 | description string |
| 107 | statement string |
| 108 | wantRanges int |
| 109 | }{ |
| 110 | { |
| 111 | description: "single statement", |
| 112 | statement: `db.collection.find({})`, |
| 113 | wantRanges: 1, |
| 114 | }, |
| 115 | { |
| 116 | description: "multiple statements on separate lines", |
| 117 | statement: "db.users.find({});\ndb.products.find({})", |
| 118 | wantRanges: 2, |
| 119 | }, |
| 120 | { |
| 121 | description: "multiline statement", |
| 122 | statement: `db.users.aggregate([ |
| 123 | { $match: { status: "A" } }, |
| 124 | { $group: { _id: "$cust_id" } } |
| 125 | ])`, |
| 126 | wantRanges: 1, |
| 127 | }, |
| 128 | { |
| 129 | description: "empty input", |
| 130 | statement: "", |
| 131 | wantRanges: 0, |
| 132 | }, |
| 133 | } |
| 134 | |
| 135 | for _, tc := range testCases { |
| 136 | t.Run(tc.description, func(t *testing.T) { |
| 137 | ranges, err := GetStatementRanges(context.Background(), base.StatementRangeContext{}, tc.statement) |
| 138 | require.NoError(t, err) |
| 139 | require.Len(t, ranges, tc.wantRanges) |
| 140 | }) |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | func TestGetStatementRangesWithHindiCharacters(t *testing.T) { |
| 145 | // Test with Hindi characters - ANTLR returns character (rune) offsets, not byte offsets |
nothing calls this directly
no test coverage detected