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>
41std::string datafile(
const std::string& fname);
48std::string slurpfile(
const std::string& name);
53std::vector<std::string> all_test_files(
const std::string& encoding);
55void track_bulletin(Bulletin& b,
const char* tag,
const char* fname);
57template<
typename BULLETIN>
58std::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();
73template<
typename BULLETIN>
74std::unique_ptr<BULLETIN> decode_checked(
const std::string& buf,
const char* name, FILE* verbose)
77 return BULLETIN::decode_verbose(buf, verbose, name);
80 auto h = BULLETIN::decode_header(buf, name);
81 h->print_structured(stderr);
83 std::cerr <<
"Dump interrupted: " << e.
what();
89template<
typename BULLETIN>
93 std::function<void(
const BULLETIN&)> check_contents = [](
const BULLETIN&) {};
95 TestCodec(
const std::string& fname) : fname(fname) {}
101void assert_var_equal(
const Var& actual,
const Var& expected);
102void assert_var_not_equal(
const Var& actual,
const Var& expected);
103template<
typename Val>
104void assert_var_value_equal(
const Var& actual, Val expected);
105template<
typename Val>
106void assert_var_value_not_equal(
const Var& actual, Val expected);
113 void operator==(
const Var& expected)
const { assert_var_equal(_actual, expected); }
114 void operator!=(
const Var& expected)
const { assert_var_not_equal(_actual, expected); }
115 template<
typename Val>
116 void operator==(Val expected)
const { assert_var_value_equal(_actual, expected); }
117 template<
typename Val>
118 void operator!=(Val expected)
const { assert_var_value_not_equal(_actual, expected); }
120 void isunset()
const;
127 using Actual::Actual;
129 void operator==(
Varcode expected)
const;
130 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
virtual const char * what() const noexcept=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:318
Implement fast access to information about WMO variables.