fix RangeTest to account for Range now using exclusive ends, not inclusive
This commit is contained in:
parent
2af00a3f69
commit
7a0da94ba3
@ -11,24 +11,24 @@ void
|
||||
RangeTest::coalesceTest ()
|
||||
{
|
||||
timepos_t t2 (2);
|
||||
timepos_t t4 (4);
|
||||
timepos_t t5 (5);
|
||||
timepos_t t6 (6);
|
||||
timepos_t t8 (8);
|
||||
timepos_t t7 (7);
|
||||
timepos_t t9 (9);
|
||||
|
||||
RangeList fred;
|
||||
fred.add (Range (t2, t4));
|
||||
fred.add (Range (t5, t6));
|
||||
fred.add (Range (t6, t8));
|
||||
fred.add (Range (t2, t5));
|
||||
fred.add (Range (t5, t7));
|
||||
fred.add (Range (t6, t9));
|
||||
|
||||
RangeList::List jim = fred.get ();
|
||||
|
||||
RangeList::List::iterator i = jim.begin ();
|
||||
CPPUNIT_ASSERT_EQUAL (t2, i->start());
|
||||
CPPUNIT_ASSERT_EQUAL (t4, i->end());
|
||||
CPPUNIT_ASSERT_EQUAL (t5, i->end());
|
||||
++i;
|
||||
CPPUNIT_ASSERT_EQUAL (t5, i->start());
|
||||
CPPUNIT_ASSERT_EQUAL (t8, i->end());
|
||||
CPPUNIT_ASSERT_EQUAL (t9, i->end());
|
||||
}
|
||||
|
||||
/* Basic subtraction of a few smaller ranges from a larger one */
|
||||
@ -56,8 +56,8 @@ RangeTest::subtractTest1 ()
|
||||
Range fred (t0, t10);
|
||||
|
||||
RangeList jim;
|
||||
jim.add (Range (t2, t4));
|
||||
jim.add (Range (t7, t8));
|
||||
jim.add (Range (t2, t5));
|
||||
jim.add (Range (t7, t9));
|
||||
|
||||
RangeList sheila = fred.subtract (jim);
|
||||
|
||||
@ -66,11 +66,11 @@ RangeTest::subtractTest1 ()
|
||||
|
||||
RangeList::List::iterator i = s.begin ();
|
||||
CPPUNIT_ASSERT_EQUAL (t0, i->start());
|
||||
CPPUNIT_ASSERT_EQUAL (t1, i->end()); // XXX -> 2
|
||||
CPPUNIT_ASSERT_EQUAL (t2, i->end()); // XXX -> 2
|
||||
|
||||
++i;
|
||||
CPPUNIT_ASSERT_EQUAL (t5, i->start()); // XXX -> 4
|
||||
CPPUNIT_ASSERT_EQUAL (t6, i->end()); // XXX -> 7
|
||||
CPPUNIT_ASSERT_EQUAL (t7, i->end()); // XXX -> 7
|
||||
|
||||
++i;
|
||||
CPPUNIT_ASSERT_EQUAL (t9, i->start()); // XXX -> 8
|
||||
@ -135,6 +135,7 @@ RangeTest::subtractTest4 ()
|
||||
timepos_t t8 (8);
|
||||
timepos_t t9 (9);
|
||||
timepos_t t10 (10);
|
||||
timepos_t t11 (11);
|
||||
|
||||
/* 01234567890
|
||||
* fred: |---------|
|
||||
@ -143,12 +144,12 @@ RangeTest::subtractTest4 ()
|
||||
* sheila: || || |
|
||||
*/
|
||||
|
||||
Range fred (t0, t10);
|
||||
Range fred (t0, t11);;
|
||||
|
||||
RangeList jim;
|
||||
jim.add (Range (t2, t4));
|
||||
jim.add (Range (t7, t8));
|
||||
jim.add (Range (t8, t9));
|
||||
jim.add (Range (t2, t5));
|
||||
jim.add (Range (t7, t9));
|
||||
jim.add (Range (t8, t10));
|
||||
|
||||
RangeList sheila = fred.subtract (jim);
|
||||
|
||||
@ -157,15 +158,15 @@ RangeTest::subtractTest4 ()
|
||||
|
||||
RangeList::List::iterator i = s.begin ();
|
||||
CPPUNIT_ASSERT_EQUAL (t0, i->start());
|
||||
CPPUNIT_ASSERT_EQUAL (t1, i->end());
|
||||
CPPUNIT_ASSERT_EQUAL (t2, i->end());
|
||||
|
||||
++i;
|
||||
CPPUNIT_ASSERT_EQUAL (t5, i->start());
|
||||
CPPUNIT_ASSERT_EQUAL (t6, i->end());
|
||||
CPPUNIT_ASSERT_EQUAL (t7, i->end());
|
||||
|
||||
++i;
|
||||
CPPUNIT_ASSERT_EQUAL (t10, i->start());
|
||||
CPPUNIT_ASSERT_EQUAL (t10, i->end());
|
||||
CPPUNIT_ASSERT_EQUAL (t11, i->end());
|
||||
}
|
||||
|
||||
/* A bit like subtractTest1, except some of the ranges
|
||||
@ -183,8 +184,8 @@ RangeTest::subtractTest5 ()
|
||||
timepos_t t7 (7);
|
||||
timepos_t t8 (8);
|
||||
timepos_t t9 (9);
|
||||
timepos_t t12 (12);
|
||||
timepos_t t42 (42);
|
||||
timepos_t t13 (13);
|
||||
timepos_t t43 (43);
|
||||
|
||||
/* 01234567890123
|
||||
* fred: |----------|
|
||||
@ -192,12 +193,12 @@ RangeTest::subtractTest5 ()
|
||||
* sheila:i | |
|
||||
*/
|
||||
|
||||
Range fred (t1, t12);
|
||||
Range fred (t1, t13);
|
||||
|
||||
RangeList jim;
|
||||
jim.add (Range (t0, t4));
|
||||
jim.add (Range (t6, t7));
|
||||
jim.add (Range (t9, t42));
|
||||
jim.add (Range (t0, t5));
|
||||
jim.add (Range (t6, t8));
|
||||
jim.add (Range (t9, t43));
|
||||
|
||||
RangeList sheila = fred.subtract (jim);
|
||||
|
||||
@ -206,11 +207,11 @@ RangeTest::subtractTest5 ()
|
||||
|
||||
RangeList::List::iterator i = s.begin ();
|
||||
CPPUNIT_ASSERT_EQUAL (t5, i->start());
|
||||
CPPUNIT_ASSERT_EQUAL (t5, i->end());
|
||||
CPPUNIT_ASSERT_EQUAL (t6, i->end());
|
||||
|
||||
++i;
|
||||
CPPUNIT_ASSERT_EQUAL (t8, i->start());
|
||||
CPPUNIT_ASSERT_EQUAL (t8, i->end());
|
||||
CPPUNIT_ASSERT_EQUAL (t9, i->end());
|
||||
}
|
||||
|
||||
/* Test coverage() with all possible types of overlap.
|
||||
@ -222,58 +223,58 @@ RangeTest::coverageTest ()
|
||||
#define coverage(A0, A1, B0, B1) Range(timepos_t(A0), timepos_t(A1)).coverage(timepos_t(B0), timepos_t(B1))
|
||||
|
||||
// b starts before a
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 7, 1, 1), OverlapNone);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 7, 1, 2), OverlapNone);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 7, 1, 3), OverlapStart); // XXX fails
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 7, 1, 5), OverlapStart);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 7, 1, 7), OverlapExternal);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 7, 1, 9), OverlapExternal);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage (3, 8, 1, 2), OverlapNone);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage (3, 8, 1, 3), OverlapNone);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage (3, 8, 1, 4), OverlapStart); // XXX fails
|
||||
CPPUNIT_ASSERT_EQUAL (coverage (3, 8, 1, 6), OverlapStart);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage (3, 8, 1, 8), OverlapExternal);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage (3, 8, 1, 10), OverlapExternal);
|
||||
|
||||
// b starts at a
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 7, 3, 3), OverlapStart); // XXX fails
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 7, 3, 5), OverlapStart);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 7, 3, 7), OverlapExternal);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 7, 3, 9), OverlapExternal);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage (3, 8, 3, 4), OverlapStart); // XXX fails
|
||||
CPPUNIT_ASSERT_EQUAL (coverage (3, 8, 3, 6), OverlapStart);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage (3, 8, 3, 8), OverlapExternal);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage (3, 8, 3, 10), OverlapExternal);
|
||||
|
||||
// b starts inside a
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 7, 4, 4), OverlapInternal); // XXX fails
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 7, 4, 6), OverlapInternal);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 7, 4, 7), OverlapEnd);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 7, 4, 8), OverlapEnd);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage (3, 8, 4, 5), OverlapInternal); // XXX fails
|
||||
CPPUNIT_ASSERT_EQUAL (coverage (3, 8, 4, 7), OverlapInternal);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage (3, 8, 4, 8), OverlapEnd);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage (3, 8, 4, 9), OverlapEnd);
|
||||
|
||||
// b starts at end of a
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 7, 7, 7), OverlapEnd); // XXX fails
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 7, 7, 9), OverlapEnd); // XXX fails
|
||||
CPPUNIT_ASSERT_EQUAL (coverage (3, 8, 7, 8), OverlapEnd); // XXX fails
|
||||
CPPUNIT_ASSERT_EQUAL (coverage (3, 8, 7, 10), OverlapEnd); // XXX fails
|
||||
|
||||
// b starts after end of a
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 7, 8, 8), OverlapNone);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 7, 8, 9), OverlapNone);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage (3, 8, 8, 9), OverlapNone);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage (3, 8, 8, 10), OverlapNone);
|
||||
|
||||
// zero-length range a
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 3, 2, 4), OverlapExternal); // XXX fails
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 3, 1, 2), OverlapNone);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 3, 3, 3), OverlapExternal); // XXX fails
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 3, 8, 9), OverlapNone);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 4, 2, 5), OverlapExternal); // XXX fails
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 4, 1, 3), OverlapNone);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 4, 3, 4), OverlapExternal); // XXX fails
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 4, 8, 10), OverlapNone);
|
||||
|
||||
// negative length range a
|
||||
// XXX these are debatable - should we just consider start & end to be
|
||||
// swapped if end < start?
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(4, 3, 1, 2), OverlapNone);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(4, 3, 2, 3), OverlapNone);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(4, 3, 2, 4), OverlapNone);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(4, 3, 3, 3), OverlapNone);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(4, 3, 8, 9), OverlapNone);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(4, 4, 1, 3), OverlapNone);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(4, 4, 2, 4), OverlapNone);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(4, 4, 2, 5), OverlapNone);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(4, 4, 3, 4), OverlapNone);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(4, 4, 8, 10), OverlapNone);
|
||||
|
||||
// negative length range b
|
||||
// b starts before a
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 7, 1, 0), OverlapNone);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 8, 1, 1), OverlapNone);
|
||||
// b starts at a
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 7, 3, 2), OverlapNone);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 8, 3, 3), OverlapNone);
|
||||
// b starts inside a
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 7, 4, 3), OverlapNone);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage (3, 8, 4, 4), OverlapNone);
|
||||
// b starts at end of a
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 7, 7, 5), OverlapNone);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage (3, 8, 7, 6), OverlapNone);
|
||||
// b starts after end of a
|
||||
CPPUNIT_ASSERT_EQUAL (coverage(3, 7, 8, 7), OverlapNone);
|
||||
CPPUNIT_ASSERT_EQUAL (coverage (3, 8, 8, 8), OverlapNone);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user