Belle II Software development
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
13using namespace std;
14using namespace Belle2;
15
16namespace {
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
std::set< std::string > filterBranches(const std::set< std::string > &branchesToFilter, const std::vector< std::string > &branches, const std::vector< std::string > &excludeBranches, int durability, bool quiet=false)
Given a list of input branches and lists of branches to include/exclude, returns a list of branches t...
Abstract base class for different kinds of events.
STL namespace.