Commit 206ce1b4 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰

[#65,!96] Now both MapElement and ListElement have functional empty()

parent 8c910e9c
......@@ -697,6 +697,8 @@ public:
}
bool equals(const Element& other) const;
bool empty() const { return (m.empty()); }
};
/// Checks whether the given ElementPtr is a NULL pointer
......
......@@ -650,6 +650,8 @@ TEST(Element, MapElement) {
EXPECT_TRUE(isNull(el->get("value3")));
EXPECT_FALSE(el->empty());
el->set("value3", Element::create(56176));
EXPECT_EQ(el->get("value3")->intValue(), 56176);
......@@ -1340,4 +1342,23 @@ TEST(Element, getPositionCommented) {
EXPECT_EQ(14, level2_el->getPosition().pos_);
EXPECT_EQ("kea.conf", level2_el->getPosition().file_);
}
TEST(Element, empty) {
// Let's try Map first
ElementPtr m = Element::createMap();
EXPECT_TRUE(m->empty());
m->set("something", Element::create(123));
EXPECT_FALSE(m->empty());
m->remove("something");
EXPECT_TRUE(m->empty());
// Now do the same with list
ElementPtr l = Element::createList();
EXPECT_TRUE(l->empty());
l->add(Element::create(123));
EXPECT_FALSE(l->empty());
l->remove(0);
EXPECT_TRUE(l->empty());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment