summaryrefslogtreecommitdiff
path: root/cpp/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/tests')
-rw-r--r--cpp/src/tests/Makefile.am6
-rw-r--r--cpp/src/tests/amqp_0_10/ProxyTemplate.cpp (renamed from cpp/src/tests/ProxyTemplate.cpp)0
-rw-r--r--cpp/src/tests/amqp_0_10/apply.cpp (renamed from cpp/src/tests/apply.cpp)0
-rw-r--r--cpp/src/tests/amqp_0_10/serialize.cpp (renamed from cpp/src/tests/serialize.cpp)34
4 files changed, 38 insertions, 2 deletions
diff --git a/cpp/src/tests/Makefile.am b/cpp/src/tests/Makefile.am
index ae47241e67..fd3f67e99f 100644
--- a/cpp/src/tests/Makefile.am
+++ b/cpp/src/tests/Makefile.am
@@ -39,8 +39,10 @@ unit_test_SOURCES= unit_test.cpp unit_test.h \
ISList.cpp IList.cpp \
ClientSessionTest.cpp \
SequenceSet.cpp \
- serialize.cpp \
- ProxyTemplate.cpp apply.cpp BoundedIterator.cpp \
+ amqp_0_10/serialize.cpp \
+ amqp_0_10/ProxyTemplate.cpp \
+ amqp_0_10/apply.cpp \
+ BoundedIterator.cpp \
IncompleteMessageList.cpp \
amqp_0_10/Map.cpp
diff --git a/cpp/src/tests/ProxyTemplate.cpp b/cpp/src/tests/amqp_0_10/ProxyTemplate.cpp
index cab87b6511..cab87b6511 100644
--- a/cpp/src/tests/ProxyTemplate.cpp
+++ b/cpp/src/tests/amqp_0_10/ProxyTemplate.cpp
diff --git a/cpp/src/tests/apply.cpp b/cpp/src/tests/amqp_0_10/apply.cpp
index 450aeac356..450aeac356 100644
--- a/cpp/src/tests/apply.cpp
+++ b/cpp/src/tests/amqp_0_10/apply.cpp
diff --git a/cpp/src/tests/serialize.cpp b/cpp/src/tests/amqp_0_10/serialize.cpp
index 386f721338..a6cb28caee 100644
--- a/cpp/src/tests/serialize.cpp
+++ b/cpp/src/tests/amqp_0_10/serialize.cpp
@@ -97,6 +97,40 @@ BOOST_AUTO_TEST_CASE(testNetworkByteOrder) {
BOOST_CHECK_EQUAL(s, s2);
}
+BOOST_AUTO_TEST_CASE(testSetLimit) {
+ typedef Codec::Encoder<back_insert_iterator<string> > Encoder;
+ string data;
+ Encoder encode(back_inserter(data), 3);
+ encode('1')('2')('3');
+ try {
+ encode('4');
+ BOOST_FAIL("Expected exception");
+ } catch (...) {} // FIXME aconway 2008-04-03: catch proper exception
+ BOOST_CHECK_EQUAL(data, "123");
+}
+
+BOOST_AUTO_TEST_CASE(testScopedLimit) {
+ typedef Codec::Encoder<back_insert_iterator<string> > Encoder;
+ string data;
+ Encoder encode(back_inserter(data), 10);
+ encode(Str8("123")); // 4 bytes
+ {
+ Encoder::ScopedLimit l(encode, 3);
+ encode('a')('b')('c');
+ try {
+ encode('d');
+ BOOST_FAIL("Expected exception");
+ } catch(...) {} // FIXME aconway 2008-04-03: catch proper exception
+ }
+ BOOST_CHECK_EQUAL(data, "\003123abc");
+ encode('x')('y')('z');
+ try {
+ encode('!');
+ BOOST_FAIL("Expected exception");
+ } catch(...) {} // FIXME aconway 2008-04-03: catch proper exception
+ BOOST_CHECK_EQUAL(data.size(), 10u);
+}
+
// Assign test values to the various types.
void testValue(bool& b) { b = true; }
void testValue(Bit&) { }