11 #ifndef TEST_INTERFACE_STATE_H_ 12 #define TEST_INTERFACE_STATE_H_ 19 #define BOOST_TEST_NO_MAIN 20 #define BOOST_TEST_ALTERNATIVE_INIT_API 21 #define BOOST_TEST_DYN_LINK 23 #include <boost/test/unit_test.hpp> 25 #include <boost/noncopyable.hpp> 26 #include <boost/scoped_ptr.hpp> 28 #include "eckit/config/LocalConfiguration.h" 33 #include "oops/util/DateTime.h" 34 #include "oops/util/dot_product.h" 35 #include "oops/util/Logger.h" 42 template <
typename MODEL>
class StateFixture :
private boost::noncopyable {
53 return theStateFixture;
65 boost::scoped_ptr<const eckit::LocalConfiguration>
test_;
75 const double norm =
Test_::test().getDouble(
"norm-file");
82 boost::scoped_ptr<State_> xx1(
new State_(Test_::resol(),
vars,
conf));
84 BOOST_CHECK(xx1.get());
85 const double norm1 = xx1->norm();
86 BOOST_CHECK_CLOSE(norm1, norm,
tol);
87 BOOST_CHECK_EQUAL(xx1->validTime(),
vt);
90 boost::scoped_ptr<State_> xx2(
new State_(*xx1));
91 BOOST_CHECK(xx2.get());
92 BOOST_CHECK_CLOSE(xx2->norm(), norm,
tol);
93 BOOST_CHECK_EQUAL(xx2->validTime(),
vt);
97 BOOST_CHECK(!xx2.get());
100 const double norm2 = xx1->norm();
101 BOOST_CHECK_EQUAL(norm1, norm2);
148 const eckit::LocalConfiguration confgen(
Test_::test(),
"StateGenerate");
150 const State_ xx(Test_::resol(), statevars, confgen);
151 const double norm =
Test_::test().getDouble(
"norm-gen");
153 BOOST_CHECK_CLOSE(xx.norm(), norm,
tol);
157 if (!confgen.has(
"analytic_init")) {
165 const eckit::LocalConfiguration confloc(
Test_::test(),
"Locations");
166 const Locations_ locs(confloc);
171 const eckit::LocalConfiguration confvar(
Test_::test(),
"InterpTest");
175 GeoVaLs_ gval(locs,
vars);
178 xx.getValues(locs,
vars, gval);
183 ref.analytic_init(locs, confgen);
193 double interp_tol =
Test_::test().getDouble(
"interp_tolerance");
194 BOOST_CHECK_SMALL(gval.norm(), interp_tol);
204 << std::endl << gval << std::endl;
208 << std::endl << locs << std::endl;
221 boost::unit_test::test_suite * ts = BOOST_TEST_SUITE(
"interface/State");
223 ts->add(BOOST_TEST_CASE(&testStateConstructors<MODEL>));
224 ts->add(BOOST_TEST_CASE(&testStateInterpolation<MODEL>));
226 boost::unit_test::framework::master_test_suite().add(ts);
234 #endif // TEST_INTERFACE_STATE_H_
integer, parameter, public warning
boost::scoped_ptr< const eckit::LocalConfiguration > test_
std::string testid() const
Encapsulates the model state.
static const eckit::Configuration & config()
static const eckit::Configuration & test()
real, dimension(:,:,:), allocatable vt
static const Geometry_ & resol()
void testStateConstructors()
void testStateInterpolation()
Interpolation test.
oops::State< MODEL > State_
oops::Geometry< MODEL > Geometry_
static StateFixture< MODEL > & getInstance()
void register_tests() const
boost::scoped_ptr< Geometry_ > resol_