1#include <wreport/tests.h>
2#include <dballe/file.h>
4#include <dballe/core/query.h>
18using namespace wreport::tests;
23static inline int rnd(
int min,
int max)
25 return min + (int) ((max - min) * (rand() / (RAND_MAX + 1.0)));
28static inline double rnd(
double min,
double max)
30 return min + (int) ((max - min) * (rand() / (RAND_MAX + 1.0)));
33static inline std::string rnd(
int len)
36 int max = rnd(1, len);
37 for (
int i = 0; i < max; i++)
38 res += (
char)rnd(
'a',
'z');
42static inline bool rnd(
double prob)
44 return (rnd(0, 100) < prob*100) ? true :
false;
51std::string datafile(
const std::string& fname);
53std::unique_ptr<File> open_test_data(
const char* filename, Encoding type);
55BinaryMessage read_rawmsg(
const char* filename, Encoding type);
60 std::stringstream buf;
64 buf << row << std::endl;
71struct TestRecordValEqual
73 const dballe::Record& actual;
74 const dballe::Record& expected;
76 bool with_missing_int;
78 TestRecordValEqual(
const dballe::Record& actual,
const dballe::Record& expected,
const char* name,
bool with_missing_int=
false)
79 : actual(actual), expected(expected), name(name), with_missing_int(with_missing_int) {}
84struct TestRecordVarsEqual
86 const dballe::Record& actual;
89 TestRecordVarsEqual(
const dballe::Record& actual,
const dballe::Record& expected) : actual(actual), expected(expected) {}
90 TestRecordVarsEqual(
const dballe::Record& actual,
const dballe::Values& expected) : actual(actual), expected(expected) {}
97std::unique_ptr<Query> query_from_string(
const std::string& s);
98core::Query core_query_from_string(
const std::string& s);
102 using Actual::Actual;
104 void operator==(
int expected)
const;
105 void operator!=(
int expected)
const;
110using 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:58
void flush_row() override
Write the current line to the output file, and start a new one.
Definition: core/tests.h:62
Routines to parse data in CSV format.
Collection of Value objects, indexed by wreport::Varcode.
Definition: values.h:177
Definition: core/tests.h:101
Structures used as input to database insert functions.