Cheetah Software  1.0
test_yaml.cpp
Go to the documentation of this file.
1 #include "gmock/gmock.h"
2 #include "gtest/gtest.h"
3 
4 #include "ParamHandler.hpp"
5 #include "Utilities/utilities.h"
6 
7 TEST(YAML, yaml_category_read) {
8  ParamHandler paramHandler(getConfigDirectoryPath() + "test-yaml.yaml");
9  EXPECT_TRUE(paramHandler.fileOpenedSuccessfully());
10  double c1p1, c2p1;
11  std::vector<double> c1p2, c2p2;
12  EXPECT_TRUE(paramHandler.getValue("category-1", "parameter-1", c1p1));
13  EXPECT_TRUE(paramHandler.getValue("category-2", "parameter-1", c2p1));
14  EXPECT_TRUE(paramHandler.getVector("category-1", "parameter-2", c1p2));
15  EXPECT_TRUE(paramHandler.getVector("category-2", "parameter-2", c2p2));
16 
17  EXPECT_TRUE(c1p1 == 12.);
18  EXPECT_TRUE(c1p2[0] == 1.);
19  EXPECT_TRUE(c1p2[1] == 2.);
20  EXPECT_TRUE(c1p2[2] == 3.);
21  EXPECT_TRUE(c1p2.size() == 3);
22 
23  EXPECT_TRUE(c2p1 == 23.);
24  EXPECT_TRUE(c2p2[0] == 2.);
25  EXPECT_TRUE(c2p2[1] == 3.);
26  EXPECT_TRUE(c2p2.size() == 2);
27 
28  EXPECT_FALSE(paramHandler.getValue("notARealKey", c1p1));
29  ParamHandler badHandler("not-a-real-file.potato");
30  EXPECT_FALSE(badHandler.fileOpenedSuccessfully());
31 }
TEST(YAML, yaml_category_read)
Definition: test_yaml.cpp:7
std::string getConfigDirectoryPath()
Definition: utilities.cpp:30