8 #ifndef TEST_IODA_OBSDATAVECTOR_H_
9 #define TEST_IODA_OBSDATAVECTOR_H_
15 #include <boost/make_unique.hpp>
17 #include "eckit/config/LocalConfiguration.h"
18 #include "eckit/testing/Test.h"
20 #include "oops/mpi/mpi.h"
21 #include "oops/runs/Test.h"
22 #include "oops/test/TestEnvironment.h"
39 return theObsDataVecTestFixture;
43 const eckit::Configuration &conf = ::test::TestEnvironment::config();
44 const util::DateTime bgn(conf.getString(
"window begin"));
45 const util::DateTime end(conf.getString(
"window end"));
47 eckit::LocalConfiguration obsconf(conf,
"obs space");
49 obsparams.validateAndDeserialize(obsconf);
50 obspace_ = boost::make_unique<ObsSpace_>(obsparams, oops::mpi::world(),
51 bgn, end, oops::mpi::myself());
57 std::string
trim(
const std::string & str) {
58 const auto strBegin = str.find_first_not_of(
"\n");
59 if (strBegin == std::string::npos)
return "";
60 const auto strEnd = str.find_last_not_of(
"\n");
61 const auto strRange = strEnd - strBegin + 1;
62 return str.substr(strBegin, strRange);
68 eckit::LocalConfiguration conf(::test::TestEnvironment::config(),
"print." + datatype);
71 for (
const std::string &var : conf.getStringVector(
"variables"))
73 const std::string group = conf.getString(
"group");
76 std::stringstream stream;
78 std::string output =
trim(stream.str());
79 std::string expectedOutput =
trim(conf.getString(
"expected output"));
80 EXPECT_EQUAL(output, expectedOutput);
83 CASE(
"ioda/ObsDataVector/printFloat") {
84 testPrint<float>(
"float");
87 CASE(
"ioda/ObsDataVector/printDouble") {
88 testPrint<double>(
"double");
91 CASE(
"ioda/ObsDataVector/printInt") {
92 testPrint<int>(
"int");
95 CASE(
"ioda/ObsDataVector/printString") {
96 testPrint<std::string>(
"string");
99 CASE(
"ioda/ObsDataVector/printDateTime") {
100 testPrint<util::DateTime>(
"datetime");
103 CASE(
"ioda/ObsDataVector/closeObsSpace") {
110 std::string
testid()
const override {
return "test::ObsDataVector<ioda::IodaTrait>";}
ObsDataVector<DATATYPE> handles vectors of data of type DATATYPE in observation space.
std::unique_ptr< ObsSpace_ > obspace_
static ObsDataVecTestFixture & getInstance()
static ObsSpace_ & obspace()
void register_tests() const override
void clear() const override
std::string testid() const override
CASE("Derived variable, unit conversion, and exception checking methods")
void testPrint(const std::string &datatype)
std::string trim(const std::string &str)