1#include <wreport/tests.h>
2#include <dballe/file.h>
4#include <dballe/core/query.h>
19using namespace wreport::tests;
24static inline int rnd(
int min,
int max)
26 return min + (int) ((max - min) * (rand() / (RAND_MAX + 1.0)));
29static inline double rnd(
double min,
double max)
31 return min + (int) ((max - min) * (rand() / (RAND_MAX + 1.0)));
34static 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');
43static inline bool rnd(
double prob)
45 return (rnd(0, 100) < prob*100) ? true :
false;
52std::filesystem::path datafile(
const std::string& fname);
54std::unique_ptr<File> open_test_data(
const char* filename, Encoding type);
56BinaryMessage read_rawmsg(
const char* filename, Encoding type);
61 std::stringstream buf;
65 buf << row << std::endl;
72struct 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) {}
85struct 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) {}
98std::unique_ptr<Query> query_from_string(
const std::string& s);
99core::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;
111using wreport::tests::actual;
A station identifier, that can be any string (including the empty string) or a missing value.
Definition types.h:748
Definition core/tests.h:59
void flush_row() override
Write the current line to the output file, and start a new one.
Definition core/tests.h:63
Routines to parse data in CSV format.
Collection of Value objects, indexed by wreport::Varcode.
Definition values.h:177
Definition core/tests.h:102
Structures used as input to database insert functions.