summaryrefslogtreecommitdiff
path: root/test/OptionTest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/OptionTest.cc')
-rw-r--r--test/OptionTest.cc45
1 files changed, 35 insertions, 10 deletions
diff --git a/test/OptionTest.cc b/test/OptionTest.cc
index f7ce58f2..b8f39b81 100644
--- a/test/OptionTest.cc
+++ b/test/OptionTest.cc
@@ -8,7 +8,7 @@
namespace aria2 {
-class OptionTest:public CppUnit::TestFixture {
+class OptionTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(OptionTest);
CPPUNIT_TEST(testPutAndGet);
@@ -18,12 +18,12 @@ class OptionTest:public CppUnit::TestFixture {
CPPUNIT_TEST(testBlank);
CPPUNIT_TEST(testMerge);
CPPUNIT_TEST(testParent);
+ CPPUNIT_TEST(testRemove);
CPPUNIT_TEST_SUITE_END();
-private:
+private:
public:
- void setUp() {
- }
+ void setUp() {}
void testPutAndGet();
void testPutAndGetAsInt();
@@ -32,12 +32,13 @@ public:
void testBlank();
void testMerge();
void testParent();
+ void testRemove();
};
+CPPUNIT_TEST_SUITE_REGISTRATION(OptionTest);
-CPPUNIT_TEST_SUITE_REGISTRATION( OptionTest );
-
-void OptionTest::testPutAndGet() {
+void OptionTest::testPutAndGet()
+{
Option op;
op.put(PREF_TIMEOUT, "value");
@@ -45,7 +46,8 @@ void OptionTest::testPutAndGet() {
CPPUNIT_ASSERT_EQUAL(std::string("value"), op.get(PREF_TIMEOUT));
}
-void OptionTest::testPutAndGetAsInt() {
+void OptionTest::testPutAndGetAsInt()
+{
Option op;
op.put(PREF_TIMEOUT, "1000");
@@ -53,7 +55,8 @@ void OptionTest::testPutAndGetAsInt() {
CPPUNIT_ASSERT_EQUAL((int32_t)1000, op.getAsInt(PREF_TIMEOUT));
}
-void OptionTest::testPutAndGetAsDouble() {
+void OptionTest::testPutAndGetAsDouble()
+{
Option op;
op.put(PREF_TIMEOUT, "10.0");
@@ -118,9 +121,31 @@ void OptionTest::testParent()
CPPUNIT_ASSERT(child.defined(PREF_TIMEOUT));
CPPUNIT_ASSERT(child.definedLocal(PREF_TIMEOUT));
CPPUNIT_ASSERT_EQUAL(std::string("200"), child.get(PREF_TIMEOUT));
- child.remove(PREF_TIMEOUT);
+ child.removeLocal(PREF_TIMEOUT);
CPPUNIT_ASSERT(child.defined(PREF_TIMEOUT));
CPPUNIT_ASSERT(!child.definedLocal(PREF_TIMEOUT));
}
+void OptionTest::testRemove()
+{
+ Option child;
+ auto parent = std::make_shared<Option>();
+ child.setParent(parent);
+
+ child.put(PREF_DIR, "foo");
+ child.put(PREF_TIMEOUT, "200");
+ parent->put(PREF_DIR, "bar");
+ parent->put(PREF_TIMEOUT, "400");
+
+ child.remove(PREF_DIR);
+
+ CPPUNIT_ASSERT(!child.defined(PREF_DIR));
+
+ child.removeLocal(PREF_TIMEOUT);
+
+ CPPUNIT_ASSERT(!child.definedLocal(PREF_TIMEOUT));
+ CPPUNIT_ASSERT(child.defined(PREF_TIMEOUT));
+ CPPUNIT_ASSERT(parent->defined(PREF_TIMEOUT));
+}
+
} // namespace aria2