summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/tests
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2008-04-15 18:23:55 +0000
committerAlan Conway <aconway@apache.org>2008-04-15 18:23:55 +0000
commitcaceb56988996f722585125c1990233aff0a1166 (patch)
tree952400e6d7cd1d0e760c54f96c5b853bf4ad121d /qpid/cpp/src/tests
parentdda43816958847a6514495a9d823a025f53d83d1 (diff)
downloadqpid-python-caceb56988996f722585125c1990233aff0a1166.tar.gz
Correct Struct32 encoding: size/code/data.
Proper re-encoding for unknown struct codes. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@648362 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/tests')
-rw-r--r--qpid/cpp/src/tests/amqp_0_10/serialize.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/qpid/cpp/src/tests/amqp_0_10/serialize.cpp b/qpid/cpp/src/tests/amqp_0_10/serialize.cpp
index f533590622..1c569e4ae8 100644
--- a/qpid/cpp/src/tests/amqp_0_10/serialize.cpp
+++ b/qpid/cpp/src/tests/amqp_0_10/serialize.cpp
@@ -221,10 +221,10 @@ BOOST_AUTO_TEST_CASE(testStruct32) {
string data;
Codec::encode(back_inserter(data))(s);
-// uint32_t structSize; // Starts with size
-// Codec::decode(data.begin())(structSize);
-// BOOST_CHECK_EQUAL(structSize, Codec::size(dp) + 4); // code+pack
-// BOOST_CHECK_EQUAL(structSize, data.size()-4);
+ uint32_t structSize; // Starts with size
+ Codec::decode(data.begin())(structSize);
+ BOOST_CHECK_EQUAL(structSize, Codec::size(dp) + 2); // +2 for code
+ BOOST_CHECK_EQUAL(structSize, data.size()-4); // encoded body
BOOST_CHECK_EQUAL(data.size(), Codec::size(s));
Struct32 s2;
@@ -233,15 +233,19 @@ BOOST_AUTO_TEST_CASE(testStruct32) {
BOOST_REQUIRE(dp2);
BOOST_CHECK_EQUAL(dp2->priority, message::MEDIUM);
BOOST_CHECK_EQUAL(dp2->routingKey, "foo");
+}
+BOOST_AUTO_TEST_CASE(testStruct32Unknown) {
// Verify we can recode an unknown struct unchanged.
-// data.clear();
-// Codec::encode(back_inserter(data))(uint32_t(10));
-// data.append(10, 'X');
-// Codec::decode(data.begin())(s2);
-// string data2;
-// Codec::decode(back_inserter(data2));
- // BOOST_CHECK_EQUAL(data, data2);
+ Struct32 s;
+ string data;
+ Codec::encode(back_inserter(data))(uint32_t(10));
+ data.append(10, 'X');
+ Codec::decode(data.begin())(s);
+ string data2;
+ Codec::encode(back_inserter(data2))(s);
+ BOOST_CHECK_EQUAL(data.size(), data2.size());
+ BOOST_CHECK_EQUAL(data, data2);
}
struct DummyPacked {