1 #include <wreport/tests.h> 2 #include <dballe/file.h> 4 #include <dballe/core/query.h> 24 static inline int rnd(
int min,
int max)
26 return min + (int) ((max - min) * (rand() / (RAND_MAX + 1.0)));
29 static inline double rnd(
double min,
double max)
31 return min + (int) ((max - min) * (rand() / (RAND_MAX + 1.0)));
34 static inline std::string rnd(
int len)
37 int max = rnd(1, len);
38 for (
int i = 0; i < max; i++)
39 res += (
char)rnd(
'a',
'z');
43 static inline bool rnd(
double prob)
45 return (rnd(0, 100) < prob*100) ? true :
false;
52 std::filesystem::path datafile(
const std::string& fname);
54 std::unique_ptr<File> open_test_data(
const char* filename, Encoding type);
56 BinaryMessage read_rawmsg(
const char* filename, Encoding type);
61 std::stringstream buf;
65 buf << row << std::endl;
71 struct TestRecordValEqual
74 const dballe::Record& actual;
75 const dballe::Record& expected;
77 bool with_missing_int;
79 TestRecordValEqual(
const dballe::Record& actual,
const dballe::Record& expected,
const char* name,
bool with_missing_int=
false)
80 : actual(actual), expected(expected), name(name), with_missing_int(with_missing_int) {}
85 struct TestRecordVarsEqual
87 const dballe::Record& actual;
90 TestRecordVarsEqual(
const dballe::Record& actual,
const dballe::Record& expected) : actual(actual), expected(expected) {}
91 TestRecordVarsEqual(
const dballe::Record& actual,
const dballe::Values& expected) : actual(actual), expected(expected) {}
98 std::unique_ptr<Query> query_from_string(
const std::string& s);
99 core::Query core_query_from_string(
const std::string& s);
103 using Actual::Actual;
105 void operator==(
int expected)
const;
106 void operator!=(
int expected)
const;
111 using wreport::tests::actual;
A station identifier, that can be any string (including the empty string) or a missing value...
Definition: types.h:747
Routines to parse data in CSV format.
Definition: core/tests.h:101
Structures used as input to database insert functions.
Collection of Value objects, indexed by wreport::Varcode.
Definition: values.h:176
void flush_row() override
Write the current line to the output file, and start a new one.
Definition: core/tests.h:63
Definition: core/tests.h:58