[Lldb-commits] [lldb] r331966 - CPlusPlusLanguage: Add unit tests for the FindAlternateFunctionManglings method
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Thu May 10 01:59:17 PDT 2018
Author: labath
Date: Thu May 10 01:59:17 2018
New Revision: 331966
URL: http://llvm.org/viewvc/llvm-project?rev=331966&view=rev
Log:
CPlusPlusLanguage: Add unit tests for the FindAlternateFunctionManglings method
I was considering modifying this function, so I wrote some tests to make
sure I don't regress its behavior. I am not sure if I will actually
proceed with the modifications, but the tests seem useful nonetheless.
Modified:
lldb/trunk/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
Modified: lldb/trunk/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp?rev=331966&r1=331965&r2=331966&view=diff
==============================================================================
--- lldb/trunk/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp (original)
+++ lldb/trunk/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp Thu May 10 01:59:17 2018
@@ -6,9 +6,9 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#include "gtest/gtest.h"
-
#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
using namespace lldb_private;
@@ -163,3 +163,24 @@ TEST(CPlusPlusLanguage, ExtractContextAn
EXPECT_FALSE(CPlusPlusLanguage::ExtractContextAndIdentifier(
"f<A<B><C>>", context, basename));
}
+
+static std::set<std::string> FindAlternate(llvm::StringRef Name) {
+ std::set<ConstString> Results;
+ uint32_t Count = CPlusPlusLanguage::FindAlternateFunctionManglings(
+ ConstString(Name), Results);
+ EXPECT_EQ(Count, Results.size());
+ std::set<std::string> Strings;
+ for (ConstString Str : Results)
+ Strings.insert(Str.GetStringRef());
+ return Strings;
+}
+
+TEST(CPlusPlusLanguage, FindAlternateFunctionManglings) {
+ using namespace testing;
+
+ EXPECT_THAT(FindAlternate("_ZN1A1fEv"),
+ UnorderedElementsAre("_ZNK1A1fEv", "_ZLN1A1fEv"));
+ EXPECT_THAT(FindAlternate("_ZN1A1fEa"), Contains("_ZN1A1fEc"));
+ EXPECT_THAT(FindAlternate("_ZN1A1fEx"), Contains("_ZN1A1fEl"));
+ EXPECT_THAT(FindAlternate("_ZN1A1fEy"), Contains("_ZN1A1fEm"));
+}
More information about the lldb-commits
mailing list