1 #include <dballe/core/tests.h> 2 #include <dballe/exporter.h> 3 #include <dballe/importer.h> 4 #include <dballe/message.h> 5 #include <dballe/msg/msg.h> 15 impl::Messages read_msgs(
16 const char* filename, Encoding type,
18 impl::Messages read_msgs(
const char* filename, Encoding type,
19 const std::string& opts);
20 impl::Messages read_msgs_csv(
const char* filename);
34 std::unique_ptr<wreport::Bulletin> export_msgs(
35 Encoding enctype,
const impl::Messages& in,
const std::string& tag,
37 #define test_export_msgs(...) wcallchecked(export_msgs(__VA_ARGS__)) 39 void track_different_msgs(
const Message& msg1,
const Message& msg2,
40 const std::string& prefix);
41 void track_different_msgs(
const impl::Messages& msgs1,
42 const impl::Messages& msgs2,
43 const std::string& prefix);
45 extern const char* bufr_files[];
46 extern const char* crex_files[];
54 inline ActualVar actual_var(
const Message& message,
57 return ActualVar(want_var(message, shortcut));
59 inline ActualVar actual_var(
const Message& message, wreport::Varcode code,
62 return ActualVar(want_var(message, code, lev, tr));
65 void dump(
const std::string& tag,
const Message& msg,
66 const std::string& desc =
"message");
67 void dump(
const std::string& tag,
const impl::Message& msg,
68 const std::string& desc);
69 void dump(
const std::string& tag,
const impl::Messages& msgs,
70 const std::string& desc =
"message");
72 const std::string& desc =
"message");
73 void dump(
const std::string& tag,
const BinaryMessage& msg,
74 const std::string& desc =
"message");
75 void dump(
const std::string& tag,
const std::string& str,
76 const std::string& desc =
"message");
81 virtual void tweak(impl::Messages&) {}
82 virtual std::string desc()
const = 0;
87 std::vector<MessageTweaker*> tweaks;
92 void apply(impl::Messages& msgs);
100 std::vector<wreport::Varcode> codes;
102 void tweak(impl::Messages& msgs)
override;
103 std::string desc()
const override {
return "StripAttrs"; }
110 std::string desc()
const override {
return "StripQCAttrs"; }
116 void tweak(impl::Messages& msgs)
override;
117 std::string desc()
const override {
return "StripSubstituteAttrs"; }
124 std::string desc()
const override {
return "StripContextAttrs"; }
130 std::vector<wreport::Varcode> codes;
133 StripVars(std::initializer_list<wreport::Varcode> codes) : codes(codes) {}
134 void tweak(impl::Messages& msgs)
override;
135 std::string desc()
const override {
return "StripVars"; }
143 void tweak(impl::Messages& msgs)
override;
144 std::string desc()
const override {
return "RoundLegacyVars"; }
150 void tweak(impl::Messages& msgs)
override;
151 std::string desc()
const override {
return "RemoveSynopWMOOnlyVars"; }
157 void tweak(impl::Messages& msgs)
override;
158 std::string desc()
const override {
return "RemoveTempWMOOnlyVars"; }
166 std::string desc()
const override 168 return "RemoveOddTempTemplateOnlyVars";
176 void tweak(impl::Messages& msgs)
override;
177 std::string desc()
const override {
return "RemoveSynopWMOOddprec"; }
183 void tweak(impl::Messages& msgs)
override;
184 std::string desc()
const override {
return "TruncStName"; }
192 void tweak(impl::Messages& msgs)
override;
193 std::string desc()
const override {
return "RoundGeopotential"; }
202 void tweak(impl::Messages& msgs)
override;
203 std::string desc()
const override {
return "HeightToGeopotential"; }
209 void tweak(impl::Messages& msgs)
override;
210 std::string desc()
const override {
return "RoundVSS"; }
219 void tweak(impl::Messages& msgs)
override;
220 std::string desc()
const override {
return "RemoveContext"; }
233 TestMessage(Encoding type,
const std::string& name);
236 void read_from_file(
const std::string& fname,
240 void read_from_msgs(
const impl::Messages& msgs,
249 bool verbose =
false;
252 std::string expected_template;
253 int expected_subsets = 1;
254 int expected_min_vars = 1;
255 int expected_data_category = MISSING_INT;
256 int expected_data_subcategory = MISSING_INT;
257 int expected_data_subcategory_local = MISSING_INT;
265 explicit TestCodec(
const std::string& fname,
266 Encoding type = Encoding::BUFR);
268 void configure_ecmwf_to_wmo_tweaks();
274 void run_convert(
const std::string& tplname);
281 class msg_generator :
public generator
284 dba_err fill_message(dba_msg msg,
bool mobile);
290 class msg_vector :
public dba_raw_consumer,
public std::vector<dba_msgs>
293 virtual ~msg_vector()
295 for (iterator i = begin(); i != end(); i++)
299 virtual dba_err consume(dba_rawmsg raw)
303 DBA_RUN_OR_RETURN(dba_marshal_decode(raw, &msgs));
306 return dba_error_ok();
310 template <
typename T>
311 void my_ensure_msg_equals(
const char* file,
int line, dba_msg msg,
int id,
const char* idname,
const T& value)
313 dba_var var = my_want_var(file, line, msg,
id, idname);
314 inner_ensure_var_equals(var, value);
316 #define gen_ensure_msg_equals(msg, id, value) \ 317 my_ensure_msg_equals(__FILE__, __LINE__, (msg), (id), #id, (value)) 318 #define inner_ensure_msg_equals(msg, id, value) \ 319 my_ensure_msg_equals(file, line, (msg), (id), #id, (value))
Definition: msg/tests.h:163
Binary message.
Definition: file.h:134
Definition: msg/tests.h:114
Definition: msg/tests.h:128
Definition: msg/tests.h:181
Definition: msg/tests.h:225
Information on how a value has been sampled or computed with regards to time.
Definition: types.h:688
Definition: msg/tests.h:98
Options to control message export.
Definition: exporter.h:24
Definition: msg/tests.h:214
Definition: msg/tests.h:121
Options to control message import.
Definition: importer.h:24
Definition: msg/tests.h:174
Vertical level or layer.
Definition: types.h:624
Definition: msg/tests.h:207
Definition: msg/tests.h:148
Definition: msg/tests.h:198
A bulletin that has been decoded and physically interpreted.
Definition: message.h:28
Definition: msg/tests.h:85
Definition: msg/tests.h:78
Definition: msg/tests.h:22
ImporterOptions with default constructor usable.
Definition: msg.h:25
Definition: shortcuts.h:11
static const ImporterOptions defaults
Default importer options.
Definition: importer.h:52
Definition: msg/tests.h:107
Definition: msg/tests.h:139
Definition: msg/tests.h:155
ExporterOptions with default constructor usable.
Definition: msg.h:38
Definition: msg/tests.h:188