21 #ifndef WREPORT_TESTS_UTILS
22 #define WREPORT_TESTS_UTILS
24 #include <wreport/utils/tests.h>
26 #include <wreport/bulletin.h>
27 #include <wreport/tests.h>
28 #include <wreport/notes.h>
41 std::string datafile(
const std::string& fname);
48 std::string slurpfile(
const std::string& name);
53 std::vector<std::string> all_test_files(
const std::string& encoding);
55 void track_bulletin(Bulletin& b,
const char* tag,
const char* fname);
57 template<
typename BULLETIN>
58 std::unique_ptr<BULLETIN> decode_checked(
const std::string& buf,
const char* name)
61 return BULLETIN::decode(buf, name);
64 auto h = BULLETIN::decode_header(buf, name);
65 h->print_structured(stderr);
67 std::cerr <<
"Dump interrupted: " << e.
what();
73 template<
typename BULLETIN>
77 std::function<void(const BULLETIN&)> check_contents = [](
const BULLETIN&) {};
79 TestCodec(
const std::string& fname) : fname(fname) {}
85 void assert_var_equal(
const Var& actual,
const Var& expected);
86 void assert_var_not_equal(
const Var& actual,
const Var& expected);
87 template<
typename Val>
88 void assert_var_value_equal(
const Var& actual, Val expected);
89 template<
typename Val>
90 void assert_var_value_not_equal(
const Var& actual, Val expected);
97 void operator==(
const Var& expected)
const { assert_var_equal(_actual, expected); }
98 void operator!=(
const Var& expected)
const { assert_var_not_equal(_actual, expected); }
99 template<
typename Val>
100 void operator==(Val expected)
const { assert_var_value_equal(_actual, expected); }
101 template<
typename Val>
102 void operator!=(Val expected)
const { assert_var_value_not_equal(_actual, expected); }
104 void isunset()
const;
111 using Actual::Actual;
113 void operator==(
Varcode expected)
const;
114 void operator!=(
Varcode expected)
const;
Base class for DB-All.e exceptions.
Definition: error.h:59
A physical variable.
Definition: var.h:23
Definition: utils/tests.h:275
Report an error when parsing informations.
Definition: error.h:192
uint16_t Varcode
Holds the WMO variable code of a variable.
Definition: varinfo.h:57
Implement fast access to information about WMO variables.
virtual const char * what() const noexcept=0
Error message.