xref: /llvm-project/llvm/unittests/Demangle/DLangDemangleTest.cpp (revision 22a1aa5a43cbdaf9dde014ba1f120e0f7ca1788b)
1 //===------------------ DLangDemangleTest.cpp -----------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "llvm/Demangle/Demangle.h"
10 #include "gmock/gmock.h"
11 #include "gtest/gtest.h"
12 
13 #include <cstdlib>
14 #include <utility>
15 
16 struct DLangDemangleTestFixture
17     : public testing::TestWithParam<std::pair<const char *, const char *>> {
18   char *Demangled;
19 
20   void SetUp() override { Demangled = llvm::dlangDemangle(GetParam().first); }
21 
22   void TearDown() override { std::free(Demangled); }
23 };
24 
25 TEST_P(DLangDemangleTestFixture, DLangDemangleTest) {
26   EXPECT_STREQ(Demangled, GetParam().second);
27 }
28 
29 INSTANTIATE_TEST_SUITE_P(DLangDemangleTest, DLangDemangleTestFixture,
30                          testing::Values(std::make_pair("_Dmain", "D main"),
31                                          std::make_pair(nullptr, nullptr),
32                                          std::make_pair("_Z", nullptr),
33                                          std::make_pair("_DDD", nullptr)));
34