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

Function TestKeywords_AggregateFunctions

pkg/sql/keywords/keywords_test.go:634–665  ·  view source on GitHub ↗

TestKeywords_AggregateFunctions tests aggregate function keywords

(t *testing.T)

Source from the content-addressed store, hash-verified

632
633// TestKeywords_AggregateFunctions tests aggregate function keywords
634func TestKeywords_AggregateFunctions(t *testing.T) {
635 k := New(DialectGeneric, true)
636
637 aggregateFunctions := []struct {
638 word string
639 expectedType models.TokenType
640 }{
641 {"COUNT", models.TokenTypeCount},
642 {"SUM", models.TokenTypeSum},
643 {"AVG", models.TokenTypeAvg},
644 {"MIN", models.TokenTypeMin},
645 {"MAX", models.TokenTypeMax},
646 }
647
648 for _, af := range aggregateFunctions {
649 // Test case variations
650 testVariations := []string{af.word, strings.ToLower(af.word)}
651 for _, word := range testVariations {
652 if !k.IsKeyword(word) {
653 t.Errorf("Aggregate function %q should be a keyword", word)
654 }
655 if !k.IsReserved(word) {
656 t.Errorf("Aggregate function %q should be reserved", word)
657 }
658
659 tokenType := k.GetTokenType(word)
660 if tokenType != af.expectedType {
661 t.Errorf("GetTokenType(%q) = %v, want %v", word, tokenType, af.expectedType)
662 }
663 }
664 }
665}
666
667// TestKeywords_CaseSensitiveMode tests case-sensitive keyword matching
668func TestKeywords_CaseSensitiveMode(t *testing.T) {

Callers

nothing calls this directly

Calls 5

IsReservedMethod · 0.80
GetTokenTypeMethod · 0.80
NewFunction · 0.70
ErrorfMethod · 0.65
IsKeywordMethod · 0.45

Tested by

no test coverage detected