Belle II Software  release-05-01-25
make_root_compatible.cc
1 #include <framework/utilities/TestHelpers.h>
2 #include <framework/utilities/MakeROOTCompatible.h>
3 
4 #include <gtest/gtest.h>
5 
6 using namespace std;
7 using namespace Belle2;
8 
9 namespace {
10 
11  TEST(VariableTest, makeROOTCompatible)
12  {
13  EXPECT_EQ("", makeROOTCompatible(""));
14  EXPECT_EQ("test", makeROOTCompatible("test"));
15  EXPECT_EQ("test213", makeROOTCompatible("test213"));
16  EXPECT_EQ("test_23", makeROOTCompatible("test_23"));
17 
18  EXPECT_EQ("", makeROOTCompatible(""));
19  EXPECT_EQ("test", makeROOTCompatible("test"));
20  EXPECT_EQ("test213", makeROOTCompatible("test213"));
21  EXPECT_EQ("test_23", makeROOTCompatible("test_23"));
22 
23  EXPECT_EQ("test__bo23__bc", makeROOTCompatible("test(23)"));
24  EXPECT_EQ("test__so23__sc", makeROOTCompatible("test[23]"));
25  EXPECT_EQ("test__co23__cc", makeROOTCompatible("test{23}"));
26  EXPECT_EQ("test__boe__pl__clgamma__cm__spM__sp__st__sp3__bc", makeROOTCompatible("test(e+:gamma, M < 3)"));
27  EXPECT_EQ("__cl__bo__bc__sp__bo__bc__cm", makeROOTCompatible(":() (),"));
28  EXPECT_EQ("c__cl__bo__bcb__sp__bo__bc__cma", makeROOTCompatible("c:()b (),a"));
29  EXPECT_EQ("c__cl__bo__cm__pl8951aBZWVZUEOH_Rhtnsq__bcb__sp__bo__bc__cma", makeROOTCompatible("c:(,+8951aBZWVZUEOH_Rhtnsq)b (),a"));
30  EXPECT_EQ("foo__bobar__cm__mi0__pt123__cm__sp94__bc", makeROOTCompatible("foo(bar,-0.123, 94)"));
31 
32  for (const auto& pair : getSubstitutionMap()) {
33  EXPECT_EQ(pair.second, makeROOTCompatible(pair.first));
34  }
35 
36  EXPECT_NO_B2WARNING(makeROOTCompatible("test_a"));
37  EXPECT_B2WARNING(makeROOTCompatible("test__a"));
38  }
39 
40  TEST(VariableTest, invertMakeROOTCompatible)
41  {
42  EXPECT_EQ(invertMakeROOTCompatible(""), "");
43  EXPECT_EQ(invertMakeROOTCompatible("test"), "test");
44  EXPECT_EQ(invertMakeROOTCompatible("test213"), "test213");
45  EXPECT_EQ(invertMakeROOTCompatible("test_23"), "test_23");
46 
47  EXPECT_EQ(invertMakeROOTCompatible(""), "");
48  EXPECT_EQ(invertMakeROOTCompatible("test"), "test");
49  EXPECT_EQ(invertMakeROOTCompatible("test213"), "test213");
50  EXPECT_EQ(invertMakeROOTCompatible("test_23"), "test_23");
51 
52  EXPECT_EQ(invertMakeROOTCompatible("test__bo23__bc"), "test(23)");
53  EXPECT_EQ(invertMakeROOTCompatible("test__so23__sc"), "test[23]");
54  EXPECT_EQ(invertMakeROOTCompatible("test__co23__cc"), "test{23}");
55  EXPECT_EQ(invertMakeROOTCompatible("test__boe__pl__clgamma__cm__spM__sp__st__sp3__bc"), "test(e+:gamma, M < 3)");
56  EXPECT_EQ(invertMakeROOTCompatible("__cl__bo__bc__sp__bo__bc__cm"), ":() (),");
57  EXPECT_EQ(invertMakeROOTCompatible("c__cl__bo__bcb__sp__bo__bc__cma"), "c:()b (),a");
58  EXPECT_EQ(invertMakeROOTCompatible("c__cl__bo__cm__pl8951aBZWVZUEOH_Rhtnsq__bcb__sp__bo__bc__cma"),
59  "c:(,+8951aBZWVZUEOH_Rhtnsq)b (),a");
60  EXPECT_EQ(invertMakeROOTCompatible("foo__bobar__cm__mi0__pt123__cm__sp94__bc"), "foo(bar,-0.123, 94)");
61 
62  for (const auto& pair : getSubstitutionMap()) {
63  EXPECT_EQ(pair.first, invertMakeROOTCompatible(pair.second));
64  }
65  }
66 
67 }
Belle2::invertMakeROOTCompatible
std::string invertMakeROOTCompatible(std::string str)
Invert makeROOTCompatible operation.
Definition: MakeROOTCompatible.cc:89
Belle2::makeROOTCompatible
std::string makeROOTCompatible(std::string str)
Remove special characters that ROOT dislikes in branch names, e.g.
Definition: MakeROOTCompatible.cc:74
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::getSubstitutionMap
std::map< std::string, std::string > getSubstitutionMap()
Substituation map for makeROOTCompatible.
Definition: MakeROOTCompatible.cc:32
Belle2::TEST
TEST(TestgetDetectorRegion, TestgetDetectorRegion)
Test Constructors.
Definition: utilityFunctions.cc:18