FV3 Bundle
oops/src/test/interface/Locations.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_LOCATIONS_H_
12 #define TEST_INTERFACE_LOCATIONS_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"
26 #include "oops/runs/Test.h"
27 #include "test/TestEnvironment.h"
28 
29 namespace test {
30 
31 // -----------------------------------------------------------------------------
32 
33 template <typename MODEL> void testConstructor() {
34  typedef oops::Locations<MODEL> Locations_;
35 
36  const eckit::LocalConfiguration conf(TestEnvironment::config(), "Locations");
37  boost::scoped_ptr<Locations_> locs(new Locations_(conf));
38  BOOST_CHECK(locs.get());
39 
40  locs.reset();
41  BOOST_CHECK(!locs.get());
42 }
43 
44 // -----------------------------------------------------------------------------
45 
46 template <typename MODEL> void testCopyConstructor() {
47  typedef oops::Locations<MODEL> Locations_;
48 
49  const eckit::LocalConfiguration conf(TestEnvironment::config(), "Locations");
50  boost::scoped_ptr<Locations_> locs(new Locations_(conf));
51  BOOST_CHECK(locs.get());
52 
53  boost::scoped_ptr<Locations_> other_locs(new Locations_(*locs));
54  BOOST_CHECK(other_locs.get());
55 
56  locs.reset();
57  BOOST_CHECK(!locs.get());
58 
59  other_locs.reset();
60  BOOST_CHECK(!other_locs.get());
61 }
62 
63 // -----------------------------------------------------------------------------
64 
65 template <typename MODEL> class Locations : public oops::Test {
66  public:
67  Locations() {}
68  virtual ~Locations() {}
69  private:
70  std::string testid() const {return "test::Locations<" + MODEL::name() + ">";}
71 
72  void register_tests() const {
73  boost::unit_test::test_suite * ts = BOOST_TEST_SUITE("interface/Locations");
74 
75  ts->add(BOOST_TEST_CASE(&testConstructor<MODEL>));
76  ts->add(BOOST_TEST_CASE(&testCopyConstructor<MODEL>));
77 
78  boost::unit_test::framework::master_test_suite().add(ts);
79  }
80 };
81 
82 // -----------------------------------------------------------------------------
83 
84 } // namespace test
85 
86 #endif // TEST_INTERFACE_LOCATIONS_H_
Definition: conf.py:1
static const eckit::Configuration & config()
character(len=32) name
void testConstructor()
void testCopyConstructor()