summaryrefslogtreecommitdiff
path: root/cpp/src/tests
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2010-03-18 18:37:28 +0000
committerGordon Sim <gsim@apache.org>2010-03-18 18:37:28 +0000
commit53df223b3e2d08aed1bb70649c1f0269e0639f84 (patch)
tree3b6cb3d0b2a1ec005412d6ce4030fe1e738bf945 /cpp/src/tests
parent615cde45bd6415a6b562aeb6b2954c20c48aaed5 (diff)
downloadqpid-python-53df223b3e2d08aed1bb70649c1f0269e0639f84.tar.gz
QPID-2452: Fixed control over the encoding used when sending a string valued variant. The user is currently responsible for correctly setting any encoding (e.g. utf8). If none is specified it will be transfered as an amqp0-10 vbin. Fixed bug preventing correct assignment of encoding in variants.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@924939 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests')
-rw-r--r--cpp/src/tests/MessagingSessionTests.cpp10
-rw-r--r--cpp/src/tests/Variant.cpp15
2 files changed, 25 insertions, 0 deletions
diff --git a/cpp/src/tests/MessagingSessionTests.cpp b/cpp/src/tests/MessagingSessionTests.cpp
index dea98216b4..a1e90f83f3 100644
--- a/cpp/src/tests/MessagingSessionTests.cpp
+++ b/cpp/src/tests/MessagingSessionTests.cpp
@@ -336,6 +336,12 @@ QPID_AUTO_TEST_CASE(testMapMessage)
MapContent content(out);
content["abc"] = "def";
content["pi"] = 3.14f;
+ Variant utf8("A utf 8 string");
+ utf8.setEncoding("utf8");
+ content["utf8"] = utf8;
+ Variant utf16("\x00\x61\x00\x62\x00\x63");
+ utf16.setEncoding("utf16");
+ content["utf16"] = utf16;
content.encode();
sender.send(out);
Receiver receiver = fix.session.createReceiver(fix.queue);
@@ -343,6 +349,10 @@ QPID_AUTO_TEST_CASE(testMapMessage)
MapView view(in);
BOOST_CHECK_EQUAL(view["abc"].asString(), "def");
BOOST_CHECK_EQUAL(view["pi"].asFloat(), 3.14f);
+ BOOST_CHECK_EQUAL(view["utf8"].asString(), utf8.asString());
+ BOOST_CHECK_EQUAL(view["utf8"].getEncoding(), utf8.getEncoding());
+ BOOST_CHECK_EQUAL(view["utf16"].asString(), utf16.asString());
+ BOOST_CHECK_EQUAL(view["utf16"].getEncoding(), utf16.getEncoding());
fix.session.acknowledge();
}
diff --git a/cpp/src/tests/Variant.cpp b/cpp/src/tests/Variant.cpp
index c0bb9772c8..db9e419eab 100644
--- a/cpp/src/tests/Variant.cpp
+++ b/cpp/src/tests/Variant.cpp
@@ -178,6 +178,21 @@ QPID_AUTO_TEST_CASE(testIsEqualTo)
BOOST_CHECK_EQUAL(a, b);
}
+QPID_AUTO_TEST_CASE(testEncoding)
+{
+ Variant a("abc");
+ a.setEncoding("utf8");
+ Variant b = a;
+ Variant map = Variant::Map();
+ map.asMap()["a"] = a;
+ map.asMap()["b"] = b;
+ BOOST_CHECK_EQUAL(a.getEncoding(), std::string("utf8"));
+ BOOST_CHECK_EQUAL(a.getEncoding(), b.getEncoding());
+ BOOST_CHECK_EQUAL(a.getEncoding(), map.asMap()["a"].getEncoding());
+ BOOST_CHECK_EQUAL(b.getEncoding(), map.asMap()["b"].getEncoding());
+ BOOST_CHECK_EQUAL(map.asMap()["a"].getEncoding(), map.asMap()["b"].getEncoding());
+}
+
QPID_AUTO_TEST_SUITE_END()
}} // namespace qpid::tests