Macros | Functions
return_optionalValues_from_fcl_t.cc File Reference
#include "boost/test/unit_test.hpp"
#include "fhiclcpp/types/OptionalAtom.h"
#include "fhiclcpp/types/OptionalSequence.h"
#include "fhiclcpp/types/OptionalTable.h"
#include "fhiclcpp/types/OptionalTuple.h"
#include "fhiclcpp/types/Sequence.h"
#include "fhiclcpp/types/Table.h"
#include "fhiclcpp/types/Tuple.h"
#include "FixtureBase.h"
#include <limits>
#include <string>

Go to the source code of this file.

Macros

#define BOOST_TEST_MODULE   (return optional values from fcl)
 

Functions

 BOOST_AUTO_TEST_CASE (optAtom_t)
 
 BOOST_AUTO_TEST_CASE (optTable_t)
 
 BOOST_AUTO_TEST_CASE (optSeqVector_t1)
 
 BOOST_AUTO_TEST_CASE (optSeqVector_t2)
 
 BOOST_AUTO_TEST_CASE (optSeqVector_t3)
 
 BOOST_AUTO_TEST_CASE (optSeqVector_t4)
 
 BOOST_AUTO_TEST_CASE (optTuple_t)
 

Macro Definition Documentation

#define BOOST_TEST_MODULE   (return optional values from fcl)

Definition at line 10 of file return_optionalValues_from_fcl_t.cc.

Function Documentation

BOOST_AUTO_TEST_CASE ( optAtom_t  )

Definition at line 64 of file return_optionalValues_from_fcl_t.cc.

65 {
66  int i{};
67  std::string n;
68  BOOST_TEST(config().atom(i));
69  BOOST_TEST(!config().name(n));
70  BOOST_TEST(i == 5);
71  BOOST_TEST(n.empty());
72 }
static QCString name
Definition: declinfo.cpp:673
std::string string
Definition: nybbler.cc:12
static Config * config
Definition: config.cpp:1054
std::void_t< T > n
BOOST_AUTO_TEST_CASE ( optTable_t  )

Definition at line 75 of file return_optionalValues_from_fcl_t.cc.

76 {
77  auto phys = config().physics();
78  BOOST_REQUIRE(phys.has_value());
79  auto name = phys->moniker();
80  BOOST_REQUIRE(name.has_value());
81  BOOST_TEST(*name == "Johnny");
82  BOOST_TEST(phys->energyCutoff.get<0>() == "QGSP");
83  BOOST_TEST(phys->energyCutoff.get<1>() == 14.6, tolerance);
84 }
static QCString name
Definition: declinfo.cpp:673
auto const tolerance
static Config * config
Definition: config.cpp:1054
BOOST_AUTO_TEST_CASE ( optSeqVector_t1  )

Definition at line 87 of file return_optionalValues_from_fcl_t.cc.

88 {
89  std::vector<int> intList;
90  BOOST_TEST(!config().list1.hasValue());
91  BOOST_TEST(!config().list1(intList));
92 }
static Config * config
Definition: config.cpp:1054
BOOST_AUTO_TEST_CASE ( optSeqVector_t2  )

Definition at line 95 of file return_optionalValues_from_fcl_t.cc.

96 {
97  std::array<int, 4> intList;
98  auto ref = {1, 2, 4, 8};
99  BOOST_TEST(config().list2.hasValue());
100  BOOST_TEST(config().list2(intList));
101  BOOST_TEST(intList == ref, boost::test_tools::per_element{});
102 }
static Config * config
Definition: config.cpp:1054
BOOST_AUTO_TEST_CASE ( optSeqVector_t3  )

Definition at line 105 of file return_optionalValues_from_fcl_t.cc.

106 {
107  auto intLists = config().list3();
108  BOOST_TEST(intLists.has_value());
109 
110  decltype(intLists)::value_type const ref{
111  {{0, 1}}, {{1, 2}}, {{2, 4}}, {{3, 8}}};
112  std::size_t i{};
113  for (auto const& list : *intLists) {
114  BOOST_TEST(list == ref[i], boost::test_tools::per_element{});
115  ++i;
116  }
117 }
static Config * config
Definition: config.cpp:1054
BOOST_AUTO_TEST_CASE ( optSeqVector_t4  )

Definition at line 120 of file return_optionalValues_from_fcl_t.cc.

121 {
122  std::array<Composer, 4> composers;
123  BOOST_TEST(config().list4(composers));
124 
125  std::array<std::string, 4> const ref{
126  {"Mozart", "Beethoven", "Brahms", "Mahler"}};
127 
128  std::size_t i{};
129  for (auto const& comp : composers) {
130  BOOST_TEST(comp.composer() == ref[i]);
131  ++i;
132  }
133 }
static Config * config
Definition: config.cpp:1054
BOOST_AUTO_TEST_CASE ( optTuple_t  )

Definition at line 136 of file return_optionalValues_from_fcl_t.cc.

137 {
138  enum composer_t { Mozart, Beethoven, Brahms, Mahler };
139 
140  std::array<Composer, 4> composers;
141  BOOST_TEST(config().list4(composers));
142 
143  std::array<int, 4> const symphonyNumbers{{41, 3, 0, 8}};
144  std::array<std::string, 4> const symphonyMonikers{
145  {"Jupiter", "Eroica", "", "Symphony for a Thousand"}};
146  std::size_t i{};
147  for (auto const& comp : composers) {
148 
149  std::tuple<int, std::string> moniker;
150  if (i != static_cast<composer_t>(Brahms)) {
151  BOOST_TEST(comp.aSymphonyMoniker(moniker));
152  } else {
153  BOOST_TEST(!comp.aSymphonyMoniker(moniker));
154  }
155 
156  BOOST_TEST(std::get<int>(moniker) == symphonyNumbers[i]);
157  BOOST_TEST(std::get<std::string>(moniker) == symphonyMonikers[i]);
158  ++i;
159  }
160 }
static Config * config
Definition: config.cpp:1054