FV3 Bundle
TestConfig.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 L95_TEST_LORENZ95_TESTCONFIG_H_
12 #define L95_TEST_LORENZ95_TESTCONFIG_H_
13 
14 #include <string>
15 
16 #include <boost/scoped_ptr.hpp>
17 #include <boost/test/unit_test.hpp>
18 
19 #include "eckit/config/LocalConfiguration.h"
20 #include "eckit/config/YAMLConfiguration.h"
21 #include "eckit/exception/Exceptions.h"
22 #include "eckit/runtime/Main.h"
23 
24 namespace test {
25 
26 // -----------------------------------------------------------------------------
27 
28 class TestConfig {
29  public:
30  static const eckit::Configuration & config() {
31  static TestConfig test;
32  return *test.config_;
33  }
34 
36  ASSERT(eckit::Main::ready());
37 
38  int narg = eckit::Main::instance().argc();
39  ASSERT(narg >= 2);
40  eckit::PathName fname = eckit::Main::instance().argv(narg-1);
41  config_.reset(new eckit::YAMLConfiguration(fname));
42  }
43 
45 
46  private:
47  boost::scoped_ptr<const eckit::YAMLConfiguration> config_;
48 };
49 
50 // -----------------------------------------------------------------------------
51 
52 } // namespace test
53 
54 #endif // L95_TEST_LORENZ95_TESTCONFIG_H_
program test
boost::scoped_ptr< const eckit::YAMLConfiguration > config_
Definition: TestConfig.h:47
static const eckit::Configuration & config()
Definition: TestConfig.h:30