From f27fbdd8abac05e9e85ee1f9b5257dcb0ecfd2b0 Mon Sep 17 00:00:00 2001 From: Jim Kuhn Date: Wed, 21 Sep 2022 11:38:23 -0400 Subject: [PATCH] Fix sense of test (.analyzerinfo files get placed in wrong directory) (#4486) * Fix sense of test (.analyzerinfo files get placed in wrong directory) * Update testanalyzerinformation.cpp style (tabs -> spaces) --- lib/analyzerinfo.cpp | 2 +- test/testanalyzerinformation.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/analyzerinfo.cpp b/lib/analyzerinfo.cpp index 1cd3a4652..0140aeb37 100644 --- a/lib/analyzerinfo.cpp +++ b/lib/analyzerinfo.cpp @@ -120,7 +120,7 @@ std::string AnalyzerInformation::getAnalyzerInfoFile(const std::string &buildDir const std::string::size_type pos = sourcefile.rfind('/'); std::string filename; - if (pos != std::string::npos) + if (pos == std::string::npos) filename = sourcefile; else filename = sourcefile.substr(pos + 1); diff --git a/test/testanalyzerinformation.cpp b/test/testanalyzerinformation.cpp index 579049ee0..a440074a6 100644 --- a/test/testanalyzerinformation.cpp +++ b/test/testanalyzerinformation.cpp @@ -38,6 +38,8 @@ private: ASSERT_EQUALS("file1.a4", getAnalyzerInfoFileFromFilesTxt(f1, "file1.c", "")); std::istringstream f2(filesTxt); ASSERT_EQUALS("file1.a4", getAnalyzerInfoFileFromFilesTxt(f2, "./file1.c", "")); + ASSERT_EQUALS("builddir/file1.c.analyzerinfo", AnalyzerInformation::getAnalyzerInfoFile("builddir", "file1.c", "")); + ASSERT_EQUALS("builddir/file1.c.analyzerinfo", AnalyzerInformation::getAnalyzerInfoFile("builddir", "some/path/file1.c", "")); } };