OOPS
test/interface/ObsAuxControl.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_OBSAUXCONTROL_H_
12 #define TEST_INTERFACE_OBSAUXCONTROL_H_
13 
14 #include <memory>
15 #include <string>
16 #include <vector>
17 
18 #define ECKIT_TESTING_SELF_REGISTER_CASES 0
19 
20 #include <boost/noncopyable.hpp>
21 
22 #include "eckit/config/Configuration.h"
23 #include "eckit/testing/Test.h"
25 #include "oops/runs/Test.h"
27 #include "test/TestEnvironment.h"
28 
29 namespace test {
30 
31 // -----------------------------------------------------------------------------
32 
33 template <typename OBS> void testConstructor() {
34  typedef ObsTestsFixture<OBS> Test_;
35  typedef oops::ObsAuxControl<OBS> ObsAux_;
36 
37  std::vector<eckit::LocalConfiguration> oconf;
38  TestEnvironment::config().get("observations", oconf);
39  for (std::size_t jj = 0; jj < Test_::obspace().size(); ++jj) {
40  std::unique_ptr<ObsAux_> bias(new ObsAux_(Test_::obspace()[jj], oconf[jj]));
41  EXPECT(bias.get());
42 
43  bias.reset();
44  EXPECT(!bias.get());
45  }
46 }
47 
48 // -----------------------------------------------------------------------------
49 
50 template <typename OBS> void testCopyConstructor() {
51  typedef ObsTestsFixture<OBS> Test_;
52  typedef oops::ObsAuxControl<OBS> ObsAux_;
53 
54  std::vector<eckit::LocalConfiguration> oconf;
55  TestEnvironment::config().get("observations", oconf);
56  for (std::size_t jj = 0; jj < Test_::obspace().size(); ++jj) {
57  std::unique_ptr<ObsAux_> bias(new ObsAux_(Test_::obspace()[jj], oconf[jj]));
58 
59  std::unique_ptr<ObsAux_> other(new ObsAux_(*bias));
60  EXPECT(other.get());
61 
62  other.reset();
63  EXPECT(!other.get());
64 
65  EXPECT(bias.get());
66  }
67 }
68 
69 // -----------------------------------------------------------------------------
70 
71 template <typename OBS>
72 class ObsAuxControl : public oops::Test {
74  public:
76  virtual ~ObsAuxControl() {}
77  private:
78  std::string testid() const override {return "test::ObsAuxControl<" + OBS::name() + ">";}
79 
80  void register_tests() const override {
81  std::vector<eckit::testing::Test>& ts = eckit::testing::specification();
82 
83  ts.emplace_back(CASE("interface/ObsAuxControl/testConstructor")
84  { testConstructor<OBS>(); });
85  ts.emplace_back(CASE("interface/ObsAuxControl/testCopyConstructor")
86  { testCopyConstructor<OBS>(); });
87  }
88 
89  void clear() const override {
90  Test_::reset();
91  }
92 };
93 
94 // =============================================================================
95 
96 } // namespace test
97 
98 #endif // TEST_INTERFACE_OBSAUXCONTROL_H_
test::ObsTestsFixture
Definition: ObsTestsFixture.h:29
test::testCopyConstructor
void testCopyConstructor()
Definition: test/base/Variables.h:50
ObsAuxControl.h
test::ObsTestsFixture::reset
static void reset()
Definition: ObsTestsFixture.h:37
test::CASE
CASE("test_linearmodelparameterswrapper_valid_name")
Definition: LinearModelFactory.cc:22
test::ObsAuxControl::ObsAuxControl
ObsAuxControl()
Definition: test/interface/ObsAuxControl.h:75
test
Definition: LinearModelFactory.cc:20
oops::ObsAuxControl
Definition: oops/interface/ObsAuxControl.h:35
test::ObsAuxControl::Test_
ObsTestsFixture< OBS > Test_
Definition: test/interface/ObsAuxControl.h:73
Test.h
test::TestEnvironment::config
static const eckit::Configuration & config()
Definition: TestEnvironment.h:40
ObsTestsFixture.h
test::ObsAuxControl::testid
std::string testid() const override
Definition: test/interface/ObsAuxControl.h:78
test::ObsAuxControl::~ObsAuxControl
virtual ~ObsAuxControl()
Definition: test/interface/ObsAuxControl.h:76
TestEnvironment.h
test::ObsAuxControl::register_tests
void register_tests() const override
Definition: test/interface/ObsAuxControl.h:80
test::testConstructor
void testConstructor()
Tests creation and destruction of ObsErrorCovariances.
Definition: test/base/ObsErrorCovariance.h:32
test::ObsAuxControl::clear
void clear() const override
Definition: test/interface/ObsAuxControl.h:89
oops::Test
Definition: Test.h:39
test::ObsAuxControl
Definition: test/interface/ObsAuxControl.h:72