@@ -43,29 +43,38 @@ func TestFindBestLibraryWithHeader(t *testing.T) {
4343 l3 := & types.Library {Name : "Calculus Lib Improved" }
4444 l4 := & types.Library {Name : "Another Calculus Lib" }
4545 l5 := & types.Library {Name : "Yet Another Calculus Lib Improved" }
46- l6 := & types.Library {Name : "AnotherLib" }
46+ l6 := & types.Library {Name : "Calculus Unified Lib" }
47+ l7 := & types.Library {Name : "AnotherLib" }
4748
4849 // Test exact name matching
49- res := findBestLibraryWithHeader ("calculus_lib.h" , []* types.Library {l6 , l5 , l4 , l3 , l2 , l1 })
50+ res := findBestLibraryWithHeader ("calculus_lib.h" , []* types.Library {l7 , l6 , l5 , l4 , l3 , l2 , l1 })
5051 require .Equal (t , l1 .Name , res .Name )
5152
5253 // Test exact name with "-master" postfix matching
53- res = findBestLibraryWithHeader ("calculus_lib.h" , []* types.Library {l6 , l5 , l4 , l3 , l2 })
54+ res = findBestLibraryWithHeader ("calculus_lib.h" , []* types.Library {l7 , l6 , l5 , l4 , l3 , l2 })
5455 require .Equal (t , l2 .Name , res .Name )
5556
5657 // Test prefix matching
57- res = findBestLibraryWithHeader ("calculus_lib.h" , []* types.Library {l6 , l5 , l4 , l3 })
58+ res = findBestLibraryWithHeader ("calculus_lib.h" , []* types.Library {l7 , l6 , l5 , l4 , l3 })
5859 require .Equal (t , l3 .Name , res .Name )
5960
6061 // Test postfix matching
61- res = findBestLibraryWithHeader ("calculus_lib.h" , []* types.Library {l6 , l5 , l4 })
62+ res = findBestLibraryWithHeader ("calculus_lib.h" , []* types.Library {l7 , l6 , l5 , l4 })
6263 require .Equal (t , l4 .Name , res .Name )
6364
6465 // Test "contains"" matching
65- res = findBestLibraryWithHeader ("calculus_lib.h" , []* types.Library {l6 , l5 })
66+ res = findBestLibraryWithHeader ("calculus_lib.h" , []* types.Library {l7 , l6 , l5 })
6667 require .Equal (t , l5 .Name , res .Name )
6768
69+ // Test lexicographic similarity matching
70+ res = findBestLibraryWithHeader ("calculus_lib.h" , []* types.Library {l7 , l6 })
71+ require .Equal (t , l6 .Name , res .Name )
72+
73+ // Test lexicographic similarity matching (2)
74+ res = findBestLibraryWithHeader ("calculus_lib.h" , []* types.Library {l6 , l7 })
75+ require .Equal (t , l6 .Name , res .Name )
76+
6877 // Test none matching
69- res = findBestLibraryWithHeader ("calculus_lib.h" , []* types.Library {l6 })
70- require .Nil (t , res )
78+ res = findBestLibraryWithHeader ("calculus_lib.h" , []* types.Library {l7 })
79+ require .Equal (t , l7 . Name , res . Name )
7180}
0 commit comments