1 //===- TypeNameTest.cpp ---------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "llvm/Support/TypeName.h"
10 #include "llvm/Support/raw_ostream.h"
11 #include "gtest/gtest.h"
22 TEST(TypeNameTest
, Names
) {
25 StringRef S1Name
= getTypeName
<N1::S1
>();
26 StringRef C1Name
= getTypeName
<N1::C1
>();
27 StringRef U1Name
= getTypeName
<N1::U1
>();
28 StringRef S2Name
= getTypeName
<S2
>();
30 #if defined(__clang__) || defined(__GNUC__) || defined(__INTEL_COMPILER) || \
32 EXPECT_TRUE(S1Name
.ends_with("::N1::S1")) << S1Name
.str();
33 EXPECT_TRUE(C1Name
.ends_with("::N1::C1")) << C1Name
.str();
34 EXPECT_TRUE(U1Name
.ends_with("::N1::U1")) << U1Name
.str();
36 EXPECT_TRUE(S2Name
.ends_with("S2")) << S2Name
.str();
38 EXPECT_TRUE(S2Name
.ends_with("::S2")) << S2Name
.str();
41 EXPECT_EQ("UNKNOWN_TYPE", S1Name
);
42 EXPECT_EQ("UNKNOWN_TYPE", C1Name
);
43 EXPECT_EQ("UNKNOWN_TYPE", U1Name
);
44 EXPECT_EQ("UNKNOWN_TYPE", S2Name
);
48 } // end anonymous namespace