summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2011-07-01 12:00:56 +0000
committerGordon Sim <gsim@apache.org>2011-07-01 12:00:56 +0000
commit1233bc87a07817a1869a6ff8eb74870154e31346 (patch)
tree51c631f28562349306c0f1c7d911cfee9065b13e /cpp/src
parentf79ba92ffe3335b739bc060aeafd9de325d05ed3 (diff)
downloadqpid-python-1233bc87a07817a1869a6ff8eb74870154e31346.tar.gz
QPID-3330: Corrected handling of empty strings (using patch from Anthony Foglia) and added test case
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1141910 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/qpid/messaging/AddressParser.cpp2
-rw-r--r--cpp/src/tests/Address.cpp11
2 files changed, 12 insertions, 1 deletions
diff --git a/cpp/src/qpid/messaging/AddressParser.cpp b/cpp/src/qpid/messaging/AddressParser.cpp
index 4c8f35fbc5..83aca82be4 100644
--- a/cpp/src/qpid/messaging/AddressParser.cpp
+++ b/cpp/src/qpid/messaging/AddressParser.cpp
@@ -151,7 +151,7 @@ bool AddressParser::readValueIfExists(Variant& value)
bool AddressParser::readString(std::string& value, char delimiter)
{
if (readChar(delimiter)) {
- std::string::size_type start = current++;
+ std::string::size_type start = current;
while (!eos()) {
if (input.at(current) == delimiter) {
if (current > start) {
diff --git a/cpp/src/tests/Address.cpp b/cpp/src/tests/Address.cpp
index f41f27b6df..0fd3585958 100644
--- a/cpp/src/tests/Address.cpp
+++ b/cpp/src/tests/Address.cpp
@@ -119,6 +119,17 @@ QPID_AUTO_TEST_CASE(testParseQuotedNameAndSubject)
BOOST_CHECK_EQUAL(std::string("my subject with ; in it"), address.getSubject());
}
+QPID_AUTO_TEST_CASE(testParseOptionsWithEmptyStringAsValue)
+{
+ Address address("my-topic; {a:'', x:101}");
+ BOOST_CHECK_EQUAL(std::string("my-topic"), address.getName());
+ Variant a = address.getOptions()["a"];
+ BOOST_CHECK_EQUAL(VAR_STRING, a.getType());
+ std::string aVal = a;
+ BOOST_CHECK(aVal.size() == 0);
+ BOOST_CHECK_EQUAL((uint16_t) 101, address.getOptions()["x"].asInt64());
+}
+
QPID_AUTO_TEST_SUITE_END()
}}