]> granicus.if.org Git - taglib/commitdiff
Separate some tests to make them more specific.
authorTsuda Kageyu <tsuda.kageyu@gmail.com>
Wed, 9 Nov 2016 06:51:33 +0000 (15:51 +0900)
committerTsuda Kageyu <tsuda.kageyu@gmail.com>
Wed, 9 Nov 2016 06:51:33 +0000 (15:51 +0900)
tests/test_list.cpp
tests/test_map.cpp

index e314836a1cfed425ae5da187032fcff54a16b594..1c6d8c4c60de5159d465c72aa1bb33749f7ab6f4 100644 (file)
@@ -32,12 +32,13 @@ using namespace TagLib;
 class TestList : public CppUnit::TestFixture
 {
   CPPUNIT_TEST_SUITE(TestList);
-  CPPUNIT_TEST(testList);
+  CPPUNIT_TEST(testAppend);
+  CPPUNIT_TEST(testDetach);
   CPPUNIT_TEST_SUITE_END();
 
 public:
 
-  void testList()
+  void testAppend()
   {
     List<int> l1;
     List<int> l2;
@@ -51,14 +52,25 @@ public:
     l3.append(2);
     l3.append(3);
     l3.append(4);
+    CPPUNIT_ASSERT_EQUAL(4U, l1.size());
     CPPUNIT_ASSERT(l1 == l3);
+  }
+
+  void testDetach()
+  {
+    List<int> l1;
+    l1.append(1);
+    l1.append(2);
+    l1.append(3);
+    l1.append(4);
 
-    List<int> l4 = l1;
-    List<int>::Iterator it = l4.find(3);
+    List<int> l2 = l1;
+    List<int>::Iterator it = l2.find(3);
     *it = 33;
-    CPPUNIT_ASSERT_EQUAL(l1[2], 3);
-    CPPUNIT_ASSERT_EQUAL(l4[2], 33);
+    CPPUNIT_ASSERT_EQUAL(3,  l1[2]);
+    CPPUNIT_ASSERT_EQUAL(33, l2[2]);
   }
+
 };
 
 CPPUNIT_TEST_SUITE_REGISTRATION(TestList);
index 3096ff6925365369c9c56df48c75f4bb41dc80e8..b5e493b61e90fd461bca4ff0e6c288e696284edd 100644 (file)
@@ -34,6 +34,7 @@ class TestMap : public CppUnit::TestFixture
 {
   CPPUNIT_TEST_SUITE(TestMap);
   CPPUNIT_TEST(testInsert);
+  CPPUNIT_TEST(testDetach);
   CPPUNIT_TEST_SUITE_END();
 
 public:
@@ -42,19 +43,28 @@ public:
   {
     Map<String, int> m1;
     m1.insert("foo", 3);
+    m1.insert("bar", 5);
+    CPPUNIT_ASSERT_EQUAL(2U, m1.size());
     CPPUNIT_ASSERT_EQUAL(3, m1["foo"]);
+    CPPUNIT_ASSERT_EQUAL(5, m1["bar"]);
     m1.insert("foo", 7);
+    CPPUNIT_ASSERT_EQUAL(2U, m1.size());
     CPPUNIT_ASSERT_EQUAL(7, m1["foo"]);
+    CPPUNIT_ASSERT_EQUAL(5, m1["bar"]);
+  }
 
-    m1.insert("alice",  5);
-    m1.insert("bob",    9);
+  void testDetach()
+  {
+    Map<String, int> m1;
+    m1.insert("alice", 5);
+    m1.insert("bob", 9);
     m1.insert("carol", 11);
 
     Map<String, int> m2 = m1;
     Map<String, int>::Iterator it = m2.find("bob");
     (*it).second = 99;
-    CPPUNIT_ASSERT_EQUAL(m1["bob"], 9);
-    CPPUNIT_ASSERT_EQUAL(m2["bob"], 99);
+    CPPUNIT_ASSERT_EQUAL(9,  m1["bob"]);
+    CPPUNIT_ASSERT_EQUAL(99, m2["bob"]);
   }
 
 };