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>
16impl::Messages read_msgs(
const char* filename, Encoding type,
const std::string& opts);
17impl::Messages read_msgs_csv(
const char* filename);
28std::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__))
31void track_different_msgs(
const Message& msg1,
const Message& msg2,
const std::string& prefix);
32void track_different_msgs(
const impl::Messages& msgs1,
const impl::Messages& msgs2,
const std::string& prefix);
34extern const char* bufr_files[];
35extern const char* crex_files[];
43void dump(
const std::string& tag,
const Message& msg,
const std::string& desc=
"message");
44void dump(
const std::string& tag,
const impl::Message& msg,
const std::string& desc);
45void dump(
const std::string& tag,
const impl::Messages& msgs,
const std::string& desc=
"message");
46void dump(
const std::string& tag,
const wreport::Bulletin& bul,
const std::string& desc=
"message");
47void dump(
const std::string& tag,
const BinaryMessage& msg,
const std::string& desc=
"message");
48void 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"; }
135struct RemoveOddTempTemplateOnlyVars :
public StripVars
137 RemoveOddTempTemplateOnlyVars();
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"; }
169 HeightToGeopotential();
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);
246class msg_generator :
public generator
249 dba_err fill_message(dba_msg msg,
bool mobile);
255class 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();
276void 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))
Binary message.
Definition file.h:131
Options to control message export.
Definition exporter.h:25
Options to control message import.
Definition importer.h:25
static const ImporterOptions defaults
Default importer options.
Definition importer.h:54
A bulletin that has been decoded and physically interpreted.
Definition message.h:29
Vertical level or layer.
Definition types.h:625
Information on how a value has been sampled or computed with regards to time.
Definition types.h:687
ExporterOptions with default constructor usable.
Definition msg.h:39
ImporterOptions with default constructor usable.
Definition msg.h:26
Definition shortcuts.h:12
Definition msg/tests.h:20
Definition msg/tests.h:51
Definition msg/tests.h:58
Definition msg/tests.h:194
Definition msg/tests.h:144
Definition msg/tests.h:121
Definition msg/tests.h:128
Definition msg/tests.h:176
Definition msg/tests.h:71
Definition msg/tests.h:87
Definition msg/tests.h:151