Macros | Functions
nestedValidation_03_t.cc File Reference
#include "boost/test/unit_test.hpp"
#include "fhiclcpp/ParameterSet.h"
#include "fhiclcpp/types/Atom.h"
#include "fhiclcpp/types/Name.h"
#include "fhiclcpp/types/Sequence.h"
#include "fhiclcpp/types/Table.h"
#include "fhiclcpp/types/Tuple.h"
#include <string>

Go to the source code of this file.

Macros

#define BOOST_TEST_MODULE   (Nested Validation)
 

Functions

 BOOST_AUTO_TEST_CASE (GoodTuple1)
 
 BOOST_AUTO_TEST_CASE (GoodTuple2)
 
 BOOST_AUTO_TEST_CASE (BadTuple1)
 
 BOOST_AUTO_TEST_CASE (BadTuple2)
 
 BOOST_AUTO_TEST_CASE (BadTuple3)
 
 BOOST_AUTO_TEST_CASE (BadTuple4)
 

Macro Definition Documentation

#define BOOST_TEST_MODULE   (Nested Validation)

Definition at line 1 of file nestedValidation_03_t.cc.

Function Documentation

BOOST_AUTO_TEST_CASE ( GoodTuple1  )

Definition at line 53 of file nestedValidation_03_t.cc.

54 {
55  string const good{"nested: { pars: [[A, [B]], [X, [Y, Z]]] }"s};
56  std::vector<std::string> const ref1{"B"s};
57  std::vector<std::string> const ref2{"Y"s, "Z"s};
58  std::vector<std::string> const ref3{"U"s, "V"s, "W"s};
59  auto validatedConfig = validateConfig(good);
60  auto const& pars = validatedConfig().nested().pars();
61  BOOST_TEST_REQUIRE(pars.size() == 2ull);
62  BOOST_TEST(std::get<0>(pars[0]) == "A"s);
63  BOOST_TEST(std::get<1>(pars[0]) == ref1);
64  BOOST_TEST(std::get<0>(pars[1]) == "X"s);
65  BOOST_TEST(std::get<1>(pars[1]) == ref2);
66  auto const& defaultedPars = validatedConfig().nestedWithDef().pars();
67  BOOST_TEST_REQUIRE(defaultedPars.size() == 1ull);
68  BOOST_TEST(std::get<0>(defaultedPars[0]) == "T"s);
69  BOOST_TEST(std::get<1>(defaultedPars[0]) == ref3);
70 }
fhicl::Table< Config > validateConfig(std::string const &configStr)
BOOST_TEST_REQUIRE(static_cast< bool >(inFile))
static QCString * s
Definition: config.cpp:1042
BOOST_AUTO_TEST_CASE ( GoodTuple2  )

Definition at line 72 of file nestedValidation_03_t.cc.

73 {
74  string const good{"nested: { pars: [[A, [B]], [X, [Y, Z]]] }\n"s +
75  "nestedWithDef: { pars: [[M, [N, O, P, Q]], [R, [S]]] }"s};
76  std::vector<std::string> const ref1{"B"s};
77  std::vector<std::string> const ref2{"Y"s, "Z"s};
78  std::vector<std::string> const ref3{"N"s, "O"s, "P"s, "Q"s};
79  std::vector<std::string> const ref4{"S"s};
80  auto validatedConfig = validateConfig(good);
81  auto const& pars = validatedConfig().nested().pars();
82  BOOST_TEST_REQUIRE(pars.size() == 2ull);
83  BOOST_TEST(std::get<0>(pars[0]) == "A"s);
84  BOOST_TEST(std::get<1>(pars[0]) == ref1);
85  BOOST_TEST(std::get<0>(pars[1]) == "X"s);
86  BOOST_TEST(std::get<1>(pars[1]) == ref2);
87  auto const& defaultedPars = validatedConfig().nestedWithDef().pars();
88  BOOST_TEST_REQUIRE(defaultedPars.size() == 2ull);
89  BOOST_TEST(std::get<0>(defaultedPars[0]) == "M"s);
90  BOOST_TEST(std::get<1>(defaultedPars[0]) == ref3);
91  BOOST_TEST(std::get<0>(defaultedPars[1]) == "R"s);
92  BOOST_TEST(std::get<1>(defaultedPars[1]) == ref4);
93 }
fhicl::Table< Config > validateConfig(std::string const &configStr)
BOOST_TEST_REQUIRE(static_cast< bool >(inFile))
static QCString * s
Definition: config.cpp:1042
BOOST_AUTO_TEST_CASE ( BadTuple1  )

Definition at line 95 of file nestedValidation_03_t.cc.

96 {
97  string const bad{"nested: { pars: [[A], [X, [Y, Z]]] }"s};
98  BOOST_REQUIRE_THROW(validateConfig(bad), detail::validationException);
100 }
fhicl::Table< Config > validateConfig(std::string const &configStr)
BOOST_TEST_REQUIRE(static_cast< bool >(inFile))
unsigned int bad()
static QCString * s
Definition: config.cpp:1042
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:97
BOOST_AUTO_TEST_CASE ( BadTuple2  )

Definition at line 102 of file nestedValidation_03_t.cc.

103 {
104  string const bad{"nested: { pars: [[A]] }"s};
105  BOOST_REQUIRE_THROW(validateConfig(bad), detail::validationException);
107 }
fhicl::Table< Config > validateConfig(std::string const &configStr)
BOOST_TEST_REQUIRE(static_cast< bool >(inFile))
unsigned int bad()
static QCString * s
Definition: config.cpp:1042
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:97
BOOST_AUTO_TEST_CASE ( BadTuple3  )

Definition at line 109 of file nestedValidation_03_t.cc.

110 {
111  string const bad{"nested: { pars: [[A, 7]] }"s};
112  BOOST_REQUIRE_THROW(validateConfig(bad), fhicl::exception);
114 }
fhicl::Table< Config > validateConfig(std::string const &configStr)
BOOST_TEST_REQUIRE(static_cast< bool >(inFile))
unsigned int bad()
static QCString * s
Definition: config.cpp:1042
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:97
BOOST_AUTO_TEST_CASE ( BadTuple4  )

Definition at line 116 of file nestedValidation_03_t.cc.

117 {
118  string const bad{"nested: { pars: [[A, [7]]] }\n"s +
119  "nestedWithDef: { pars: [[A]]}"s};
120  BOOST_REQUIRE_THROW(validateConfig(bad), detail::validationException);
122 }
fhicl::Table< Config > validateConfig(std::string const &configStr)
BOOST_TEST_REQUIRE(static_cast< bool >(inFile))
unsigned int bad()
static QCString * s
Definition: config.cpp:1042
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:97