IODA Bundle
ObsDtype.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2021 Met Office UK
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  */
7 
8 #ifndef TEST_IODA_OBSDTYPE_H_
9 #define TEST_IODA_OBSDTYPE_H_
10 
11 #include <memory>
12 #include <string>
13 #include <vector>
14 
15 #include <boost/make_unique.hpp>
16 
17 #include "eckit/config/LocalConfiguration.h"
18 #include "eckit/testing/Test.h"
19 
20 #include "oops/mpi/mpi.h"
21 #include "oops/runs/Test.h"
22 #include "oops/test/TestEnvironment.h"
23 #include "oops/util/parameters/Parameters.h"
24 #include "oops/util/parameters/RequiredParameter.h"
25 
26 #include "ioda/core/ParameterTraitsObsDtype.h"
27 #include "ioda/ObsSpace.h"
28 
29 namespace ioda {
30 namespace test {
31 
32 class MyParameters : public oops::Parameters {
33  OOPS_CONCRETE_PARAMETERS(MyParameters, Parameters)
34  public:
35  oops::RequiredParameter<ioda::ObsDtype> dtype{"dtype", this};
36 };
37 
38 CASE("ioda/ObsDtype") {
39  const eckit::Configuration &conf = ::test::TestEnvironment::config();
40 
41  {
43  params.validateAndDeserialize(conf.getSubConfiguration("int"));
44  EXPECT(params.dtype == ObsDtype::Integer);
45  }
46  {
48  params.validateAndDeserialize(conf.getSubConfiguration("float"));
49  EXPECT(params.dtype == ObsDtype::Float);
50  }
51  {
53  params.validateAndDeserialize(conf.getSubConfiguration("string"));
54  EXPECT(params.dtype == ObsDtype::String);
55  }
56  {
58  params.validateAndDeserialize(conf.getSubConfiguration("datetime"));
59  EXPECT(params.dtype == ObsDtype::DateTime);
60  }
61  {
63  EXPECT_THROWS(params.validateAndDeserialize(conf.getSubConfiguration("invalid")));
64  }
65 }
66 
67 class ObsDtype : public oops::Test {
68  private:
69  std::string testid() const override {return "test::ioda::ObsDtype";}
70 
71  void register_tests() const override {}
72 
73  void clear() const override {}
74 };
75 
76 // =============================================================================
77 
78 } // namespace test
79 } // namespace ioda
80 
81 #endif // TEST_IODA_OBSDTYPE_H_
oops::RequiredParameter< ioda::ObsDtype > dtype
Definition: ObsDtype.h:35
void clear() const override
Definition: ObsDtype.h:73
std::string testid() const override
Definition: ObsDtype.h:69
void register_tests() const override
Definition: ObsDtype.h:71
static const eckit::Configuration & config()
CASE("Derived variable, unit conversion, and exception checking methods")