TestNewWithKeywords tests the NewWithKeywords constructor
(t *testing.T)
| 600 | |
| 601 | // TestNewWithKeywords tests the NewWithKeywords constructor |
| 602 | func TestNewWithKeywords(t *testing.T) { |
| 603 | // Create custom keyword set |
| 604 | customKeywords := keywords.NewKeywords() |
| 605 | |
| 606 | // Create tokenizer with custom keywords |
| 607 | tkz, err := NewWithKeywords(customKeywords) |
| 608 | if err != nil { |
| 609 | t.Errorf("Unexpected error: %v", err) |
| 610 | return |
| 611 | } |
| 612 | if tkz == nil { |
| 613 | t.Error("Expected tokenizer, got nil") |
| 614 | return |
| 615 | } |
| 616 | |
| 617 | // Test that it can tokenize |
| 618 | input := "SELECT * FROM users" |
| 619 | tokens, err := tkz.Tokenize([]byte(input)) |
| 620 | if err != nil { |
| 621 | t.Errorf("Unexpected error: %v", err) |
| 622 | } |
| 623 | |
| 624 | if len(tokens) == 0 { |
| 625 | t.Error("Expected tokens, got empty result") |
| 626 | } |
| 627 | |
| 628 | // Verify SELECT is recognized (keyword or specific SELECT token type) |
| 629 | if tokens[0].Token.Value != "SELECT" { |
| 630 | t.Errorf("Expected first token to be SELECT, got %v", tokens[0].Token.Value) |
| 631 | } |
| 632 | } |
| 633 | |
| 634 | // TestSetLogger tests the slog-based logger functionality |
| 635 | func TestSetLogger(t *testing.T) { |
nothing calls this directly
no test coverage detected