@@ -445,6 +445,111 @@ func TestFilter_FuzzyPrefersWordBoundaryMatches(t *testing.T) {
445445 }
446446}
447447
448+ func TestFilter_MatchesNorwegianCharacters (t * testing.T ) {
449+ projects := []Project {
450+ {Name : "øl-project" , Path : "/repos/øl-project" },
451+ {Name : "særen" , Path : "/repos/særen" },
452+ {Name : "håland" , Path : "/repos/håland" },
453+ }
454+
455+ result := Filter (projects , "øl" )
456+ if len (result ) != 1 {
457+ t .Errorf ("expected 1 match for 'øl', got %d" , len (result ))
458+ }
459+ if result [0 ].Name != "øl-project" {
460+ t .Errorf ("expected 'øl-project', got %q" , result [0 ].Name )
461+ }
462+
463+ result = Filter (projects , "sæ" )
464+ if len (result ) != 1 {
465+ t .Errorf ("expected 1 match for 'sæ', got %d" , len (result ))
466+ }
467+ if result [0 ].Name != "særen" {
468+ t .Errorf ("expected 'særen', got %q" , result [0 ].Name )
469+ }
470+
471+ result = Filter (projects , "hå" )
472+ if len (result ) != 1 {
473+ t .Errorf ("expected 1 match for 'hå', got %d" , len (result ))
474+ }
475+ if result [0 ].Name != "håland" {
476+ t .Errorf ("expected 'håland', got %q" , result [0 ].Name )
477+ }
478+ }
479+
480+ func TestFilter_NorwegianCaseInsensitive (t * testing.T ) {
481+ projects := []Project {
482+ {Name : "ØL-PROJECT" , Path : "/repos/ØL-PROJECT" },
483+ {Name : "SÆREN" , Path : "/repos/SÆREN" },
484+ {Name : "HÅLAND" , Path : "/repos/HÅLAND" },
485+ }
486+
487+ tests := []struct {
488+ query string
489+ expect string
490+ }{
491+ {"øl" , "ØL-PROJECT" },
492+ {"øL" , "ØL-PROJECT" },
493+ {"ØL" , "ØL-PROJECT" },
494+ {"sæ" , "SÆREN" },
495+ {"SÆ" , "SÆREN" },
496+ {"hå" , "HÅLAND" },
497+ {"HÅ" , "HÅLAND" },
498+ }
499+
500+ for _ , tt := range tests {
501+ result := Filter (projects , tt .query )
502+ if len (result ) != 1 {
503+ t .Errorf ("query %q: expected 1 match, got %d" , tt .query , len (result ))
504+ continue
505+ }
506+ if result [0 ].Name != tt .expect {
507+ t .Errorf ("query %q: expected %q, got %q" , tt .query , tt .expect , result [0 ].Name )
508+ }
509+ }
510+ }
511+
512+ func TestFilter_NorwegianFuzzyMatching (t * testing.T ) {
513+ projects := []Project {
514+ {Name : "første-prosjekt" , Path : "/repos/første-prosjekt" },
515+ {Name : "anden-prosjekt" , Path : "/repos/anden-prosjekt" },
516+ }
517+
518+ // "fp" should match "første-prosjekt"
519+ result := Filter (projects , "fp" )
520+ if len (result ) != 1 {
521+ t .Errorf ("expected 1 match for 'fp', got %d" , len (result ))
522+ }
523+ if result [0 ].Name != "første-prosjekt" {
524+ t .Errorf ("expected 'første-prosjekt', got %q" , result [0 ].Name )
525+ }
526+
527+ // "ap" should match "anden-prosjekt"
528+ result = Filter (projects , "ap" )
529+ if len (result ) != 1 {
530+ t .Errorf ("expected 1 match for 'ap', got %d" , len (result ))
531+ }
532+ if result [0 ].Name != "anden-prosjekt" {
533+ t .Errorf ("expected 'anden-prosjekt', got %q" , result [0 ].Name )
534+ }
535+ }
536+
537+ func TestFilter_NorwegianWordBoundary (t * testing.T ) {
538+ projects := []Project {
539+ {Name : "xølx" , Path : "/repos/xølx" },
540+ {Name : "øl-project" , Path : "/repos/øl-project" },
541+ }
542+
543+ // "øl" at start should rank higher
544+ result := Filter (projects , "øl" )
545+ if len (result ) != 2 {
546+ t .Fatalf ("expected 2 matches, got %d" , len (result ))
547+ }
548+ if result [0 ].Name != "øl-project" {
549+ t .Errorf ("expected 'øl-project' first (word boundary), got %q" , result [0 ].Name )
550+ }
551+ }
552+
448553func TestScore_ScoreIsNonNegative (t * testing.T ) {
449554 properties := gopter .NewProperties (nil )
450555
0 commit comments