diff options
| author | Alan Conway <aconway@apache.org> | 2008-04-08 19:53:07 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2008-04-08 19:53:07 +0000 |
| commit | e72e25abd1272c4e9489f7efd5bc02c4ecf0b5cd (patch) | |
| tree | 2d32b5153aefb4059ec410118ffd80f37d64b6bd /cpp/src/tests | |
| parent | 43aaed1c309c8c7ff95695109cf49b5b9157f4b6 (diff) | |
| download | qpid-python-e72e25abd1272c4e9489f7efd5bc02c4ecf0b5cd.tar.gz | |
Summary: added 0-10 Array encoding and decoding.
rubygen/0-10/allsegmenttypes.rb: test header,body and each command and control type.
rubygen/0-10/specification.rb: enable packed encoding.
src/qpid/amqp_0_10/Array.h: Implemented array and array domains.
src/qpid/amqp_0_10/Codec.h: enable litte-endian encoding for pack bits
src/qpid/amqp_0_10/Packer.h: use litte-endian encoding for pack bits
src/qpid/amqp_0_10/Unit.cpp, .h: setting flags, fix op <<.
src/qpid/amqp_0_10/complex_types.cpp, .h: added op <<
src/qpid/framing/Blob.h: copy-object template constructor.
src/tests/amqp_0_10/serialize.cpp:
- test Array
Minor adjustments for new Array.h:
src/qpid/amqp_0_10/Map.cpp
src/qpid/amqp_0_10/Map.h
src/qpid/amqp_0_10/UnknownType.h
src/qpid/amqp_0_10/built_in_types.h
src/qpid/amqp_0_10/Body.h
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@646054 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests')
| -rw-r--r-- | cpp/src/tests/amqp_0_10/Map.cpp | 3 | ||||
| -rw-r--r-- | cpp/src/tests/amqp_0_10/serialize.cpp | 85 | ||||
| -rwxr-xr-x | cpp/src/tests/python_tests | 3 |
3 files changed, 74 insertions, 17 deletions
diff --git a/cpp/src/tests/amqp_0_10/Map.cpp b/cpp/src/tests/amqp_0_10/Map.cpp index ad6f38b5d7..dcba6e38c2 100644 --- a/cpp/src/tests/amqp_0_10/Map.cpp +++ b/cpp/src/tests/amqp_0_10/Map.cpp @@ -19,7 +19,8 @@ * */ #include "unit_test.h" -#include "qpid/amqp_0_10/Map.h" +#include "qpid/amqp_0_10/all_built_in_types.h" +//FIXME aconway 2008-04-08: #include "qpid/amqp_0_10/allSegmentTypes.h" #include "qpid/amqp_0_10/Codec.h" #include <iostream> diff --git a/cpp/src/tests/amqp_0_10/serialize.cpp b/cpp/src/tests/amqp_0_10/serialize.cpp index 16559b3516..e479151ec0 100644 --- a/cpp/src/tests/amqp_0_10/serialize.cpp +++ b/cpp/src/tests/amqp_0_10/serialize.cpp @@ -20,6 +20,10 @@ */ #include "unit_test.h" + +#include "qpid/framing/AMQFrame.h" +#include "qpid/framing/Buffer.h" + #include "qpid/amqp_0_10/Packer.h" #include "qpid/amqp_0_10/built_in_types.h" #include "qpid/amqp_0_10/Codec.h" @@ -28,6 +32,7 @@ #include "qpid/amqp_0_10/FrameHeader.h" #include "qpid/amqp_0_10/Map.h" #include "qpid/amqp_0_10/Unit.h" +#include "tests/allSegmentTypes.h" #include <boost/test/test_case_template.hpp> #include <boost/type_traits/is_arithmetic.hpp> @@ -266,21 +271,71 @@ BOOST_AUTO_TEST_CASE(testUnit) { BOOST_CHECK_EQUAL(data, data2); } -// FIXME aconway 2008-04-07: TODO -// BOOST_AUTO_TEST_CASE(testAllSegmentTypes) { -// string data; -// int n = allSegmentTypes(Codec::encode(data)); - -// string data2; -// Codec::Decoder<string::iterator> decode(data.begin(), data.size()); -// while (decode.pos() != data.end()) { -// Unit unit; -// decode(unit); -// Codec::encode(back_insert(data)); -// --n; -// } -// BOOST_CHECK_EQUAL(n, 0); -// BOOST_CHECK_EQUAL(data, data2); +BOOST_AUTO_TEST_CASE(testArray) { + ArrayDomain<char> a; + a.resize(3, 'x'); + string data; + Codec::encode(back_inserter(data))(a); + + ArrayDomain<char> b; + Codec::decode(data.begin())(b); + BOOST_CHECK_EQUAL(b.size(), 3u); + string data3; + Codec::encode(back_inserter(data3))(a); + BOOST_CHECK_EQUAL(data, data3); + + Array x; + Codec::decode(data.begin())(x); + BOOST_CHECK_EQUAL(x.size(), 3u); + BOOST_CHECK_EQUAL(x[0].size(), 1u); + BOOST_CHECK_EQUAL(*x[0].begin(), 'x'); + BOOST_CHECK_EQUAL(*x[2].begin(), 'x'); + + string data2; + Codec::encode(back_inserter(data2))(x); + BOOST_CHECK_EQUAL(data,data2); +} + +struct RecodeUnit { + template <class T> + void operator() (const T& t) { + using qpid::framing::Buffer; + using qpid::framing::AMQFrame; + + Unit u(t); + connection::Start s; + + string data; + Codec::encode(back_inserter(data))(u.getHeader())(u); + data.push_back(char(0xCE)); // Preview end-of-frame + + Buffer buf(&data[0], data.size()); + AMQFrame f; + f.decode(buf); + + string data2(f.size(), ' '); + Buffer buf2(&data2[0], data.size()); + f.encode(buf2); + + BOOST_CHECK_EQUAL(data, data2); + + Codec::Decoder<string::iterator> decode(data2.begin()); + FrameHeader h; + decode(h); + Unit u2(h); + decode(u2); + + string data3; + Codec::encode(back_inserter(data3))(u.getHeader())(u); + + BOOST_CHECK_EQUAL(data3, data2); + } +}; + +// FIXME aconway 2008-04-08: TODO +// BOOST_AUTO_TEST_CASE(testSerializeAllSegmentTypes) { +// RecodeUnit recode; +// allSegmentTypes(recode); // } QPID_AUTO_TEST_SUITE_END() diff --git a/cpp/src/tests/python_tests b/cpp/src/tests/python_tests index a3478eac1c..f35cb16480 100755 --- a/cpp/src/tests/python_tests +++ b/cpp/src/tests/python_tests @@ -3,10 +3,11 @@ QPID_PORT=${QPID_PORT:-5672} PYTHON_TESTS=${PYTHON_TESTS:-$*} + run() { SPEC=$1 FAILING=$2 - ./run-tests --skip-self-test -v -s $SPEC -I $FAILING -b localhost:$QPID_PORT $PYTHON_TESTS || exit 1 + ./run-tests --skip-self-test -v -s $SPEC -I $FAILING -b localhost:$QPID_PORT $PYTHON_TESTS || { echo "FAIL python tests for $SPEC"; exit 1; } } if test -d ../../../python ; then |
