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>
42std::filesystem::path datafile(
const std::filesystem::path& fname);
52std::filesystem::path path_from_env(
const char* varname,
const char* deflt =
nullptr);
59std::string slurpfile(
const std::filesystem::path& name);
64std::vector<std::filesystem::path> all_test_files(
const std::string& encoding);
66void track_bulletin(Bulletin& b,
const char* tag,
const std::filesystem::path& fname);
68template<
typename BULLETIN>
69std::unique_ptr<BULLETIN> decode_checked(
const std::string& buf,
const char* name)
72 return BULLETIN::decode(buf, name);
75 auto h = BULLETIN::decode_header(buf, name);
76 h->print_structured(stderr);
78 std::cerr <<
"Dump interrupted: " << e.
what();
84template<
typename BULLETIN>
85std::unique_ptr<BULLETIN> decode_checked(
const std::string& buf,
const char* name, FILE* verbose)
88 return BULLETIN::decode_verbose(buf, verbose, name);
91 auto h = BULLETIN::decode_header(buf, name);
92 h->print_structured(stderr);
94 std::cerr <<
"Dump interrupted: " << e2.
what();
100template<
typename BULLETIN>
103 std::filesystem::path fname;
104 std::function<void(
const BULLETIN&)> check_contents = [](
const BULLETIN&)
noexcept {};
106 explicit TestCodec(
const std::filesystem::path& fname) : fname(fname) {}
112void assert_var_equal(
const Var& actual,
const Var& expected);
113void assert_var_not_equal(
const Var& actual,
const Var& expected);
114template<
typename Val>
115void assert_var_value_equal(
const Var& actual, Val expected);
116template<
typename Val>
117void assert_var_value_not_equal(
const Var& actual, Val expected);
124 void operator==(
const Var& expected)
const { assert_var_equal(_actual, expected); }
125 void operator!=(
const Var& expected)
const { assert_var_not_equal(_actual, expected); }
126 template<
typename Val>
127 void operator==(Val expected)
const { assert_var_value_equal(_actual, expected); }
128 template<
typename Val>
129 void operator!=(Val expected)
const { assert_var_value_not_equal(_actual, expected); }
131 void isunset()
const;
138 using Actual::Actual;
140 void operator==(
Varcode expected)
const;
141 void operator!=(
Varcode expected)
const;
A physical variable.
Definition var.h:25
Report an error when parsing informations.
Definition error.h:202
Base class for DB-All.e exceptions.
Definition error.h:60
const char * what() const noexcept override=0
Error message.
String functions.
Definition benchmark.h:13
uint16_t Varcode
Holds the WMO variable code of a variable.
Definition fwd.h:12
Definition utils/tests.h:320
Implement fast access to information about WMO variables.