TestParser_DisplayAST_Table tests table output format
(t *testing.T)
| 168 | |
| 169 | // TestParser_DisplayAST_Table tests table output format |
| 170 | func TestParser_DisplayAST_Table(t *testing.T) { |
| 171 | var outBuf, errBuf bytes.Buffer |
| 172 | parser := NewParser(&outBuf, &errBuf, CLIParserOptions{ |
| 173 | Format: "table", |
| 174 | }) |
| 175 | |
| 176 | result, err := parser.Parse("SELECT * FROM users") |
| 177 | if err != nil { |
| 178 | t.Fatalf("Unexpected error: %v", err) |
| 179 | } |
| 180 | defer ast.ReleaseAST(result.AST) |
| 181 | |
| 182 | err = parser.Display(result) |
| 183 | if err != nil { |
| 184 | t.Fatalf("Failed to display: %v", err) |
| 185 | } |
| 186 | |
| 187 | output := outBuf.String() |
| 188 | if output == "" { |
| 189 | t.Error("Expected table output but got empty string") |
| 190 | } |
| 191 | |
| 192 | // Check for expected table elements |
| 193 | expectedElements := []string{ |
| 194 | "AST Structure", |
| 195 | "Statements", |
| 196 | } |
| 197 | |
| 198 | for _, elem := range expectedElements { |
| 199 | if !strings.Contains(output, elem) { |
| 200 | t.Errorf("Expected output to contain '%s', but it doesn't", elem) |
| 201 | } |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | // TestParser_DisplayTokens tests token display |
| 206 | func TestParser_DisplayTokens(t *testing.T) { |