diff options
author | Alan Conway <aconway@apache.org> | 2008-04-03 22:19:47 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2008-04-03 22:19:47 +0000 |
commit | 83026d0f664b69cc8ed74b1ed52df212f0a66ab7 (patch) | |
tree | 757296a69f9499afb5e11202e9a89846c682b985 /cpp/src/tests | |
parent | 39c9c45c38d82914324cbdf4c89d5ad92d9f8e6d (diff) | |
download | qpid-python-83026d0f664b69cc8ed74b1ed52df212f0a66ab7.tar.gz |
qpid/Serializer.h, qpid/amqp_0_10/Codec.h:
- serializer enforces overrunning encode/decode limits.
tests/amqp_0_10: Moved unit tests for amqp_0_10 namespace into amqp_0_10 directory.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@644533 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests')
-rw-r--r-- | cpp/src/tests/Makefile.am | 6 | ||||
-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&) { } |