@@ -43,29 +43,38 @@ func TestFindBestLibraryWithHeader(t *testing.T) {
43
43
l3 := & types.Library {Name : "Calculus Lib Improved" }
44
44
l4 := & types.Library {Name : "Another Calculus Lib" }
45
45
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" }
47
48
48
49
// 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 })
50
51
require .Equal (t , l1 .Name , res .Name )
51
52
52
53
// 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 })
54
55
require .Equal (t , l2 .Name , res .Name )
55
56
56
57
// 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 })
58
59
require .Equal (t , l3 .Name , res .Name )
59
60
60
61
// 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 })
62
63
require .Equal (t , l4 .Name , res .Name )
63
64
64
65
// Test "contains"" matching
65
- res = findBestLibraryWithHeader ("calculus_lib.h" , []* types.Library {l6 , l5 })
66
+ res = findBestLibraryWithHeader ("calculus_lib.h" , []* types.Library {l7 , l6 , l5 })
66
67
require .Equal (t , l5 .Name , res .Name )
67
68
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
+
68
77
// 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 )
71
80
}
0 commit comments