Macros | Functions
make_tool_t.cc File Reference
#include "boost/test/unit_test.hpp"
#include "art/Utilities/make_tool.h"
#include "art/test/Utilities/tools/ClassTool.h"
#include "art/test/Utilities/tools/FunctionTool.h"
#include "art/test/Utilities/tools/NestedClassTool.h"
#include "art/test/Utilities/tools/NestedFunctionInClassTool.h"
#include "art/test/Utilities/tools/NestedFunctionTool.h"
#include "art/test/Utilities/tools/OperationBase.h"
#include "fhiclcpp/ParameterSet.h"
#include <string>

Go to the source code of this file.

Macros

#define BOOST_TEST_MODULE   (make_tool_t)
 

Functions

 BOOST_AUTO_TEST_CASE (tool_class)
 
 BOOST_AUTO_TEST_CASE (tool_function)
 
 BOOST_AUTO_TEST_CASE (nested_function_tools)
 
 BOOST_AUTO_TEST_CASE (nested_class_tools)
 
 BOOST_AUTO_TEST_CASE (nested_function_in_class_tools)
 
 BOOST_AUTO_TEST_CASE (polymorphic_tools)
 

Macro Definition Documentation

#define BOOST_TEST_MODULE   (make_tool_t)

Definition at line 1 of file make_tool_t.cc.

Function Documentation

BOOST_AUTO_TEST_CASE ( tool_class  )

Definition at line 27 of file make_tool_t.cc.

28 {
30  ps.put("tool_type", "ClassTool"s);
31  auto t1 = art::make_tool<arttest::ClassTool>(ps);
32  BOOST_TEST(t1->addOne(17) == 18);
33 }
static constexpr double ps
Definition: Units.h:99
static QCString * s
Definition: config.cpp:1042
void put(std::string const &key)
BOOST_AUTO_TEST_CASE ( tool_function  )

Definition at line 35 of file make_tool_t.cc.

36 {
38  ps.put("tool_type", "FunctionTool"s);
39  int i{17};
40  auto addOne1 = art::make_tool<decltype(arttest::addOne)>(ps, "addOne");
41  auto addOne2 = art::make_tool<int(int)>(ps, "addOne");
42  BOOST_TEST(addOne1(i) == 18);
43  BOOST_TEST(addOne2(i) == 18);
44 }
static constexpr double ps
Definition: Units.h:99
static QCString * s
Definition: config.cpp:1042
void put(std::string const &key)
BOOST_AUTO_TEST_CASE ( nested_function_tools  )

Definition at line 46 of file make_tool_t.cc.

47 {
48  std::ostringstream ss;
49  ss << "tool_type: NestedFunctionTool\n"
50  << "addOneTool: {"
51  << " tool_type: FunctionTool"
52  << "}";
53  auto const& ps = pset_from_oss(ss);
54  auto callThroughToAddOne =
55  art::make_tool<decltype(arttest::callThroughToAddOne)>(
56  ps, "callThroughToAddOne");
57  auto const& nestedPS = ps.get<fhicl::ParameterSet>("addOneTool");
58  BOOST_TEST(callThroughToAddOne(nestedPS, 17) == 18);
59 }
static constexpr double ps
Definition: Units.h:99
int callThroughToAddOne(fhicl::ParameterSet const &pset, int const i)
BOOST_AUTO_TEST_CASE ( nested_class_tools  )

Definition at line 61 of file make_tool_t.cc.

62 {
63  std::ostringstream ss;
64  ss << "tool_type: NestedClassTool\n"
65  << "addOneTool: {"
66  << " tool_type: ClassTool"
67  << "}";
68  auto const& ps = pset_from_oss(ss);
69  auto t = art::make_tool<arttest::NestedClassTool>(ps);
70  BOOST_TEST(t->callThroughToAddOne(17) == 18);
71 }
static constexpr double ps
Definition: Units.h:99
BOOST_AUTO_TEST_CASE ( nested_function_in_class_tools  )

Definition at line 73 of file make_tool_t.cc.

74 {
75  std::ostringstream ss;
76  ss << "tool_type: NestedFunctionInClassTool\n"
77  << "addOneTool: {"
78  << " tool_type: FunctionTool"
79  << "}";
80  auto const& ps = pset_from_oss(ss);
81  auto t = art::make_tool<arttest::NestedFunctionInClassTool>(ps);
82  BOOST_TEST(t->callThroughToAddOne(17) == 18);
83 }
static constexpr double ps
Definition: Units.h:99
BOOST_AUTO_TEST_CASE ( polymorphic_tools  )

Definition at line 85 of file make_tool_t.cc.

86 {
87  int i{17};
88  {
90  ps.put("tool_type", "AddNumber");
91  ps.put("incrementBy", 7);
92  art::make_tool<arttest::OperationBase>(ps)->adjustNumber(i);
93  BOOST_TEST(i == 24);
94  }
95  {
97  ps.put("tool_type", "SubtractNumber");
98  art::make_tool<arttest::OperationBase>(ps)->adjustNumber(i);
99  BOOST_TEST(i == 23);
100  }
101  {
103  ps.put("tool_type", "MultiplyNumber");
104  art::make_tool<arttest::OperationBase>(ps)->adjustNumber(i);
105  BOOST_TEST(i == 46);
106  }
107 }
static constexpr double ps
Definition: Units.h:99
void put(std::string const &key)