Make tests of Evoral::Range functions include both endpoints in Range
authorColin Fletcher <colin.m.fletcher@googlemail.com>
Sun, 30 Nov 2014 11:17:58 +0000 (11:17 +0000)
committerColin Fletcher <colin.m.fletcher@googlemail.com>
Mon, 1 Dec 2014 16:52:58 +0000 (16:52 +0000)
Some of the tests for Evoral::RangeList::subtract() assume that ranges
don't contain their end (->to) point. This appears inconsistent with how
they are used elsewhere.

Add some ASCII art comments to the tests to try to clarify what they're
really testing for, and amend subtractTest1, subtractTest4, & subtractTest5
to incorporate the assumption that ranges include their end points.

libs/evoral/test/RangeTest.cpp

index 409e40f013defaa269026aab500368821a7e5165..bbb2bdeb58dfb8d55b8410b371cdb3ed885e1761 100644 (file)
@@ -29,6 +29,13 @@ RangeTest::coalesceTest ()
 void
 RangeTest::subtractTest1 ()
 {
+
+/*         01234567890
+ * fred:   |---------|
+ * jim:      |-|  ||
+ * sheila: ||   ||  ||
+ */
+
        Range<int> fred (0, 10);
 
        RangeList<int> jim;
@@ -45,11 +52,11 @@ RangeTest::subtractTest1 ()
        CPPUNIT_ASSERT_EQUAL (1, i->to);
 
        ++i;
-       CPPUNIT_ASSERT_EQUAL (4, i->from);
+       CPPUNIT_ASSERT_EQUAL (5, i->from);
        CPPUNIT_ASSERT_EQUAL (6, i->to);
 
        ++i;
-       CPPUNIT_ASSERT_EQUAL (8, i->from);
+       CPPUNIT_ASSERT_EQUAL (9, i->from);
        CPPUNIT_ASSERT_EQUAL (10, i->to);
 }
 
@@ -93,6 +100,13 @@ RangeTest::subtractTest3 ()
 void
 RangeTest::subtractTest4 ()
 {
+/*         01234567890
+ * fred:   |---------|
+ * jim:      |-|  ||
+ *                 ||
+ * sheila: ||   ||   |
+ */
+
        Range<int> fred (0, 10);
 
        RangeList<int> jim;
@@ -110,11 +124,11 @@ RangeTest::subtractTest4 ()
        CPPUNIT_ASSERT_EQUAL (1, i->to);
 
        ++i;
-       CPPUNIT_ASSERT_EQUAL (4, i->from);
+       CPPUNIT_ASSERT_EQUAL (5, i->from);
        CPPUNIT_ASSERT_EQUAL (6, i->to);
 
        ++i;
-       CPPUNIT_ASSERT_EQUAL (9, i->from);
+       CPPUNIT_ASSERT_EQUAL (10, i->from);
        CPPUNIT_ASSERT_EQUAL (10, i->to);
 }
 
@@ -125,6 +139,12 @@ RangeTest::subtractTest4 ()
 void
 RangeTest::subtractTest5 ()
 {
+/*         01234567890123
+ * fred:    |----------|
+ * jim:    |---| || |------...
+ * sheila:i     |  |
+ */
+
        Range<int> fred (1, 12);
 
        RangeList<int> jim;
@@ -138,11 +158,11 @@ RangeTest::subtractTest5 ()
        CPPUNIT_ASSERT_EQUAL (size_t (2), s.size ());
 
        RangeList<int>::List::iterator i = s.begin ();
-       CPPUNIT_ASSERT_EQUAL (4, i->from);
+       CPPUNIT_ASSERT_EQUAL (5, i->from);
        CPPUNIT_ASSERT_EQUAL (5, i->to);
 
        ++i;
-       CPPUNIT_ASSERT_EQUAL (7, i->from);
+       CPPUNIT_ASSERT_EQUAL (8, i->from);
        CPPUNIT_ASSERT_EQUAL (8, i->to);
 }