IODA
test-layoutobsgroup.cpp
Go to the documentation of this file.
1 /*
2  * (C) Crown Copyright 2021 Met Office
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 
9 #include <string>
10 #include <typeindex>
11 #include "ioda/Exception.h"
12 #include "ioda/testconfig.h"
13 
14 // This header is internal to ioda. It is not callable by end-users outside of the
15 // testing environment.
17 
18 #include "eckit/testing/Test.h"
19 
20 using namespace eckit::testing;
21 
22 namespace ioda {
23 namespace test {
24 
25 CASE("Derived variable, unit conversion, and exception checking methods") {
27  EXPECT_NOT(dataLayoutPolicy.isComplementary("anyVariable"));
28  EXPECT_THROWS(dataLayoutPolicy.getComplementaryPosition("anyVariable"));
29  EXPECT_THROWS(dataLayoutPolicy.getInputsNeeded("anyVariable"));
30  EXPECT_THROWS(dataLayoutPolicy.getMergeMethod("anyVariable"));
31  EXPECT_THROWS(dataLayoutPolicy.getOutputNameFromComponent("anyVariable"));
32  EXPECT_THROWS(dataLayoutPolicy.getOutputVariableDataType("anyVariable"));
33  // unit conversion methods
34  EXPECT_NOT(dataLayoutPolicy.isMapped("anyVariable"));
35  EXPECT_THROWS(dataLayoutPolicy.getUnit("anyVariable"));
36  // exception checking method
37  EXPECT_NOT(dataLayoutPolicy.isMapOutput("anyVariable"));
38 }
39 
40 CASE("Generate variants") {
41  detail::DataLayoutPolicy::generate("ObsGroup");
42  detail::DataLayoutPolicy::generate(detail::DataLayoutPolicy::Policies::ObsGroup);
43  std::string str;
44  EXPECT_THROWS(detail::DataLayoutPolicy::generate("ObsGroup", str));
45  EXPECT_THROWS(detail::DataLayoutPolicy::generate(detail::DataLayoutPolicy::Policies::ObsGroup,
46  str));
47  EXPECT_THROWS(detail::DataLayoutPolicy::generate(detail::DataLayoutPolicy::Policies::None, str));
48 }
49 
50 } // namespace test
51 } // namespace ioda
52 
53 int main(int argc, char** argv) {
54  return run_tests(argc, argv);
55 }
IODA's error system.
Contains definitions for how data are arranged in ioda internally.
Layout for ObsGroup-like data.
virtual size_t getComplementaryPosition(const std::string &) const
Definition: Layout.cpp:102
virtual std::type_index getOutputVariableDataType(const std::string &) const
Definition: Layout.cpp:110
virtual std::pair< bool, std::string > getUnit(const std::string &) const
Definition: Layout.cpp:122
virtual MergeMethod getMergeMethod(const std::string &) const
Definition: Layout.cpp:114
virtual bool isComplementary(const std::string &) const
Check if the named variable will be a part of a derived variable.
Definition: Layout.cpp:96
virtual bool isMapped(const std::string &) const
Check if the named variable is in the Variables section of the ODB mapping file.
Definition: Layout.cpp:98
virtual std::string getOutputNameFromComponent(const std::string &) const
Definition: Layout.cpp:106
virtual size_t getInputsNeeded(const std::string &) const
Definition: Layout.cpp:118
virtual bool isMapOutput(const std::string &) const
Check if the named variable matches one of the output (ioda) names.
Definition: Layout.cpp:100
int main(int argc, char **argv)
CASE("Validation")