MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / TestNewWithKeywords

Function TestNewWithKeywords

pkg/sql/tokenizer/tokenizer_coverage_test.go:602–632  ·  view source on GitHub ↗

TestNewWithKeywords tests the NewWithKeywords constructor

(t *testing.T)

Source from the content-addressed store, hash-verified

600
601// TestNewWithKeywords tests the NewWithKeywords constructor
602func 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
635func TestSetLogger(t *testing.T) {

Callers

nothing calls this directly

Calls 5

NewKeywordsFunction · 0.92
NewWithKeywordsFunction · 0.85
TokenizeMethod · 0.80
ErrorfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected