ATLAS Offline Software
Loading...
Searching...
No Matches
ColumnarMemoryTest.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7
8#ifndef COLUMNAR_TEST_FIXTURES__COLUMNAR_MEMORY_TEST_H
9#define COLUMNAR_TEST_FIXTURES__COLUMNAR_MEMORY_TEST_H
10
11#include <AsgTools/AsgTool.h>
17
18#include <gtest/gtest.h>
19
20#include <optional>
21
22namespace columnar
23{
24 namespace TestUtils
25 {
27 struct ColumnMapType;
28 }
29
30 struct ColumnarMemoryTest : public testing::Test
31 {
33
35 std::string makeUniqueName ();
36
38 static bool checkMode ();
39
42 };
43
44
45
46 namespace TestUtils
47 {
53
55 {
58
59 public:
60
61 explicit ColumnarTestToolHandle (asg::AsgTool& val_tool);
62
64 void renameContainers (const std::vector<std::pair<std::string,std::string>>& renames);
65
67 void initialize ();
68
70 void applySystematicVariation (const std::string& sysName);
71
73 [[nodiscard]] std::vector<ColumnInfo> getColumnInfo () const;
74
76 std::vector<std::string> getColumnNames () const;
77
79 std::vector<std::string> getRecommendedSystematics () const;
80
82 [[nodiscard]] ToolColumnVectorMap& getToolWrapper ();
83 [[nodiscard]] const ToolColumnVectorMap& getToolWrapper () const;
84
86 [[nodiscard]] const ColumnVectorHeader& getColumnHeader () const {
87 return *m_columnHeader;}
88
90 [[nodiscard]] IColumnarTool* getTool ();
91
92
93
96
97 private:
98
101
102 std::shared_ptr<ColumnVectorHeader> m_columnHeader;
103 std::shared_ptr<ToolColumnVectorMap> m_toolWrapper;
104 };
105
106
107
108 struct ColumnMapType final
109 {
110 ColumnMapType (ColumnarTestToolHandle& val_toolHandle);
111
112 void addColumn (const std::string& name, std::vector<std::any> data);
113
114 std::size_t columnSize (const std::string& name);
115
116 void setExpectation (const std::string& name, std::vector<std::any> values);
117
119 void connectColumnsToTool ();
120
121 void call ();
122
123 void checkExpectations ();
124
125 template<typename T> void addTypedColumn (const std::string& name, std::vector<T> data)
126 {
127 addColumn (name, std::vector<std::any> (data.begin(), data.end()));
128 }
129
130 private:
131
133
134 std::unique_ptr<ColumnVectorData> m_columnData;
135
136 struct MyColumnData final
137 {
138 std::optional<ColumnInfo> info;
139 std::optional<ManualColumnData> input;
140 std::optional<ManualColumnData> expectation;
141 };
142 std::unordered_map<std::string,MyColumnData> m_userColumns;
143 };
144 }
145}
146
147#endif
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
Interface for all CP tools supporting systematic variations.
Base class for the dual-use tool implementation classes.
Definition AsgTool.h:47
the header information for the entire columnar data vector
an interface for tools that operate on columnar data
a handle to a columnar tool for running tests
std::shared_ptr< ColumnVectorHeader > m_columnHeader
ToolColumnVectorMap & getToolWrapper()
get the tool wrapper
std::shared_ptr< ToolColumnVectorMap > m_toolWrapper
void applySystematicVariation(const std::string &sysName)
set the tool to apply the given systematic variation
std::vector< std::string > getRecommendedSystematics() const
get the recommended systematics
const ColumnVectorHeader & getColumnHeader() const
get the column header
void renameContainers(const std::vector< std::pair< std::string, std::string > > &renames)
rename the columns the tool uses
IColumnarTool * getTool()
get the contained tool
std::vector< ColumnInfo > getColumnInfo() const
get the expected column info
std::vector< std::string > getColumnNames() const
get the expected column names
a class that interfaces an IColumnarTool to a ColumnVectorHeader
TestUtils::ColumnMapType ColumnMapType
TestUtils::ColumnarTestToolHandle ColumnarTestToolHandle
std::string makeUniqueName()
make a unique tool name to be used in unit tests
static bool checkMode()
check whether we have the right mode
ColumnarTestToolHandle * m_toolHandle
void setExpectation(const std::string &name, std::vector< std::any > values)
std::unique_ptr< ColumnVectorData > m_columnData
void addTypedColumn(const std::string &name, std::vector< T > data)
void connectColumnsToTool()
add the columns we have to the tool
std::size_t columnSize(const std::string &name)
ColumnMapType(ColumnarTestToolHandle &val_toolHandle)
void addColumn(const std::string &name, std::vector< std::any > data)
std::unordered_map< std::string, MyColumnData > m_userColumns