Debian Codegraph @

packages/stk/stk_unit_tests/stk_util/environment/UnitTestParsedOptions.cpp

raw
1 #include "gtest/gtest.h"
2 #include "stk_util/environment/ParsedOptions.hpp" // for ParsedOptions, VariableType
3 #include <string> // for string
4
5 namespace {
6
7 TEST(ParsedOptions, construct_empty)
8 {
9 stk::ParsedOptions vm;
10
11 EXPECT_TRUE(vm.empty());
12 }
13
14 TEST(ParsedOptions, insert_value_and_count)
15 {
16 stk::ParsedOptions vm;
17
18 vm.insert("foo", "bar");
19
20 EXPECT_EQ(1u, vm.count("foo"));
21 EXPECT_FALSE(vm.empty());
22
23 EXPECT_EQ(0u, vm.count("garbage"));
24 }
25
26 TEST(ParsedOptions, get_value_as_type)
27 {
28 stk::ParsedOptions vm;
29
30 vm.insert("int", "99");
31
32 int val = vm["int"].as<int>();
33 EXPECT_EQ(99, val);
34
35 std::string strval = vm["int"];
36 std::string expectedVal("99");
37 EXPECT_EQ(expectedVal, strval);
38 }
39
40 }