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. llvm-svn: 331966
This commit is contained in:
parent
93dd5dcdf7
commit
4865ff1e18
|
@ -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, ExtractContextAndIdentifier) {
|
|||
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"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue