Belle II Software  release-08-01-10
ioutils.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 #include <framework/io/RootIOUtilities.h>
9 #include <framework/utilities/TestHelpers.h>
10 
11 #include <gtest/gtest.h>
12 
13 using namespace std;
14 using namespace Belle2;
15 
16 namespace {
17  TEST(IOTest, filterBranches)
18  {
19  const set<string> input = {"A", "B", "C", "AToB", "BToC", "CToA"};
20  //unfiltered
21  EXPECT_EQ(input, RootIOUtilities::filterBranches(input, {}, {}, 0));
22 
23  EXPECT_EQ(set<string>({"A", "C", "CToA"}), RootIOUtilities::filterBranches(input, {"A", "C"}, {}, 0));
24  EXPECT_EQ(set<string>({"B"}), RootIOUtilities::filterBranches(input, {"B"}, {}, 0));
25 
26  //excludeBranches takes precedence over everything
27  EXPECT_EQ(set<string>({"A", "C"}), RootIOUtilities::filterBranches(input, {"A", "C"}, {"CToA"}, 0));
28  //and also prevents dangling relations
29  EXPECT_EQ(set<string>({"A", "C"}), RootIOUtilities::filterBranches(input, {}, {"B", "CToA"}, 0));
30  EXPECT_EQ(set<string>({"A", "C", "CToA"}), RootIOUtilities::filterBranches(input, {}, {"B"}, 0));
31  //unless one really wants them!
32  EXPECT_EQ(set<string>({"AToB"}), RootIOUtilities::filterBranches(input, {"AToB", "B"}, {"B"}, 0));
33  EXPECT_EQ(set<string>(), RootIOUtilities::filterBranches(input, {"B"}, {"B"}, 0));
34  }
35 
36  TEST(IOTest, filterBranchesWarnings)
37  {
38  const set<string> input = {"A", "B", "C"};
39  EXPECT_B2WARNING(RootIOUtilities::filterBranches(input, {"A", "A"}, {}, 0));
40  EXPECT_B2WARNING(RootIOUtilities::filterBranches(input, {}, {"A", "B", "A"}, 1));
41  }
42 
43 } // namespace
TEST(TestgetDetectorRegion, TestgetDetectorRegion)
Test Constructors.
Abstract base class for different kinds of events.