FV3 Bundle
test/interface/ObsErrorCovariance.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_OBSERRORCOVARIANCE_H_
12 #define TEST_INTERFACE_OBSERRORCOVARIANCE_H_
13 
14 #include <string>
15 #include <vector>
16 
17 #define BOOST_TEST_NO_MAIN
18 #define BOOST_TEST_ALTERNATIVE_INIT_API
19 #define BOOST_TEST_DYN_LINK
20 #include <boost/test/unit_test.hpp>
21 
22 #include <boost/scoped_ptr.hpp>
23 
24 #include "eckit/config/LocalConfiguration.h"
27 #include "oops/runs/Test.h"
29 #include "test/TestEnvironment.h"
30 
31 namespace test {
32 
33 // -----------------------------------------------------------------------------
34 
35 template <typename MODEL> void testConstructor() {
36  typedef ObsTestsFixture<MODEL> Test_;
37  typedef oops::ObsErrorCovariance<MODEL> Covar_;
38 
39  oops::instantiateObsErrorFactory<MODEL>();
40 
41  const eckit::LocalConfiguration obsconf(TestEnvironment::config(), "Observations");
42  std::vector<eckit::LocalConfiguration> conf;
43  obsconf.get("ObsTypes", conf);
44 
45  for (std::size_t jj = 0; jj < Test_::obspace().size(); ++jj) {
46  const eckit::LocalConfiguration rconf(conf[jj], "Covariance");
47  boost::scoped_ptr<Covar_> R(new Covar_(Test_::obspace()[jj], rconf));
48  BOOST_CHECK(R.get());
49 
50  R.reset();
51  BOOST_CHECK(!R.get());
52  }
53 }
54 
55 // -----------------------------------------------------------------------------
56 
57 template <typename MODEL> class ObsErrorCovariance : public oops::Test {
58  public:
60  virtual ~ObsErrorCovariance() {}
61  private:
62  std::string testid() const {return "test::ObsErrorCovariance<" + MODEL::name() + ">";}
63 
64  void register_tests() const {
65  boost::unit_test::test_suite * ts = BOOST_TEST_SUITE("interface/ObsErrorCovariance");
66 
67  ts->add(BOOST_TEST_CASE(&testConstructor<MODEL>));
68 
69  boost::unit_test::framework::master_test_suite().add(ts);
70  }
71 };
72 
73 // =============================================================================
74 
75 } // namespace test
76 
77 #endif // TEST_INTERFACE_OBSERRORCOVARIANCE_H_
Definition: conf.py:1
static const eckit::Configuration & config()
character(len=32) name
void testConstructor()
Observation error covariance matrix.