OOPS
test/interface/Geometry.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_GEOMETRY_H_
12 #define TEST_INTERFACE_GEOMETRY_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 
23 #include "eckit/config/Configuration.h"
24 #include "eckit/testing/Test.h"
26 #include "oops/mpi/mpi.h"
27 #include "oops/runs/Test.h"
29 #include "test/TestEnvironment.h"
30 
31 namespace test {
32 
33 // -----------------------------------------------------------------------------
34 template <typename MODEL> void testConstructor() {
35  typedef oops::Geometry<MODEL> Geometry_;
36 
37  std::unique_ptr<Geometry_> geom(new Geometry_(GeometryFixture<MODEL>::getParameters(),
39 
40  EXPECT(geom.get());
41 
42  geom.reset();
43  EXPECT(!geom.get());
44 }
45 
46 // -----------------------------------------------------------------------------
47 template <typename MODEL> void testCopyConstructor() {
48  typedef oops::Geometry<MODEL> Geometry_;
49  std::unique_ptr<Geometry_> geom(new Geometry_(GeometryFixture<MODEL>::getParameters(),
51 
52 
53  std::unique_ptr<Geometry_> other(new Geometry_(*geom));
54  EXPECT(other.get());
55 
56  other.reset();
57  EXPECT(!other.get());
58 
59  EXPECT(geom.get());
60 }
61 
62 // -----------------------------------------------------------------------------
63 template <typename MODEL> class Geometry : public oops::Test {
64  public:
65  Geometry() {}
66  virtual ~Geometry() {}
67  private:
68  std::string testid() const override {return "test::Geometry<" + MODEL::name() + ">";}
69 
70  void register_tests() const override {
71  std::vector<eckit::testing::Test>& ts = eckit::testing::specification();
72 
73  ts.emplace_back(CASE("interface/Geometry/testConstructor")
74  { testConstructor<MODEL>(); });
75  ts.emplace_back(CASE("interface/Geometry/testCopyConstructor")
76  { testCopyConstructor<MODEL>(); });
77  }
78 
79  void clear() const override {}
80 };
81 
82 // =============================================================================
83 
84 } // namespace test
85 
86 #endif // TEST_INTERFACE_GEOMETRY_H_
GeometryFixture.h
test::testCopyConstructor
void testCopyConstructor()
Definition: test/base/Variables.h:50
mpi.h
test::CASE
CASE("test_linearmodelparameterswrapper_valid_name")
Definition: LinearModelFactory.cc:22
test::Geometry::~Geometry
virtual ~Geometry()
Definition: test/interface/Geometry.h:66
test
Definition: LinearModelFactory.cc:20
oops::mpi::myself
const eckit::mpi::Comm & myself()
Default communicator with each MPI task by itself.
Definition: oops/mpi/mpi.cc:28
test::Geometry::testid
std::string testid() const override
Definition: test/interface/Geometry.h:68
test::GeometryFixture::getParameters
static const Parameters_ & getParameters()
Definition: GeometryFixture.h:49
Test.h
test::Geometry::register_tests
void register_tests() const override
Definition: test/interface/Geometry.h:70
oops::Geometry
Geometry class used in oops; subclass of interface class above.
Definition: oops/interface/Geometry.h:189
TestEnvironment.h
test::testConstructor
void testConstructor()
Tests creation and destruction of ObsErrorCovariances.
Definition: test/base/ObsErrorCovariance.h:32
oops::Test
Definition: Test.h:39
test::Geometry
Definition: test/interface/Geometry.h:63
oops::mpi::world
const eckit::mpi::Comm & world()
Default communicator with all MPI tasks (ie MPI_COMM_WORLD)
Definition: oops/mpi/mpi.cc:22
Geometry.h
test::Geometry::Geometry
Geometry()
Definition: test/interface/Geometry.h:65
test::Geometry::clear
void clear() const override
Definition: test/interface/Geometry.h:79