|
6 | 6 |
|
7 | 7 | using namespace inih; |
8 | 8 |
|
| 9 | +TEST(INIReader, get_sections) { |
| 10 | + INIReader r{"./fixtures/config.ini"}; |
| 11 | + |
| 12 | + const std::set<std::string> ans = {"section1", "section2"}; |
| 13 | + |
| 14 | + EXPECT_EQ(r.Sections(), ans); |
| 15 | +} |
| 16 | + |
| 17 | +TEST(INIReader, get_keys) { |
| 18 | + INIReader r{"./fixtures/config.ini"}; |
| 19 | + |
| 20 | + const std::set<std::string> ans = {"any", "any2", "not_int", "not_int_arr"}; |
| 21 | + |
| 22 | + EXPECT_EQ(r.Keys("section1"), ans); |
| 23 | +} |
| 24 | + |
9 | 25 | TEST(INIReader, get_single_value) { |
10 | 26 | INIReader r{"./fixtures/config.ini"}; |
11 | 27 |
|
@@ -68,12 +84,16 @@ TEST(INIReader, exception) { |
68 | 84 |
|
69 | 85 | INIReader r{"./fixtures/config.ini"}; |
70 | 86 |
|
| 87 | + // section not found error |
| 88 | + EXPECT_THROW(r.Get("section3"), std::runtime_error); |
| 89 | + |
71 | 90 | // key not found error |
72 | 91 | EXPECT_THROW(r.Get<int>("section1", "not_exist"), std::runtime_error); |
73 | 92 | EXPECT_THROW(r.GetVector<int>("section1", "not_exist"), std::runtime_error); |
74 | 93 |
|
75 | 94 | // parse error |
76 | 95 | EXPECT_THROW(r.Get<int>("section1", "not_int"), std::runtime_error); |
| 96 | + EXPECT_THROW(r.Get<bool>("section1", "not_int"), std::runtime_error); |
77 | 97 | EXPECT_THROW(r.GetVector<int>("section1", "not_int_arr"), std::runtime_error); |
78 | 98 |
|
79 | 99 | } |
|
0 commit comments