1 #include <dballe/core/tests.h> 2 #include <dballe/message.h> 3 #include <dballe/importer.h> 4 #include <dballe/exporter.h> 5 #include <dballe/msg/msg.h> 16 impl::Messages read_msgs(
const char* filename, Encoding type,
const std::string& opts);
17 impl::Messages read_msgs_csv(
const char* filename);
28 std::unique_ptr<wreport::Bulletin> export_msgs(Encoding enctype,
const impl::Messages& in,
const std::string& tag,
const dballe::ExporterOptions& opts=dballe::ExporterOptions::defaults);
29 #define test_export_msgs(...) wcallchecked(export_msgs(__VA_ARGS__)) 31 void track_different_msgs(
const Message& msg1,
const Message& msg2,
const std::string& prefix);
32 void track_different_msgs(
const impl::Messages& msgs1,
const impl::Messages& msgs2,
const std::string& prefix);
34 extern const char* bufr_files[];
35 extern const char* crex_files[];
43 void dump(
const std::string& tag,
const Message& msg,
const std::string& desc=
"message");
44 void dump(
const std::string& tag,
const impl::Message& msg,
const std::string& desc);
45 void dump(
const std::string& tag,
const impl::Messages& msgs,
const std::string& desc=
"message");
46 void dump(
const std::string& tag,
const wreport::Bulletin& bul,
const std::string& desc=
"message");
47 void dump(
const std::string& tag,
const BinaryMessage& msg,
const std::string& desc=
"message");
48 void dump(
const std::string& tag,
const std::string& str,
const std::string& desc=
"message");
53 virtual void tweak(impl::Messages&) {}
54 virtual std::string desc()
const = 0;
59 std::vector<MessageTweaker*> tweaks;
64 void apply(impl::Messages& msgs);
72 std::vector<wreport::Varcode> codes;
74 void tweak(impl::Messages& msgs)
override;
75 std::string desc()
const override {
return "StripAttrs"; }
82 std::string desc()
const override {
return "StripQCAttrs"; }
88 void tweak(impl::Messages& msgs)
override;
89 std::string desc()
const override {
return "StripSubstituteAttrs"; }
96 std::string desc()
const override {
return "StripContextAttrs"; }
102 std::vector<wreport::Varcode> codes;
105 StripVars(std::initializer_list<wreport::Varcode> codes) : codes(codes) {}
106 void tweak(impl::Messages& msgs)
override;
107 std::string desc()
const override {
return "StripVars"; }
115 void tweak(impl::Messages& msgs)
override;
116 std::string desc()
const override {
return "RoundLegacyVars"; }
122 void tweak(impl::Messages& msgs)
override;
123 std::string desc()
const override {
return "RemoveSynopWMOOnlyVars"; }
129 void tweak(impl::Messages& msgs)
override;
130 std::string desc()
const override {
return "RemoveTempWMOOnlyVars"; }
138 std::string desc()
const override {
return "RemoveOddTempTemplateOnlyVars"; }
145 void tweak(impl::Messages& msgs)
override;
146 std::string desc()
const override {
return "RemoveSynopWMOOddprec"; }
152 void tweak(impl::Messages& msgs)
override;
153 std::string desc()
const override {
return "TruncStName"; }
161 void tweak(impl::Messages& msgs)
override;
162 std::string desc()
const override {
return "RoundGeopotential"; }
170 void tweak(impl::Messages& msgs)
override;
171 std::string desc()
const override {
return "HeightToGeopotential"; }
177 void tweak(impl::Messages& msgs)
override;
178 std::string desc()
const override {
return "RoundVSS"; }
187 void tweak(impl::Messages& msgs)
override;
188 std::string desc()
const override {
return "RemoveContext"; }
201 TestMessage(Encoding type,
const std::string& name);
204 void read_from_file(
const std::string& fname,
const ImporterOptions& input_opts);
206 void read_from_msgs(
const impl::Messages& msgs,
const ExporterOptions& export_opts);
214 bool verbose =
false;
217 std::string expected_template;
218 int expected_subsets = 1;
219 int expected_min_vars = 1;
220 int expected_data_category = MISSING_INT;
221 int expected_data_subcategory = MISSING_INT;
222 int expected_data_subcategory_local = MISSING_INT;
230 explicit TestCodec(
const std::string& fname, Encoding type=Encoding::BUFR);
232 void configure_ecmwf_to_wmo_tweaks();
238 void run_convert(
const std::string& tplname);
246 class msg_generator :
public generator
249 dba_err fill_message(dba_msg msg,
bool mobile);
255 class msg_vector :
public dba_raw_consumer,
public std::vector<dba_msgs>
258 virtual ~msg_vector()
260 for (iterator i = begin(); i != end(); i++)
264 virtual dba_err consume(dba_rawmsg raw)
268 DBA_RUN_OR_RETURN(dba_marshal_decode(raw, &msgs));
271 return dba_error_ok();
275 template <
typename T>
276 void my_ensure_msg_equals(
const char* file,
int line, dba_msg msg,
int id,
const char* idname,
const T& value)
278 dba_var var = my_want_var(file, line, msg,
id, idname);
279 inner_ensure_var_equals(var, value);
281 #define gen_ensure_msg_equals(msg, id, value) my_ensure_msg_equals(__FILE__, __LINE__, (msg), (id), #id, (value)) 282 #define inner_ensure_msg_equals(msg, id, value) my_ensure_msg_equals(file, line, (msg), (id), #id, (value)) Definition: msg/tests.h:135
Binary message.
Definition: file.h:130
Definition: msg/tests.h:86
Definition: msg/tests.h:100
Definition: msg/tests.h:150
Definition: msg/tests.h:193
Definition: msg/tests.h:210
Information on how a value has been sampled or computed with regards to time.
Definition: types.h:686
Definition: msg/tests.h:70
Options to control message export.
Definition: exporter.h:24
Definition: msg/tests.h:182
Definition: msg/tests.h:93
Options to control message import.
Definition: importer.h:24
Definition: msg/tests.h:143
Vertical level or layer.
Definition: types.h:624
Definition: msg/tests.h:175
Definition: msg/tests.h:120
Definition: msg/tests.h:166
A bulletin that has been decoded and physically interpreted.
Definition: message.h:28
Definition: msg/tests.h:57
Definition: msg/tests.h:50
Definition: msg/tests.h:19
ImporterOptions with default constructor usable.
Definition: msg.h:25
Definition: shortcuts.h:11
static const ImporterOptions defaults
Default importer options.
Definition: importer.h:54
Definition: msg/tests.h:79
Definition: msg/tests.h:111
Definition: msg/tests.h:127
ExporterOptions with default constructor usable.
Definition: msg.h:38
Definition: msg/tests.h:157