21 #ifndef WREPORT_TESTS_UTILS 22 #define WREPORT_TESTS_UTILS 30 #include <wreport/bulletin.h> 31 #include <wreport/fwd.h> 32 #include <wreport/notes.h> 33 #include <wreport/tests.h> 34 #include <wreport/utils/tests.h> 41 std::filesystem::path
datafile(
const std::filesystem::path& fname);
52 const char* deflt =
nullptr);
59 std::string
slurpfile(
const std::filesystem::path& name);
64 std::vector<std::filesystem::path>
all_test_files(
const std::string& encoding);
74 void track_bulletin(
Bulletin& b,
const char* tag,
75 const std::filesystem::path& fname);
77 template <
typename BULLETIN>
78 std::unique_ptr<BULLETIN> decode_checked(
const std::string& buf,
83 return BULLETIN::decode(buf, name);
89 auto h = BULLETIN::decode_header(buf, name);
90 h->print_structured(stderr);
94 std::cerr <<
"Dump interrupted: " << e.
what();
100 template <
typename BULLETIN>
101 std::unique_ptr<BULLETIN> decode_checked(
const std::string& buf,
102 const char* name, FILE* verbose)
106 return BULLETIN::decode_verbose(buf, verbose, name);
112 auto h = BULLETIN::decode_header(buf, name);
113 h->print_structured(stderr);
117 std::cerr <<
"Dump interrupted: " << e2.
what();
125 std::filesystem::path fname;
126 std::function<void(const BULLETIN&)> check_contents =
127 [](
const BULLETIN&) noexcept {};
129 explicit TestCodec(
const std::filesystem::path& fname) : fname(fname) {}
135 void assert_var_equal(
const Var& actual,
const Var& expected);
136 void assert_var_not_equal(
const Var& actual,
const Var& expected);
137 template <
typename Val>
138 void assert_var_value_equal(
const Var& actual, Val expected);
139 template <
typename Val>
140 void assert_var_value_not_equal(
const Var& actual, Val expected);
146 void operator==(
const Var& expected)
const 148 assert_var_equal(_actual, expected);
150 void operator!=(
const Var& expected)
const 152 assert_var_not_equal(_actual, expected);
154 template <
typename Val>
void operator==(Val expected)
const 156 assert_var_value_equal(_actual, expected);
158 template <
typename Val>
void operator!=(Val expected)
const 160 assert_var_value_not_equal(_actual, expected);
163 void isunset()
const;
173 using Actual::Actual;
175 void operator==(Varcode expected)
const;
176 void operator!=(Varcode expected)
const;
Report an error when parsing informations.
Definition: error.h:200
A physical variable.
Definition: var.h:24
Definition: utils/tests.h:335
const char * what() const noexcept override=0
Error message.
std::vector< std::filesystem::path > all_test_files(const std::string &encoding)
Get a list of all test files for the given encoding.
Storage for the decoded data of a BUFR or CREX message.
Definition: bulletin.h:29
void dump_jsonl(const Bulletin &bulletin, std::stringstream &out)
Dump a bulletin to a simple but deterministic JSON line.
Base class for DB-All.e exceptions.
Definition: error.h:60
std::filesystem::path path_from_env(const char *varname, const char *deflt=nullptr)
Return a path from an envirnment variable.
Definition: benchmark.h:13
Implement fast access to information about WMO variables.
std::string slurpfile(const std::filesystem::path &name)
Read the entire contents of a test file into a string.
std::filesystem::path datafile(const std::filesystem::path &fname)
Return the pathname of a test file.