From 7c70d21ca2d788d4432cfa89851c9b928c9f30aa Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Fri, 19 Sep 2008 22:31:45 +0000 Subject: Support floats and doubles in field tables. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@697269 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/tests/FieldTable.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'cpp/src/tests/FieldTable.cpp') diff --git a/cpp/src/tests/FieldTable.cpp b/cpp/src/tests/FieldTable.cpp index 22db287140..953b853cd6 100644 --- a/cpp/src/tests/FieldTable.cpp +++ b/cpp/src/tests/FieldTable.cpp @@ -122,4 +122,39 @@ QPID_AUTO_TEST_CASE(testNestedValues) } } +QPID_AUTO_TEST_CASE(testFloatAndDouble) +{ + char buff[100]; + float f = 5.672; + double d = 56.720001; + { + FieldTable a; + a.setString("string", "abc"); + a.setInt("int", 5672); + a.setFloat("float", f); + a.setDouble("double", d); + + Buffer wbuffer(buff, 100); + wbuffer.put(a); + } + { + Buffer rbuffer(buff, 100); + FieldTable a; + rbuffer.get(a); + BOOST_CHECK(string("abc") == a.getString("string")); + BOOST_CHECK(5672 == a.getInt("int")); + float f2; + BOOST_CHECK(!a.getFloat("string", f2)); + BOOST_CHECK(!a.getFloat("int", f2)); + BOOST_CHECK(a.getFloat("float", f2)); + BOOST_CHECK(f2 == f); + + double d2; + BOOST_CHECK(!a.getDouble("string", d2)); + BOOST_CHECK(!a.getDouble("int", d2)); + BOOST_CHECK(a.getDouble("double", d2)); + BOOST_CHECK(d2 == d); + } +} + QPID_AUTO_TEST_SUITE_END() -- cgit v1.2.1