From a15b7ff7ba6e7ccd85bdd0042dd7ea65d6840e99 Mon Sep 17 00:00:00 2001 From: Jonathan Robie Date: Thu, 16 Sep 2010 14:52:37 +0000 Subject: Fixes parsing problem with empty lists ('[]') in addresses, which previously raised an exception and leaked the memory associated with the AddressImpl. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@997771 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/tests/Address.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'cpp/src/tests/Address.cpp') diff --git a/cpp/src/tests/Address.cpp b/cpp/src/tests/Address.cpp index a0b87e25af..32d14bb4b8 100644 --- a/cpp/src/tests/Address.cpp +++ b/cpp/src/tests/Address.cpp @@ -87,6 +87,24 @@ QPID_AUTO_TEST_CASE(testParseOptionsWithList) BOOST_CHECK_EQUAL((uint16_t) 101, address.getOptions()["x"].asInt64()); } +QPID_AUTO_TEST_CASE(testParseOptionsWithEmptyList) +{ + Address address("my-topic; {a:[], x:101}"); + BOOST_CHECK_EQUAL(std::string("my-topic"), address.getName()); + Variant::List& list = address.getOptions()["a"].asList(); + BOOST_CHECK_EQUAL(list.size(), 0); + BOOST_CHECK_EQUAL((uint16_t) 101, address.getOptions()["x"].asInt64()); +} + +QPID_AUTO_TEST_CASE(testParseOptionsWithEmptyMap) +{ + Address address("my-topic; {a:{}, x:101}"); + BOOST_CHECK_EQUAL(std::string("my-topic"), address.getName()); + Variant::Map& map = address.getOptions()["a"].asMap(); + BOOST_CHECK_EQUAL(map.size(), 0); + BOOST_CHECK_EQUAL((uint16_t) 101, address.getOptions()["x"].asInt64()); +} + QPID_AUTO_TEST_CASE(testParseQuotedNameAndSubject) { Address address("'my topic with / in it'/'my subject with ; in it'"); -- cgit v1.2.1