summaryrefslogtreecommitdiff
path: root/cpp/src/tests
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2008-04-23 15:31:57 +0000
committerAlan Conway <aconway@apache.org>2008-04-23 15:31:57 +0000
commit100150d5f53264f8cef2773eb7415291dbadb238 (patch)
tree821389c09105a707c918e43be536ed660ca022e5 /cpp/src/tests
parentc25d4ec64b056134bb730932b30f382ca3caa008 (diff)
downloadqpid-python-100150d5f53264f8cef2773eb7415291dbadb238.tar.gz
- SequenceSet implemented on RangeSet.
- Reduced #include dependencides on SequenceSet.h git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@650906 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests')
-rw-r--r--cpp/src/tests/Makefile.am2
-rw-r--r--cpp/src/tests/RangeSet.cpp24
-rw-r--r--cpp/src/tests/SequenceSet.cpp2
3 files changed, 26 insertions, 2 deletions
diff --git a/cpp/src/tests/Makefile.am b/cpp/src/tests/Makefile.am
index bd020e4f77..c5baf5c73b 100644
--- a/cpp/src/tests/Makefile.am
+++ b/cpp/src/tests/Makefile.am
@@ -1,4 +1,4 @@
-AM_CXXFLAGS = $(WARNING_CFLAGS) $(CPPUNIT_CXXFLAGS) $(APR_CXXFLAGS) -DBOOST_TEST_DYN_LINK
+AM_CXXFLAG = $(WARNING_CFLAGS) $(CPPUNIT_CXXFLAGS) $(APR_CXXFLAGS) -DBOOST_TEST_DYN_LINK
INCLUDES = -I$(srcdir)/.. -I$(srcdir)/../gen -I$(top_builddir)/src/gen
abs_builddir=@abs_builddir@
diff --git a/cpp/src/tests/RangeSet.cpp b/cpp/src/tests/RangeSet.cpp
index e16339ab84..9c602de78d 100644
--- a/cpp/src/tests/RangeSet.cpp
+++ b/cpp/src/tests/RangeSet.cpp
@@ -63,6 +63,22 @@ QPID_AUTO_TEST_CASE(testRangeSetAddRange) {
BOOST_CHECK(r.back() == 6);
}
+QPID_AUTO_TEST_CASE(testRangeSetAddSet) {
+ TestRangeSet r;
+ TestRangeSet s = TestRangeSet(0,3)+TestRange(5,10);
+ r += s;
+ BOOST_CHECK_EQUAL(r,s);
+ r += TestRangeSet(3,5) + TestRange(7,12) + 15;
+ BOOST_CHECK_EQUAL(r, TestRangeSet(0,12) + 15);
+
+ r.clear();
+ BOOST_CHECK(r.empty());
+ r += TestRange::makeClosed(6,10);
+ BOOST_CHECK_EQUAL(r, TestRangeSet(6,11));
+ r += TestRangeSet(2,6)+8;
+ BOOST_CHECK_EQUAL(r, TestRangeSet(2,11));
+}
+
QPID_AUTO_TEST_CASE(testRangeSetIterate) {
TestRangeSet r;
(((r += 1) += 10) += TestRange(4,7)) += 2;
@@ -74,12 +90,14 @@ QPID_AUTO_TEST_CASE(testRangeSetIterate) {
}
QPID_AUTO_TEST_CASE(testRangeSetRemove) {
+ // points
BOOST_CHECK_EQUAL(TestRangeSet(0,5)-3, TestRangeSet(0,3)+TestRange(4,5));
BOOST_CHECK_EQUAL(TestRangeSet(1,5)-5, TestRangeSet(1,5));
BOOST_CHECK_EQUAL(TestRangeSet(1,5)-0, TestRangeSet(1,5));
TestRangeSet r(TestRangeSet(0,5)+TestRange(10,15)+TestRange(20,25));
+ // TestRanges
BOOST_CHECK_EQUAL(r-TestRange(0,5), TestRangeSet(10,15)+TestRange(20,25));
BOOST_CHECK_EQUAL(r-TestRange(10,15), TestRangeSet(0,5)+TestRange(20,25));
BOOST_CHECK_EQUAL(r-TestRange(20,25), TestRangeSet(0,5)+TestRange(10,15));
@@ -89,16 +107,22 @@ QPID_AUTO_TEST_CASE(testRangeSetRemove) {
BOOST_CHECK_EQUAL(r-TestRange(-5, 7), TestRangeSet(10,15)+TestRange(20,25));
BOOST_CHECK_EQUAL(r-TestRange(8,19), TestRangeSet(0,5)+TestRange(20,25));
BOOST_CHECK_EQUAL(r-TestRange(17,30), TestRangeSet(0,5)+TestRange(10,15));
+ BOOST_CHECK_EQUAL(r-TestRange(17,30), TestRangeSet(0,5)+TestRange(10,15));
BOOST_CHECK_EQUAL(r-TestRange(-5, 5), TestRangeSet(10,15)+TestRange(20,25));
BOOST_CHECK_EQUAL(r-TestRange(10,19), TestRangeSet(0,5)+TestRange(20,25));
BOOST_CHECK_EQUAL(r-TestRange(18,25), TestRangeSet(0,5)+TestRange(10,15));
+ BOOST_CHECK_EQUAL(r-TestRange(23,25), TestRangeSet(0,5)+TestRange(10,15)+TestRange(20,23));
BOOST_CHECK_EQUAL(r-TestRange(-3, 3), TestRangeSet(3,5)+TestRange(10,15)+TestRange(20,25));
BOOST_CHECK_EQUAL(r-TestRange(3, 7), TestRangeSet(0,2)+TestRange(10,15)+TestRange(20,25));
BOOST_CHECK_EQUAL(r-TestRange(3, 12), TestRangeSet(0,3)+TestRange(12,15)+TestRange(20,25));
BOOST_CHECK_EQUAL(r-TestRange(3, 22), TestRangeSet(12,15)+TestRange(22,25));
BOOST_CHECK_EQUAL(r-TestRange(12, 22), TestRangeSet(0,5)+TestRange(10,11)+TestRange(22,25));
+
+ // Sets
+ BOOST_CHECK_EQUAL(r-(TestRangeSet(-1,6)+TestRange(11,14)+TestRange(23,25)),
+ TestRangeSet(10,11)+TestRange(14,15)+TestRange(20,23));
}
QPID_AUTO_TEST_CASE(testRangeContaining) {
diff --git a/cpp/src/tests/SequenceSet.cpp b/cpp/src/tests/SequenceSet.cpp
index c204a8b5c5..1cc66fa55a 100644
--- a/cpp/src/tests/SequenceSet.cpp
+++ b/cpp/src/tests/SequenceSet.cpp
@@ -80,7 +80,7 @@ QPID_AUTO_TEST_CASE(testAdd) {
BOOST_CHECK(!t.contains(i));
for (uint32_t i = 2; i <= 10; i++)
- BOOST_CHECK(t.contains(i));
+ BOOST_CHECK_MESSAGE(t.contains(i), t << " contains " << i);
RangeExpectations().expect(2, 10).check(t);
}