Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test TEnum::GetEnum with using statement. #1118

Merged
merged 3 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion root/meta/enums/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ ROOTTEST_GENERATE_REFLEX_DICTIONARY(tEnumGetEnumClasses
ROOTTEST_ADD_TEST(execTEnumGetEnum
MACRO execTEnumGetEnum.C
OUTREF execTEnumGetEnum.ref
${WILLFAIL_ON_WIN32}
DEPENDS ${GENERATE_REFLEX_TEST})


Expand Down Expand Up @@ -77,3 +76,7 @@ ROOTTEST_ADD_TEST(enumSize
MACRO execenumSize.C
OUTREF execenumSize.ref
DEPENDS ${GENERATE_DICTIONARY_TEST})

ROOTTEST_ADD_TEST(testUsingEnum.cxx
MACRO test_usingenum.cxx
OUTREF test_usingenum.ref)
36 changes: 36 additions & 0 deletions root/meta/enums/test_usingenum.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
namespace A { enum E { kOne }; }
namespace B { using A::E; }
namespace C { using namespace A; }

#include <iostream>

int test_usingenum() {
auto e = TEnum::GetEnum("A::E");
if (!e) {
std::cerr << "Can not find A::E declaration\n";
return 1;
}
auto be = TEnum::GetEnum("B::E");
if (!be) {
std::cerr << "Can not find B::E\n";
return 2;
}
if (e != be) {
std::cerr << "The TEnum found for A::E and B::E is different\n";
return 3;
}
#if CLING_FIXED_15407
// This is failing due to https://github.com/root-project/root/issues/15407
auto ce = TEnum::GetEnum("C::E");
if (!ce) {
std::cerr << "Can not find C::E\n";
return 4;

}
if (e != ce) {
std::cerr << "The TEnum found for A::E and C::E is different\n";
return 5;
}
#endif
return 0;
};
3 changes: 3 additions & 0 deletions root/meta/enums/test_usingenum.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

Processing roottest/root/meta/enums/test_usingenum.cxx...
(int) 0
8 changes: 6 additions & 2 deletions root/multicore/exectsenums.C
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ void exectsenums (){
for (auto&& enName : enumNames){
auto f = [&](){
auto en = TEnum::GetEnum(enName);
names.addString(TEnum::GetEnum(enName)->GetQualifiedName());
if (en)
names.addString(TEnum::GetEnum(enName)->GetQualifiedName());
else
std::cerr << "Error: enum called " << enName << " was NOT found\n";
};
threads.emplace_back(f);
// f(); //just run serial
Expand All @@ -40,6 +43,7 @@ void exectsenums (){

std::list<std::string> namesList (names.getStrings());
namesList.sort();
for (auto&& name:namesList) printf("Enum called %s was found\n",name.c_str());
for (auto&& name:namesList)
printf("Enum called %s was found\n",name.c_str());

}