8 #ifndef TEST_INTERFACE_GEOVALS_H_ 9 #define TEST_INTERFACE_GEOVALS_H_ 15 #define BOOST_TEST_NO_MAIN 16 #define BOOST_TEST_ALTERNATIVE_INIT_API 17 #define BOOST_TEST_DYN_LINK 18 #include <boost/test/unit_test.hpp> 20 #include <boost/noncopyable.hpp> 21 #include <boost/scoped_ptr.hpp> 23 #include "eckit/config/LocalConfiguration.h" 29 #include "oops/util/dot_product.h" 36 template <
typename MODEL>
48 return theGeoVaLsFixture;
61 boost::scoped_ptr<const util::DateTime>
tbgn_;
62 boost::scoped_ptr<const util::DateTime>
tend_;
74 for (std::size_t jj = 0; jj < Test_::obspace().size(); ++jj) {
75 ObsOperator_ hop(Test_::obspace()[jj]);
77 Locations_ locs(Test_::obspace()[jj].locations(Test_::tbgn(), Test_::tend()));
78 boost::scoped_ptr<GeoVaLs_> ov(
new GeoVaLs_(locs, hop.variables()));
79 BOOST_CHECK(ov.get());
82 BOOST_CHECK(!ov.get());
94 for (std::size_t jj = 0; jj < Test_::obspace().size(); ++jj) {
95 ObsOperator_ hop(Test_::obspace()[jj]);
97 Locations_ locs(Test_::obspace()[jj].locations(Test_::tbgn(), Test_::tend()));
98 GeoVaLs_ gval(locs, hop.variables());
101 const double zz1 = dot_product(gval, gval);
102 BOOST_CHECK(zz1 > 0.0);
105 const double zz2 = dot_product(gval, gval);
106 BOOST_CHECK_EQUAL(zz2, 0.0);
119 std::vector<eckit::LocalConfiguration>
conf;
120 obsconf.get(
"ObsTypes",
conf);
122 const double tol = 1.0e-8;
123 for (std::size_t jj = 0; jj < Test_::obspace().size(); ++jj) {
124 ObsOperator_ hop(Test_::obspace()[jj]);
126 eckit::LocalConfiguration gconf(
conf[jj],
"GeoVaLs");
127 Locations_ locs(Test_::obspace()[jj].locations(Test_::tbgn(), Test_::tend()));
129 GeoVaLs_ gval(gconf, hop.variables());
131 const double xx = gconf.getDouble(
"norm");
132 const double zz = sqrt(dot_product(gval, gval));
133 BOOST_CHECK_CLOSE(xx, zz,
tol);
147 boost::unit_test::test_suite * ts = BOOST_TEST_SUITE(
"interface/GeoVaLs");
149 ts->add(BOOST_TEST_CASE(&testConstructor<MODEL>));
151 ts->add(BOOST_TEST_CASE(&testRead<MODEL>));
153 boost::unit_test::framework::master_test_suite().add(ts);
161 #endif // TEST_INTERFACE_GEOVALS_H_ boost::scoped_ptr< const util::DateTime > tbgn_
void register_tests() const
boost::scoped_ptr< ObsSpaces_ > ospaces_
static const util::DateTime & tend()
static const eckit::Configuration & config()
static GeoVaLsFixture< MODEL > & getInstance()
oops::ObsSpaces< MODEL > ObsSpaces_
boost::scoped_ptr< const util::DateTime > tend_
static const util::DateTime & tbgn()
std::string testid() const
static ObsSpaces_ & obspace()