13
0

Make tests of Evoral::Range functions include both endpoints in Range

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.
This commit is contained in:
Colin Fletcher 2014-11-30 11:17:58 +00:00
parent 0c7dd82239
commit 47d329ca40

View 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);
}