summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/tests/InlineVector.cpp
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2008-04-21 16:36:08 +0000
committerAlan Conway <aconway@apache.org>2008-04-21 16:36:08 +0000
commitff757c027f8b7142364360f0ee800c9743355903 (patch)
tree6b493551b7c15c5b8db76dd1005007981ce6a096 /qpid/cpp/src/tests/InlineVector.cpp
parent224a70f13d371068e489625954b7034019a151bb (diff)
downloadqpid-python-ff757c027f8b7142364360f0ee800c9743355903.tar.gz
src/qpid/RangeSet.h: generic set implementation using ranges.
- no heap allocation for simple sets (<= 3 ranges) - binary searches for o(log(n)) performance in complex sets git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@650198 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/tests/InlineVector.cpp')
-rw-r--r--qpid/cpp/src/tests/InlineVector.cpp56
1 files changed, 43 insertions, 13 deletions
diff --git a/qpid/cpp/src/tests/InlineVector.cpp b/qpid/cpp/src/tests/InlineVector.cpp
index 5f1a08759f..7add920cb2 100644
--- a/qpid/cpp/src/tests/InlineVector.cpp
+++ b/qpid/cpp/src/tests/InlineVector.cpp
@@ -66,24 +66,54 @@ QPID_AUTO_TEST_CASE(testCtor) {
}
QPID_AUTO_TEST_CASE(testInsert) {
- Vec v;
- v.push_back(1);
- BOOST_CHECK_EQUAL(v.size(), 1u);
- BOOST_CHECK_EQUAL(v.back(), 1);
- BOOST_CHECK(isInline(v));
+ {
+ Vec v;
+ v.push_back(1);
+ BOOST_CHECK_EQUAL(v.size(), 1u);
+ BOOST_CHECK_EQUAL(v.back(), 1);
+ BOOST_CHECK(isInline(v));
- v.insert(v.begin(), 2);
- BOOST_CHECK_EQUAL(v.size(), 2u);
- BOOST_CHECK_EQUAL(v.back(), 1);
- BOOST_CHECK(isInline(v));
+ v.insert(v.begin(), 2);
+ BOOST_CHECK_EQUAL(v.size(), 2u);
+ BOOST_CHECK_EQUAL(v.back(), 1);
+ BOOST_CHECK(isInline(v));
- v.push_back(3);
- BOOST_CHECK(isInline(v));
+ v.push_back(3);
+ BOOST_CHECK(isInline(v));
- v.push_back(4);
- BOOST_CHECK_EQUAL(v.size(), 4u);
+ v.push_back(4);
+
+ BOOST_CHECK(!isInline(v));
+ }
+ {
+ Vec v(3,42);
+ v.insert(v.begin(), 9);
+ BOOST_CHECK_EQUAL(v.size(), 4u);
+ BOOST_CHECK(!isInline(v));
+ }
+ {
+ Vec v(3,42);
+ v.insert(v.begin()+1, 9);
+ BOOST_CHECK(!isInline(v));
+ BOOST_CHECK_EQUAL(v.size(), 4u);
+ }
+}
+
+QPID_AUTO_TEST_CASE(testAssign) {
+ Vec v(3,42);
+ Vec u;
+ u = v;
+ BOOST_CHECK(isInline(u));
+ u.push_back(4);
+ BOOST_CHECK(!isInline(u));
+ v = u;
BOOST_CHECK(!isInline(v));
}
+QPID_AUTO_TEST_CASE(testResize) {
+ Vec v;
+ v.resize(5);
+ BOOST_CHECK(!isInline(v));
+}
QPID_AUTO_TEST_SUITE_END()