ATLAS Offline Software
TreeTest.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 #include "gtest/gtest.h"
10 #include <vector>
11 #include <map>
12 
13 using res = std::pair<std::vector<unsigned int>, bool>;
14 using vec = std::vector<std::size_t>;
15 
16 TEST(TreeTester, empty) {
17  std::vector<std::size_t> parents;
18 
19  Tree tree(parents);
20 
21  EXPECT_EQ(tree.size(), 0u);
22 }
23 
24 
25 TEST(TreeTester, simple) {
26  std::vector<std::size_t> parents {0u, 0u, 0u};
27 
28  Tree tree(parents);
29 
30  vec leaves {1u, 2u};
31  EXPECT_EQ(tree.size(), 3u);
32  EXPECT_EQ(tree.leaves(), leaves);
33  EXPECT_FALSE(tree.is_leaf(0u));
34  EXPECT_TRUE(tree.is_leaf(1u));
35  EXPECT_TRUE(tree.is_leaf(1u));
36 
37  EXPECT_TRUE(tree.is_simple());
38 
39 }
40 
41 
42 TEST(TreeTester, notsimple) {
43  std::vector<std::size_t> parents {0u, 0u, 1u};
44 
45  Tree tree(parents);
46 
47  vec leaves {2u};
48  EXPECT_EQ(tree.size(), 3u);
49  EXPECT_EQ(tree.leaves(), leaves);
50  EXPECT_FALSE(tree.is_leaf(0u));
51  EXPECT_FALSE(tree.is_leaf(1u));
52  EXPECT_TRUE(tree.is_leaf(2u));
53 
54  EXPECT_FALSE(tree.is_simple());
55 
56 }
57 
Tree
Definition: Tree.h:18
python.DecayParser.parents
parents
print ("==> buf:",buf)
Definition: DecayParser.py:31
tree
TChain * tree
Definition: tile_monitor.h:30
TEST
TEST(TreeTester, empty)
Definition: TreeTest.cxx:16
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
Definition: TreeTest.cxx:6
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:14
Tree.h
checker_macros.h
Define macros for attributes used to control the static checker.