@@ -12,51 +12,14 @@ using namespace TestUtils;
1212using namespace llvm ;
1313using namespace clang ;
1414
15- TEST (ScopeReflectionTest, IsEnumScope) {
16- std::vector<Decl *> Decls, SubDecls;
17- std::string code = R"(
18- enum Switch {
19- OFF,
20- ON
21- };
22-
23- Switch s = Switch::OFF;
24-
25- int i = Switch::ON;
26- )" ;
27-
28- GetAllTopLevelDecls (code, Decls);
29- GetAllSubDecls (Decls[0 ], SubDecls);
30- EXPECT_TRUE (Cpp::IsEnumScope (Decls[0 ]));
31- EXPECT_FALSE (Cpp::IsEnumScope (Decls[1 ]));
32- EXPECT_FALSE (Cpp::IsEnumScope (Decls[2 ]));
33- EXPECT_FALSE (Cpp::IsEnumScope (SubDecls[0 ]));
34- EXPECT_FALSE (Cpp::IsEnumScope (SubDecls[1 ]));
35- }
36-
37- TEST (ScopeReflectionTest, IsEnumConstant) {
38- std::vector<Decl *> Decls, SubDecls;
39- std::string code = R"(
40- enum Switch {
41- OFF,
42- ON
43- };
44-
45- Switch s = Switch::OFF;
46-
47- int i = Switch::ON;
48- )" ;
49-
50- GetAllTopLevelDecls (code, Decls);
51- GetAllSubDecls (Decls[0 ], SubDecls);
52- EXPECT_FALSE (Cpp::IsEnumConstant (Decls[0 ]));
53- EXPECT_FALSE (Cpp::IsEnumConstant (Decls[1 ]));
54- EXPECT_FALSE (Cpp::IsEnumConstant (Decls[2 ]));
55- EXPECT_TRUE (Cpp::IsEnumConstant (SubDecls[0 ]));
56- EXPECT_TRUE (Cpp::IsEnumConstant (SubDecls[1 ]));
57- }
58-
59- TEST (EnumReflectionTest, IsEnumType) {
15+ class EnumReflectionTest : public ::testing::TestWithParam<TestUtils::TestConfig> {
16+ protected:
17+ void SetUp () override {
18+ TestUtils::current_config = GetParam ();
19+ }
20+ };
21+
22+ TEST_P (EnumReflectionTest, IsEnumType) {
6023 std::vector<Decl *> Decls;
6124 std::string code = R"(
6225 enum class E {
@@ -84,7 +47,7 @@ TEST(EnumReflectionTest, IsEnumType) {
8447 EXPECT_TRUE (Cpp::IsEnumType (Cpp::GetVariableType (Decls[5 ])));
8548}
8649
87- TEST (EnumReflectionTest, GetIntegerTypeFromEnumScope) {
50+ TEST_P (EnumReflectionTest, GetIntegerTypeFromEnumScope) {
8851 std::vector<Decl *> Decls;
8952 std::string code = R"(
9053 enum Switch : bool {
@@ -134,7 +97,7 @@ TEST(EnumReflectionTest, GetIntegerTypeFromEnumScope) {
13497 EXPECT_EQ (Cpp::GetTypeAsString (Cpp::GetIntegerTypeFromEnumScope (Decls[5 ]))," NULL TYPE" );
13598}
13699
137- TEST (EnumReflectionTest, GetIntegerTypeFromEnumType) {
100+ TEST_P (EnumReflectionTest, GetIntegerTypeFromEnumType) {
138101 std::vector<Decl *> Decls;
139102 std::string code = R"(
140103 enum Switch : bool {
@@ -194,7 +157,7 @@ TEST(EnumReflectionTest, GetIntegerTypeFromEnumType) {
194157 EXPECT_EQ (get_int_type_from_enum_var (Decls[11 ]), " NULL TYPE" ); // When a non Enum Type variable is used
195158}
196159
197- TEST (EnumReflectionTest, GetEnumConstants) {
160+ TEST_P (EnumReflectionTest, GetEnumConstants) {
198161 std::vector<Decl *> Decls;
199162 std::string code = R"(
200163 enum ZeroEnum {
@@ -238,7 +201,7 @@ TEST(EnumReflectionTest, GetEnumConstants) {
238201 EXPECT_EQ (Cpp::GetEnumConstants (Decls[5 ]).size (), 0 );
239202}
240203
241- TEST (EnumReflectionTest, GetEnumConstantType) {
204+ TEST_P (EnumReflectionTest, GetEnumConstantType) {
242205 std::vector<Decl *> Decls;
243206 std::string code = R"(
244207 enum Enum0 {
@@ -269,7 +232,7 @@ TEST(EnumReflectionTest, GetEnumConstantType) {
269232 EXPECT_EQ (get_enum_constant_type_as_str (nullptr ), " NULL TYPE" );
270233}
271234
272- TEST (EnumReflectionTest, GetEnumConstantValue) {
235+ TEST_P (EnumReflectionTest, GetEnumConstantValue) {
273236 std::vector<Decl *> Decls;
274237 std::string code = R"(
275238 enum Counter {
@@ -297,7 +260,7 @@ TEST(EnumReflectionTest, GetEnumConstantValue) {
297260 EXPECT_EQ (Cpp::GetEnumConstantValue (Decls[1 ]), 0 ); // Checking value of non enum constant
298261}
299262
300- TEST (EnumReflectionTest, GetEnums) {
263+ TEST_P (EnumReflectionTest, GetEnums) {
301264 std::string code = R"(
302265 enum Color {
303266 Red,
@@ -359,3 +322,26 @@ TEST(EnumReflectionTest, GetEnums) {
359322 EXPECT_TRUE (std::find (enumNames3.begin (), enumNames3.end (), " Color" ) != enumNames3.end ());
360323 EXPECT_TRUE (enumNames4.empty ());
361324}
325+
326+ #ifdef LLVM_BUILT_WITH_OOP_JIT
327+ INSTANTIATE_TEST_SUITE_P (
328+ AllJITModes,
329+ EnumReflectionTest,
330+ ::testing::Values (
331+ TestUtils::TestConfig{false , " InProcessJIT" },
332+ TestUtils::TestConfig{true , " OutOfProcessJIT" }
333+ ),
334+ [](const ::testing::TestParamInfo<TestUtils::TestConfig>& info) {
335+ return info.param .name ;
336+ }
337+ );
338+ #else
339+ INSTANTIATE_TEST_SUITE_P (
340+ AllJITModes,
341+ EnumReflectionTest,
342+ ::testing::Values (TestUtils::TestConfig{false , " InProcessJIT" }),
343+ [](const ::testing::TestParamInfo<TestUtils::TestConfig>& info) {
344+ return info.param .name ;
345+ }
346+ );
347+ #endif
0 commit comments