FV3 Bundle
test/interface/ModelAuxCovariance.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2009-2016 ECMWF.
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  * In applying this licence, ECMWF does not waive the privileges and immunities
7  * granted to it by virtue of its status as an intergovernmental organisation nor
8  * does it submit to any jurisdiction.
9  */
10 
11 #ifndef TEST_INTERFACE_MODELAUXCOVARIANCE_H_
12 #define TEST_INTERFACE_MODELAUXCOVARIANCE_H_
13 
14 #include <string>
15 
16 #define BOOST_TEST_NO_MAIN
17 #define BOOST_TEST_ALTERNATIVE_INIT_API
18 #define BOOST_TEST_DYN_LINK
19 #include <boost/test/unit_test.hpp>
20 
21 #include <boost/noncopyable.hpp>
22 #include <boost/scoped_ptr.hpp>
23 
24 #include "eckit/config/LocalConfiguration.h"
27 #include "oops/runs/Test.h"
28 #include "test/TestEnvironment.h"
29 
30 namespace test {
31 
32 // -----------------------------------------------------------------------------
33 template <typename MODEL> class ModelAuxCovarianceFixture : private boost::noncopyable {
36 
37  public:
38  static const eckit::Configuration & config() {return *getInstance().conf_;}
39  static const Geometry_ & resol() {return *getInstance().resol_;}
40 
41  private:
43  static ModelAuxCovarianceFixture<MODEL> theModelAuxCovarianceFixture;
44  return theModelAuxCovarianceFixture;
45  }
46 
48  conf_.reset(new eckit::LocalConfiguration(TestEnvironment::config(), "ModelBiasCovariance"));
49 
50  const eckit::LocalConfiguration resolConfig(TestEnvironment::config(), "Geometry");
51  resol_.reset(new Geometry_(resolConfig));
52  }
53 
55 
56  boost::scoped_ptr<const eckit::LocalConfiguration> conf_;
57  boost::scoped_ptr<Geometry_> resol_;
58 };
59 
60 // -----------------------------------------------------------------------------
61 
62 template <typename MODEL> void testConstructor() {
64  typedef oops::ModelAuxCovariance<MODEL> Covariance_;
65 
66  boost::scoped_ptr<Covariance_> bias(new Covariance_(Test_::config(), Test_::resol()));
67  BOOST_CHECK(bias.get());
68 
69  bias.reset();
70  BOOST_CHECK(!bias.get());
71 }
72 
73 // -----------------------------------------------------------------------------
74 // void linearize(const ModelAuxControl_ &, const Geometry_ &);
75 // void multiply(const ModelAuxIncrement_ &, ModelAuxIncrement_ &) const;
76 // void invMult(const ModelAuxIncrement_ &, ModelAuxIncrement_ &) const;
77 // void randomize(ModelAuxIncrement_ &) const;
78 // -----------------------------------------------------------------------------
79 
80 // -----------------------------------------------------------------------------
81 
82 template <typename MODEL> class ModelAuxCovariance : public oops::Test {
83  public:
85  virtual ~ModelAuxCovariance() {}
86  private:
87  std::string testid() const {return "test::ModelAuxCovariance<" + MODEL::name() + ">";}
88 
89  void register_tests() const {
90  boost::unit_test::test_suite * ts = BOOST_TEST_SUITE("interface/ModelAuxCovariance");
91 
92  ts->add(BOOST_TEST_CASE(&testConstructor<MODEL>));
93 
94  boost::unit_test::framework::master_test_suite().add(ts);
95  }
96 };
97 
98 // =============================================================================
99 
100 } // namespace test
101 
102 #endif // TEST_INTERFACE_MODELAUXCOVARIANCE_H_
boost::scoped_ptr< const eckit::LocalConfiguration > conf_
static const eckit::Configuration & config()
character(len=32) name
static ModelAuxCovarianceFixture< MODEL > & getInstance()
void testConstructor()
oops::ModelAuxCovariance< MODEL > Covariance_
static const eckit::Configuration & config()