Macros | Functions
fhicl-get-test.cc File Reference
#include "boost/test/unit_test.hpp"
#include "tools/fhicl_get_impl.h"
#include <initializer_list>
#include <iostream>
#include <tuple>
#include <vector>

Go to the source code of this file.

Macros

#define BOOST_TEST_MODULE   (fhicl - get test)
 

Functions

 BOOST_AUTO_TEST_CASE (no_arguments)
 
 BOOST_AUTO_TEST_CASE (help_message)
 
 BOOST_AUTO_TEST_CASE (missing_key)
 
 BOOST_AUTO_TEST_CASE (retrieve_string)
 
 BOOST_AUTO_TEST_CASE (retrieve_double)
 
 BOOST_AUTO_TEST_CASE (retrieve_int)
 
 BOOST_AUTO_TEST_CASE (retrieve_bool)
 
 BOOST_AUTO_TEST_CASE (retrieve_sequence_int)
 
 BOOST_AUTO_TEST_CASE (unsupported_types)
 
 BOOST_AUTO_TEST_CASE (names_in_file)
 
 BOOST_AUTO_TEST_CASE (names_in_nonempty_table)
 
 BOOST_AUTO_TEST_CASE (names_in_empty_table)
 
 BOOST_AUTO_TEST_CASE (names_in_nonexistent_table_1)
 
 BOOST_AUTO_TEST_CASE (names_in_nonexistent_table_2)
 
 BOOST_AUTO_TEST_CASE (names_in_nontable)
 

Macro Definition Documentation

#define BOOST_TEST_MODULE   (fhicl - get test)

Definition at line 1 of file fhicl-get-test.cc.

Function Documentation

BOOST_AUTO_TEST_CASE ( no_arguments  )

Definition at line 53 of file fhicl-get-test.cc.

54 {
55  auto const [rc, stdout, stderr] = run({});
56  BOOST_TEST(rc == 1);
57  BOOST_TEST(stdout == "");
58  BOOST_TEST(stderr.find("Missing input configuration file.") !=
59  std::string::npos);
60 }
BOOST_AUTO_TEST_CASE ( help_message  )

Definition at line 62 of file fhicl-get-test.cc.

63 {
64  auto const [rc, stdout, stderr] = run({"-h"});
65  BOOST_TEST(rc == 0);
66  BOOST_TEST(stdout.find("Usage: fhicl-get [options] [key] <file>") !=
67  std::string::npos);
68  BOOST_TEST(stderr == "");
69 }
BOOST_AUTO_TEST_CASE ( missing_key  )

Definition at line 71 of file fhicl-get-test.cc.

72 {
73  auto const [rc, stdout, stderr] =
74  run({"--atom-as", "string", "fhicl-get-t.fcl"});
75  BOOST_TEST(rc == 1);
76  BOOST_TEST(stdout == "");
77  BOOST_TEST(
78  stderr.find(
79  "A key must be specified unless the '--names-in' option is used.") !=
80  std::string::npos);
81 }
BOOST_AUTO_TEST_CASE ( retrieve_string  )

Definition at line 83 of file fhicl-get-test.cc.

84 {
85  auto const [rc, stdout, stderr] =
86  run({"--atom-as", "string", "a.billy", "fhicl-get-t.fcl"});
87  BOOST_TEST(rc == 0);
88  BOOST_TEST(stdout == "the kid\n");
89  BOOST_TEST(stderr == "");
90 }
BOOST_AUTO_TEST_CASE ( retrieve_double  )

Definition at line 92 of file fhicl-get-test.cc.

93 {
94  auto const [rc, stdout, stderr] =
95  run({"--atom-as", "double", "c", "fhicl-get-t.fcl"});
96  BOOST_TEST(rc == 0);
97  BOOST_TEST(stdout == "1.25\n");
98  BOOST_TEST(stderr == "");
99 }
BOOST_AUTO_TEST_CASE ( retrieve_int  )

Definition at line 101 of file fhicl-get-test.cc.

102 {
103  auto const [rc, stdout, stderr] =
104  run({"--atom-as", "int", "d", "fhicl-get-t.fcl"});
105  BOOST_TEST(rc == 0);
106  BOOST_TEST(stdout == "42\n");
107  BOOST_TEST(stderr == "");
108 }
BOOST_AUTO_TEST_CASE ( retrieve_bool  )

