diff options
Diffstat (limited to 'qpid/cpp/src/tests')
-rw-r--r-- | qpid/cpp/src/tests/FramingTest.cpp | 11 | ||||
-rw-r--r-- | qpid/cpp/src/tests/Variant.cpp | 26 | ||||
-rw-r--r-- | qpid/cpp/src/tests/testagent.xml | 8 |
3 files changed, 41 insertions, 4 deletions
diff --git a/qpid/cpp/src/tests/FramingTest.cpp b/qpid/cpp/src/tests/FramingTest.cpp index 3d0fa0c0de..f8795316cc 100644 --- a/qpid/cpp/src/tests/FramingTest.cpp +++ b/qpid/cpp/src/tests/FramingTest.cpp @@ -151,6 +151,17 @@ QPID_AUTO_TEST_CASE(testMessageCancelBodyFrame) BOOST_CHECK_EQUAL(tostring(in), tostring(out)); } +QPID_AUTO_TEST_CASE(badStrings) { + char data[(65535 + 2) + (255 + 1)]; + Buffer b(data, sizeof(data)); + BOOST_CHECK_THROW(b.putShortString(std::string(256, 'X')), + Exception); + BOOST_CHECK_THROW(b.putMediumString(std::string(65536, 'X')), + Exception); + b.putShortString(std::string(255, 'X')); + b.putMediumString(std::string(65535, 'X')); +} + QPID_AUTO_TEST_SUITE_END() }} // namespace qpid::tests diff --git a/qpid/cpp/src/tests/Variant.cpp b/qpid/cpp/src/tests/Variant.cpp index 596bde36de..b4188f524b 100644 --- a/qpid/cpp/src/tests/Variant.cpp +++ b/qpid/cpp/src/tests/Variant.cpp @@ -20,10 +20,12 @@ */ #include <iostream> #include "qpid/types/Variant.h" +#include "qpid/amqp_0_10/Codecs.h" #include "unit_test.h" using namespace qpid::types; +using namespace qpid::amqp_0_10; namespace qpid { namespace tests { @@ -686,6 +688,30 @@ QPID_AUTO_TEST_CASE(testEncoding) BOOST_CHECK_EQUAL(map.asMap()["a"].getEncoding(), map.asMap()["b"].getEncoding()); } +QPID_AUTO_TEST_CASE(testBufferEncoding) +{ + Variant a("abc"); + a.setEncoding("utf8"); + std::string buffer; + + Variant::Map inMap, outMap; + inMap["a"] = a; + + MapCodec::encode(inMap, buffer); + MapCodec::decode(buffer, outMap); + BOOST_CHECK_EQUAL(inMap, outMap); + + inMap["b"] = Variant(std::string(65535, 'X')); + inMap["b"].setEncoding("utf16"); + MapCodec::encode(inMap, buffer); + MapCodec::decode(buffer, outMap); + BOOST_CHECK_EQUAL(inMap, outMap); + + inMap["fail"] = Variant(std::string(65536, 'X')); + inMap["fail"].setEncoding("utf16"); + BOOST_CHECK_THROW(MapCodec::encode(inMap, buffer), std::exception); +} + QPID_AUTO_TEST_SUITE_END() }} // namespace qpid::tests diff --git a/qpid/cpp/src/tests/testagent.xml b/qpid/cpp/src/tests/testagent.xml index 8be21b7e68..0b1436f999 100644 --- a/qpid/cpp/src/tests/testagent.xml +++ b/qpid/cpp/src/tests/testagent.xml @@ -28,13 +28,13 @@ This class represents a parent object - <property name="name" type="sstr" access="RC" index="y"/> + <property name="name" type="lstr" access="RC" index="y"/> <statistic name="state" type="sstr" desc="Operational state of the link"/> <statistic name="count" type="count64" unit="tick" desc="Counter that increases monotonically"/> <method name="create_child" desc="Create child object"> - <arg name="name" dir="I" type="sstr"/> + <arg name="name" dir="I" type="lstr"/> <arg name="childRef" dir="O" type="objId"/> </method> </class> @@ -47,7 +47,7 @@ --> <class name="Child"> <property name="ParentRef" type="objId" references="Parent" access="RC" index="y" parentRef="y"/> - <property name="name" type="sstr" access="RC" index="y"/> + <property name="name" type="lstr" access="RC" index="y"/> <statistic name="count" type="count64" unit="tick" desc="Counter that increases monotonically"/> @@ -55,7 +55,7 @@ </class> <eventArguments> - <arg name="childName" type="sstr"/> + <arg name="childName" type="lstr"/> </eventArguments> <event name="ChildCreated" args="childName"/> |