From 6266b974c0c227d279f4dde0fdbc07defd7b5965 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Fri, 19 Sep 2008 12:56:38 +0000 Subject: Added support for nested field tables & arrays within a field table. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@697076 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/tests/FieldTable.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'cpp/src/tests/FieldTable.cpp') diff --git a/cpp/src/tests/FieldTable.cpp b/cpp/src/tests/FieldTable.cpp index 315801b428..22db287140 100644 --- a/cpp/src/tests/FieldTable.cpp +++ b/cpp/src/tests/FieldTable.cpp @@ -19,6 +19,7 @@ * */ #include +#include "qpid/framing/Array.h" #include "qpid/framing/FieldTable.h" #include "qpid/framing/FieldValue.h" #include @@ -82,4 +83,43 @@ QPID_AUTO_TEST_CASE(testAssignment) BOOST_CHECK(IntegerValue(1234) == *d.get("B")); } + +QPID_AUTO_TEST_CASE(testNestedValues) +{ + char buff[100]; + { + FieldTable a; + FieldTable b; + std::vector items; + items.push_back("one"); + items.push_back("two"); + Array c(items); + + a.setString("id", "A"); + b.setString("id", "B"); + a.setTable("B", b); + a.setArray("C", c); + + + Buffer wbuffer(buff, 100); + wbuffer.put(a); + } + { + Buffer rbuffer(buff, 100); + FieldTable a; + FieldTable b; + Array c; + rbuffer.get(a); + BOOST_CHECK(string("A") == a.getString("id")); + a.getTable("B", b); + BOOST_CHECK(string("B") == b.getString("id")); + a.getArray("C", c); + std::vector items; + c.collect(items); + BOOST_CHECK((uint) 2 == items.size()); + BOOST_CHECK(string("one") == items[0]); + BOOST_CHECK(string("two") == items[1]); + } +} + QPID_AUTO_TEST_SUITE_END() -- cgit v1.2.1