Definition at line 110 of file fhicl-get-test.cc.

111 {
112  auto const [rc, stdout, stderr] =
113  run({"--atom-as", "bool", "e", "fhicl-get-t.fcl"});
114  BOOST_TEST(rc == 0);
115  BOOST_TEST(stdout == "0\n");
116  BOOST_TEST(stderr == "");
117 }
BOOST_AUTO_TEST_CASE ( retrieve_sequence_int  )

Definition at line 119 of file fhicl-get-test.cc.

120 {
121  auto const [rc, stdout, stderr] =
122  run({"--sequence-of", "int", "f", "fhicl-get-t.fcl"});
123  BOOST_TEST(rc == 0);
124  BOOST_TEST(stdout == "1\n3\n");
125  BOOST_TEST(stderr == "");
126 }
BOOST_AUTO_TEST_CASE ( unsupported_types  )

Definition at line 128 of file fhicl-get-test.cc.

129 {
130  auto const [rc, stdout, stderr] =
131  run({"--atom-as", "float", "e", "fhicl-get-t.fcl"});
132  BOOST_TEST(rc == 1);
133  BOOST_TEST(stdout == "");
134  BOOST_TEST(stderr.find("The specified type 'float' is not supported") !=
135  std::string::npos);
136 }
BOOST_AUTO_TEST_CASE ( names_in_file  )

Definition at line 138 of file fhicl-get-test.cc.

139 {
140  auto const [rc, stdout, stderr] = run({"--names-in", "fhicl-get-t.fcl"});
141  BOOST_TEST(rc == 0);
142  BOOST_TEST(stdout == "a\nb\nc\nd\ne\nf\n");
143  BOOST_TEST(stderr == "");
144 }
BOOST_AUTO_TEST_CASE ( names_in_nonempty_table  )

Definition at line 146 of file fhicl-get-test.cc.

147 {
148  auto const [rc, stdout, stderr] = run({"--names-in", "a", "fhicl-get-t.fcl"});
149  BOOST_TEST(rc == 0);
150  BOOST_TEST(stdout == "billy\n");
151  BOOST_TEST(stderr == "");
152 }
BOOST_AUTO_TEST_CASE ( names_in_empty_table  )

Definition at line 154 of file fhicl-get-test.cc.

155 {
156  auto const [rc, stdout, stderr] = run({"--names-in", "b", "fhicl-get-t.fcl"});
157  BOOST_TEST(rc == 0);
158  BOOST_TEST(stdout == "");
159  BOOST_TEST(stderr == "");
160 }
BOOST_AUTO_TEST_CASE ( names_in_nonexistent_table_1  )

Definition at line 162 of file fhicl-get-test.cc.

163 {
164  auto const [rc, stdout, stderr] =
165  run({"--names-in", "g.h", "fhicl-get-t.fcl"});
166  BOOST_TEST(rc == 1);
167  BOOST_TEST(stdout == "");
168  BOOST_TEST(
169  stderr.find(
170  "A parameter with the fully-qualified key 'g.h' does not exist.") !=
171  std::string::npos);
172 }
BOOST_AUTO_TEST_CASE ( names_in_nonexistent_table_2  )

Definition at line 174 of file fhicl-get-test.cc.

175 {
176  auto const [rc, stdout, stderr] =
177  run({"--names-in", "g.h", "--allow-missing", "fhicl-get-t.fcl"});
178  BOOST_TEST(rc == 0);
179  BOOST_TEST(stdout == "");
180  BOOST_TEST(stderr == "");
181 }
BOOST_AUTO_TEST_CASE ( names_in_nontable  )

Definition at line 183 of file fhicl-get-test.cc.

184 {
185  auto const [rc, stdout, stderr] =
186  run({"--names-in", "c", "--allow-missing", "fhicl-get-t.fcl"});
187  BOOST_TEST(rc == 1);
188  BOOST_TEST(stdout == "");
189  BOOST_TEST(
190  stderr.find("The parameter named 'c' does not have a table value.") !=
191  std::string::npos);
192 }