1 #include <wreport/tests.h> 2 #include <dballe/file.h> 4 #include <dballe/core/query.h> 23 static inline int rnd(
int min,
int max)
25 return min + (int) ((max - min) * (rand() / (RAND_MAX + 1.0)));
28 static inline double rnd(
double min,
double max)
30 return min + (int) ((max - min) * (rand() / (RAND_MAX + 1.0)));
33 static 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');
42 static inline bool rnd(
double prob)
44 return (rnd(0, 100) < prob*100) ? true :
false;
51 std::string datafile(
const std::string& fname);
53 std::unique_ptr<File> open_test_data(
const char* filename, Encoding type);
55 BinaryMessage read_rawmsg(
const char* filename, Encoding type);
60 std::stringstream buf;
64 buf << row << std::endl;
70 struct 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) {}
84 struct 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) {}
97 std::unique_ptr<Query> query_from_string(
const std::string& s);
98 core::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;
110 using wreport::tests::actual;
Standard dballe::Query implementation.
Definition: core/query.h:31
A station identifier, that can be any string (including the empty string) or a missing value...
Definition: types.h:744
Routines to parse data in CSV format.
Definition: core/tests.h:100
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:62
Definition: core/tests.h:57