#include "boost/test/unit_test.hpp"
#include "cetlib/filepath_maker.h"
#include "cetlib/includer.h"
#include "cetlib_except/exception.h"
#include <fstream>
#include <iostream>
#include <regex>
#include <sstream>
#include <string>
#include <system_error>
#include <unistd.h>
Go to the source code of this file.
#define BOOST_TEST_MODULE (includer test) |
BOOST_AUTO_TEST_CASE |
( |
no_inclusion_test |
| ) |
|
Definition at line 128 of file includer_test.cc.
134 BOOST_TEST(result1 == expected_string(contents_a));
138 BOOST_TEST(result2 == expected_string(contents_b));
142 BOOST_TEST(result3 == expected_string(contents_c));
BOOST_AUTO_TEST_CASE |
( |
single_inclusion_test |
| ) |
|
Definition at line 145 of file includer_test.cc.
149 BOOST_TEST(
result == expected_string(
"begin\n") +
150 expected_string(contents_a) +
151 expected_string(
"end\n"));
BOOST_AUTO_TEST_CASE |
( |
double_inclusion_test |
| ) |
|
Definition at line 154 of file includer_test.cc.
159 expected_string(
"begin\n") + expected_string(contents_a) +
160 expected_string(contents_b) + expected_string(contents_c) +
161 expected_string(
"end\n"));
BOOST_AUTO_TEST_CASE |
( |
repeated_inclusion_test |
| ) |
|
Definition at line 164 of file includer_test.cc.
169 expected_string(
"begin\n") + expected_string(
"begin\n") +
170 expected_string(contents_a) + expected_string(contents_b) +
171 expected_string(contents_c) + expected_string(
"end\n") +
172 expected_string(
"begin\n") + expected_string(contents_a) +
173 expected_string(
"end\n") + expected_string(
"end\n"));
BOOST_AUTO_TEST_CASE |
( |
malformed_inclusion_test |
| ) |
|
Definition at line 176 of file includer_test.cc.
cet::coded_exception< error, detail::translate > exception
BOOST_AUTO_TEST_CASE |
( |
simple_recursive_inclusion_test |
| ) |
|
Definition at line 183 of file includer_test.cc.
185 BOOST_CHECK_EXCEPTION(
187 return e.category() ==
"Recursive #include directive:";
cet::coded_exception< error, detail::translate > exception
BOOST_AUTO_TEST_CASE |
( |
complex_recursive_inclusion_test |
| ) |
|
Definition at line 191 of file includer_test.cc.
196 return e.category() ==
197 "Recursive #include directive:";
cet::coded_exception< error, detail::translate > exception
BOOST_AUTO_TEST_CASE |
( |
string_inclusion_test |
| ) |
|
Definition at line 201 of file includer_test.cc.
204 std::istringstream is_a(a);
207 BOOST_TEST(result_a == a);
210 std::istringstream is_i(i);
213 BOOST_TEST(result_i == expected_string(
"begin\n") +
214 expected_string(contents_a) +
215 expected_string(
"end\n"));
BOOST_AUTO_TEST_CASE |
( |
backtrace_test |
| ) |
|
Definition at line 218 of file includer_test.cc.
224 std::cerr << j.whereis(it) <<
"\n";
226 std::string cmp(
"line 1, character 6, of file \"././j.txt\"");
228 std::advance(it, 10);
230 std::cerr << j.whereis(it) <<
"\n";
232 cmp =
"line 2, character 4, of file \"././a.txt\"\n" 233 "included from line 2 of file \"././j.txt\"";
235 std::advance(it, 10);
237 std::cerr << j.whereis(it) <<
"\n";
238 cmp =
"line 2, character 2, of file \"././b.txt\"\n" 239 "included from line 3 of file \"././j.txt\"";
BOOST_TEST_REQUIRE(static_cast< bool >(inFile))
BOOST_AUTO_TEST_CASE |
( |
highlighted_backtrace_test |
| ) |
|
Definition at line 243 of file includer_test.cc.
249 std::cerr << j.highlighted_whereis(it) <<
"\n";
251 std::string cmp(
"line 1, character 6, of file \"././j.txt\"");
252 cmp +=
"\n\nbegin\n ^";
254 std::advance(it, 10);
256 std::cerr << j.highlighted_whereis(it) <<
"\n";
258 cmp =
"line 2, character 4, of file \"././a.txt\"\n" 259 "included from line 2 of file \"././j.txt\"";
260 cmp +=
"\n\nvwxyz\n ^";
262 std::advance(it, 10);
264 std::cerr << j.highlighted_whereis(it) <<
"\n";
265 cmp =
"line 2, character 2, of file \"././b.txt\"\n" 266 "included from line 3 of file \"././j.txt\"";
267 cmp +=
"\n\n67890\n ^";
BOOST_TEST_REQUIRE(static_cast< bool >(inFile))