1 #include <wreport/tests.h> 2 #include <dballe/file.h> 3 #include <dballe/record.h> 4 #include <dballe/core/query.h> 25 static inline int rnd(
int min,
int max)
27 return min + (int) ((max - min) * (rand() / (RAND_MAX + 1.0)));
30 static inline double rnd(
double min,
double max)
32 return min + (int) ((max - min) * (rand() / (RAND_MAX + 1.0)));
35 static inline std::string rnd(
int len)
38 int max = rnd(1, len);
39 for (
int i = 0; i < max; i++)
40 res += (
char)rnd(
'a',
'z');
44 static inline bool rnd(
double prob)
46 return (rnd(0, 100) < prob*100) ?
true :
false;
53 std::string datafile(
const std::string& fname);
55 std::unique_ptr<File> open_test_data(
const char* filename,
File::Encoding type);
57 BinaryMessage read_rawmsg(
const char* filename,
File::Encoding type);
62 std::stringstream buf;
66 buf << row << std::endl;
72 struct TestRecordValEqual
78 bool with_missing_int;
81 : actual(actual), expected(expected), name(name), with_missing_int(with_missing_int) {}
86 struct TestRecordVarsEqual
103 TestRecordValEqual equals(
const Record& expected,
const char* name) {
return TestRecordValEqual(this->actual, expected, name); }
104 TestRecordValEqual equals_with_missing_int(
const Record& expected,
const char* name)
106 return TestRecordValEqual(this->actual, expected, name,
true);
109 void vars_equal(
const Record& expected)
const { vars_equal(
Values(expected)); }
112 void vars_equal(
const Values& expected)
const;
116 void set_record_from_string(
Record& rec,
const std::string& s);
117 std::unique_ptr<Record> record_from_string(
const std::string& s);
118 std::unique_ptr<Query> query_from_string(
const std::string& s);
119 core::Query core_query_from_string(
const std::string& s);
123 using Actual::Actual;
125 void operator==(
int expected)
const;
126 void operator!=(
int expected)
const;
131 using wreport::tests::actual;
Encoding
Supported encodings.
Definition: file.h:20
Key/value store where keys are strings and values are wreport variables.
Definition: record.h:16
Ostream output for dballe/core objects.
Standard dballe::Query implementation.
Definition: core/query.h:29
Copyright (C) 2008–2010 ARPA-SIM urpsim@smr.arpa.emr.it
Definition: cmdline.h:17
A station identifier, that can be any string (including the empty string) or a missing value...
Definition: core/defs.h:19
Routines to parse data in CSV format.
Definition: core/tests.h:98
Definition: core/tests.h:121
Structures used as input to database insert functions.
Collection of Value objects, indexed by wreport::Varcode.
Definition: values.h:202
void flush_row() override
Write the current line to the output file, and start a new one.
Definition: core/tests.h:64
Definition: core/tests.h:59