8 #ifndef TEST_INTERFACE_GEOVALS_H_
9 #define TEST_INTERFACE_GEOVALS_H_
16 #define ECKIT_TESTING_SELF_REGISTER_CASES 0
18 #include <boost/noncopyable.hpp>
20 #include "eckit/config/LocalConfiguration.h"
21 #include "eckit/testing/Test.h"
28 #include "oops/util/dot_product.h"
29 #include "oops/util/Logger.h"
38 typedef ObsTestsFixture<OBS> Test_;
41 for (std::size_t jj = 0; jj < Test_::obspace().size(); ++jj) {
42 eckit::LocalConfiguration gconf(Test_::config(jj),
"geovals");
44 std::unique_ptr<GeoVaLs_> geovals(
new GeoVaLs_(gconf, Test_::obspace()[jj], geovars));
45 EXPECT(geovals.get());
46 oops::Log::test() <<
"Testing GeoVaLs: " << *geovals << std::endl;
48 EXPECT(!geovals.get());
58 const double tol = 1e-6;
60 for (std::size_t jj = 0; jj < Test_::obspace().size(); ++jj) {
61 eckit::LocalConfiguration gconf(Test_::config(jj),
"geovals");
63 GeoVaLs_ gval(gconf, Test_::obspace()[jj], geovars);
65 const double zz = dot_product(gval, gval);
67 oops::Log::trace() <<
"Testing copy constructor (=) " << std::endl;
69 GeoVaLs_ gval2 = gval;
71 double zz0 = dot_product(gval2, gval2);
75 oops::Log::trace() <<
"Testing *= double" << std::endl;
79 const double zz1 = dot_product(gval2, gval2);
81 EXPECT(zz1/zz - 4.0 < tol);
83 oops::Log::trace() <<
"Testing += GeoVals" << std::endl;
87 const double zz2 = dot_product(gval2, gval2);
89 EXPECT(zz2/zz - 9.0 < tol);
91 oops::Log::trace() <<
"Testing -= GeoVals" << std::endl;
95 const double zz3 = dot_product(gval2, gval2);
97 EXPECT(zz3/zz - 4.0 < tol);
99 oops::Log::trace() <<
"Testing *= GeoVals" << std::endl;
105 GeoVaLs_ gval3 = gval2;
109 const double zz4 = dot_product(gval2, gval2);
111 const double zz5 = dot_product(gval3, gval);
113 EXPECT(zz4/zz5 - 1.0 < tol);
115 oops::Log::trace() <<
"Testing random" << std::endl;
118 const double zz6 = dot_product(gval, gval);
121 oops::Log::trace() <<
"Testing zero" << std::endl;
124 const double zz7 = dot_product(gval, gval);
135 const double tol = 1.0e-9;
136 for (std::size_t jj = 0; jj < Test_::obspace().size(); ++jj) {
137 eckit::LocalConfiguration gconf(Test_::config(jj),
"geovals");
139 GeoVaLs_ gval(gconf, Test_::obspace()[jj], geovars);
141 const double xx = gconf.getDouble(
"norm");
142 const double zz = sqrt(dot_product(gval, gval));
144 oops::Log::debug() <<
"xx: " << std::fixed << std::setprecision(8) << xx << std::endl;
145 oops::Log::debug() <<
"zz: " << std::fixed << std::setprecision(8) << zz << std::endl;
147 EXPECT(oops::is_close(xx, zz, tol));
153 template <
typename OBS>
160 std::string
testid()
const override {
return "test::GeoVaLs<" + OBS::name() +
">";}
163 std::vector<eckit::testing::Test>& ts = eckit::testing::specification();
165 ts.emplace_back(
CASE(
"interface/GeoVaLs/testConstructor")
166 { testConstructor<OBS>(); });
167 ts.emplace_back(
CASE(
"interface/GeoVaLs/testUtils")
168 { testUtils<OBS>(); });
169 ts.emplace_back(
CASE(
"interface/GeoVaLs/testRead")
170 { testRead<OBS>(); });
std::string testid() const override
void clear() const override
void register_tests() const override
ObsTestsFixture< OBS > Test_
CASE("test_linearmodelparameterswrapper_valid_name")
void testConstructor()
Tests creation and destruction of ObsErrorCovariances.