@@ -53,6 +53,41 @@ class TestAnalyzerInformation : public TestFixture {
5353 ASSERT_EQUALS (" file1.a4" , AnalyzerInformationTest::getAnalyzerInfoFileFromFilesTxt (f, " file1.c" , " " , 0 ));
5454 f.str (filesTxt);
5555 ASSERT_EQUALS (" file1.a4" , AnalyzerInformationTest::getAnalyzerInfoFileFromFilesTxt (f, " ./file1.c" , " " , 0 ));
56+
57+ // an exact match wins over a suffix match - "executor.cpp" is a suffix of
58+ // "processexecutor.cpp" so both used to resolve to the same analyzer info file
59+ {
60+ constexpr char suffixTxt[] = " executor.a1:::executor.cpp\n "
61+ " processexecutor.a2:::processexecutor.cpp\n " ;
62+ std::istringstream f1 (suffixTxt);
63+ ASSERT_EQUALS (" executor.a1" , AnalyzerInformationTest::getAnalyzerInfoFileFromFilesTxt (f1, " executor.cpp" , " " , 0 ));
64+ std::istringstream f2 (suffixTxt);
65+ ASSERT_EQUALS (" processexecutor.a2" , AnalyzerInformationTest::getAnalyzerInfoFileFromFilesTxt (f2, " processexecutor.cpp" , " " , 0 ));
66+ }
67+
68+ // the same, with the exact match on the first line
69+ {
70+ constexpr char suffixTxt[] = " processexecutor.a1:::processexecutor.cpp\n "
71+ " executor.a2:::executor.cpp\n " ;
72+ std::istringstream f1 (suffixTxt);
73+ ASSERT_EQUALS (" processexecutor.a1" , AnalyzerInformationTest::getAnalyzerInfoFileFromFilesTxt (f1, " processexecutor.cpp" , " " , 0 ));
74+ std::istringstream f2 (suffixTxt);
75+ ASSERT_EQUALS (" executor.a2" , AnalyzerInformationTest::getAnalyzerInfoFileFromFilesTxt (f2, " executor.cpp" , " " , 0 ));
76+ }
77+
78+ // a suffix match is still used when there is no exact match
79+ {
80+ constexpr char relTxt[] = " a.a1:::src/a.c\n " ;
81+ std::istringstream f1 (relTxt);
82+ ASSERT_EQUALS (" a.a1" , AnalyzerInformationTest::getAnalyzerInfoFileFromFilesTxt (f1, " /home/proj/src/a.c" , " " , 0 ));
83+ }
84+
85+ // no match at all
86+ {
87+ constexpr char noneTxt[] = " a.a1:::a.c\n " ;
88+ std::istringstream f1 (noneTxt);
89+ ASSERT_EQUALS (" " , AnalyzerInformationTest::getAnalyzerInfoFileFromFilesTxt (f1, " b.c" , " " , 0 ));
90+ }
5691 }
5792
5893 void getAnalyzerInfoFile () const {
0 commit comments