};
int intVal;
+ std::vector<int> intVector;
SubSubConfig subSubObj;
CONFIG_REGISTER
(
intVal,
+ intVector,
subSubObj
)
};
double doubleVal;
bool boolVal;
+ std::vector<int> emptyIntVector;
std::vector<int> intVector;
std::vector<std::string> stringVector;
std::vector<double> doubleVector;
doubleVal,
boolVal,
+ emptyIntVector,
intVector,
stringVector,
doubleVector,
"\"stringVal\": \"blah\", "
"\"doubleVal\": -1.234000, "
"\"boolVal\": true, "
+ "\"emptyIntVector\": [ ], "
"\"intVector\": [ 1, 2, 3 ], "
"\"stringVector\": [ \"a\", \"b\" ], "
"\"doubleVector\": [ 0.000000, 1.000000, 2.000000 ], "
- "\"subObj\": { \"intVal\": 54321, \"subSubObj\": { \"intVal\": 234 } }, "
- "\"subVector\": [ { \"intVal\": 123, \"subSubObj\": { \"intVal\": 345 } }, "
- "{ \"intVal\": 456, \"subSubObj\": { \"intVal\": 567 } } ] }";
+ "\"subObj\": { \"intVal\": 54321, \"intVector\": [ 1, 2 ], \"subSubObj\": { \"intVal\": 234 } }, "
+ "\"subVector\": [ { \"intVal\": 123, \"intVector\": [ 3, 4 ], \"subSubObj\": { \"intVal\": 345 } }, "
+ "{ \"intVal\": 456, \"intVector\": [ 5, 6 ], \"subSubObj\": { \"intVal\": 567 } } ] }";
// Floating point tolerance as a number of rounding errors
const int TOLERANCE = 1;
BOOST_CHECK_CLOSE(-1.234, testConfig.doubleVal, TOLERANCE);
BOOST_CHECK_EQUAL(true, testConfig.boolVal);
+ BOOST_REQUIRE_EQUAL(0, testConfig.emptyIntVector.size());
+
BOOST_REQUIRE_EQUAL(3, testConfig.intVector.size());
BOOST_CHECK_EQUAL(1, testConfig.intVector[0]);
BOOST_CHECK_EQUAL(2, testConfig.intVector[1]);
BOOST_CHECK_CLOSE(2.0, testConfig.doubleVector[2], TOLERANCE);
BOOST_CHECK_EQUAL(54321, testConfig.subObj.intVal);
+ BOOST_CHECK_EQUAL(2, testConfig.subObj.intVector.size());
+ BOOST_CHECK_EQUAL(1, testConfig.subObj.intVector[0]);
+ BOOST_CHECK_EQUAL(2, testConfig.subObj.intVector[1]);
+ BOOST_CHECK_EQUAL(234, testConfig.subObj.subSubObj.intVal);
BOOST_REQUIRE_EQUAL(2, testConfig.subVector.size());
BOOST_CHECK_EQUAL(123, testConfig.subVector[0].intVal);
BOOST_CHECK_EQUAL(456, testConfig.subVector[1].intVal);
BOOST_CHECK_EQUAL(345, testConfig.subVector[0].subSubObj.intVal);
BOOST_CHECK_EQUAL(567, testConfig.subVector[1].subSubObj.intVal);
+ BOOST_CHECK_EQUAL(3, testConfig.subVector[0].intVector[0]);
+ BOOST_CHECK_EQUAL(5, testConfig.subVector[1].intVector[0]);
+ BOOST_CHECK_EQUAL(4, testConfig.subVector[0].intVector[1]);
+ BOOST_CHECK_EQUAL(6, testConfig.subVector[1].intVector[1]);
+
}
std::string HARD_KEY = "[" + KEY;
BOOST_CHECK_NO_THROW(c.set(HARD_KEY, "A"));
BOOST_CHECK_NO_THROW(c.set(KEY, "B"));
- BOOST_CHECK_EQUAL(c.count(HARD_KEY), 1);
- BOOST_CHECK_EQUAL(c.count(KEY), 1);
- BOOST_CHECK_EQUAL(c.size(), 2);
+ BOOST_CHECK(c.exists(HARD_KEY));
+ BOOST_CHECK(c.exists(KEY));
BOOST_CHECK_NO_THROW(c.clear());
HARD_KEY = "]" + KEY;
BOOST_CHECK_NO_THROW(c.set(HARD_KEY, "A"));
BOOST_CHECK_NO_THROW(c.set(KEY, "B"));
- BOOST_CHECK_EQUAL(c.count(HARD_KEY), 1);
- BOOST_CHECK_EQUAL(c.count(KEY), 1);
- BOOST_CHECK_EQUAL(c.size(), 2);
+ BOOST_CHECK(c.exists(HARD_KEY));
+ BOOST_CHECK(c.exists(KEY));
BOOST_CHECK_NO_THROW(c.clear());
HARD_KEY = "?" + KEY;
BOOST_CHECK_NO_THROW(c.set(HARD_KEY, "A"));
BOOST_CHECK_NO_THROW(c.set(KEY, "B"));
- BOOST_CHECK_EQUAL(c.count(HARD_KEY), 1);
- BOOST_CHECK_EQUAL(c.count(KEY), 1);
- BOOST_CHECK_EQUAL(c.size(), 2);
+ BOOST_CHECK(c.exists(HARD_KEY));
+ BOOST_CHECK(c.exists(KEY));
BOOST_CHECK_NO_THROW(c.clear());
HARD_KEY = "*" + KEY;
BOOST_CHECK_NO_THROW(c.set(HARD_KEY, "A"));
BOOST_CHECK_NO_THROW(c.set(KEY, "B"));
- BOOST_CHECK_EQUAL(c.count(HARD_KEY), 1);
- BOOST_CHECK_EQUAL(c.count(KEY), 1);
- BOOST_CHECK_EQUAL(c.size(), 2);
+ BOOST_CHECK(c.exists(HARD_KEY));
+ BOOST_CHECK(c.exists(KEY));
}
namespace {
// Update
BOOST_CHECK_NO_THROW(f.c.set(KEY, b));
BOOST_CHECK_EQUAL(f.c.get<B>(KEY), b);
- BOOST_CHECK_EQUAL(f.c.count(KEY), 1);
+ BOOST_CHECK(f.c.exists(KEY));
// Remove
BOOST_CHECK_NO_THROW(f.c.remove(KEY));
- BOOST_CHECK_EQUAL(f.c.count(KEY), 0);
+ BOOST_CHECK(!f.c.exists(KEY));
BOOST_CHECK_THROW(f.c.get<B>(KEY), ConfigException);
}
} // namespace
BOOST_CHECK_NO_THROW(f.c.set(KEY, vec));
BOOST_CHECK_NO_THROW(storedVec = f.c.get<std::vector<T> >(KEY))
BOOST_CHECK_EQUAL_COLLECTIONS(storedVec.begin(), storedVec.end(), vec.begin(), vec.end());
- BOOST_CHECK_EQUAL(f.c.count(KEY), vec.size());
- BOOST_CHECK_EQUAL(f.c.size(), vec.size());
}
template<typename T>
// Remove
BOOST_CHECK_NO_THROW(f.c.remove(KEY));
- BOOST_CHECK_EQUAL(f.c.count(KEY), 0);
- BOOST_CHECK_EQUAL(f.c.size(), 0);
+ BOOST_CHECK(!f.c.exists(KEY));
+ BOOST_CHECK(f.c.isEmpty());
BOOST_CHECK_THROW(f.c.get<std::vector<T> >(KEY), ConfigException);
BOOST_CHECK_THROW(f.c.get(KEY), ConfigException);
}
std::vector<std::string> vec = {"A", "B"};
BOOST_CHECK_NO_THROW(c.set(KEY, vec));
BOOST_CHECK_NO_THROW(c.clear());
- BOOST_CHECK_EQUAL(c.size(), 0);
+ BOOST_CHECK(c.isEmpty());
BOOST_CHECK_NO_THROW(c.remove(KEY));
BOOST_CHECK_THROW(c.get<std::vector<std::string>>(KEY), ConfigException);