summaryrefslogtreecommitdiff
path: root/cpp/src/tests/Array.cpp
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2007-11-06 17:27:27 +0000
committerGordon Sim <gsim@apache.org>2007-11-06 17:27:27 +0000
commita2ded139f371d273afa858f49a5b7f6e0efc2394 (patch)
tree8fc04da8ffe3aa819843a101a75d98429f27eaa5 /cpp/src/tests/Array.cpp
parenta1a0ecfbf02293cf917db5e56d65d367be5ad5a7 (diff)
downloadqpid-python-a2ded139f371d273afa858f49a5b7f6e0efc2394.tar.gz
Add support for array type to c++ (and python, decode only for now)
Change the type of the in-doubt field in dtx-coordination.recover to an array (to bring in line with amqp spec) git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@592494 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests/Array.cpp')
-rw-r--r--cpp/src/tests/Array.cpp78
1 files changed, 78 insertions, 0 deletions
diff --git a/cpp/src/tests/Array.cpp b/cpp/src/tests/Array.cpp
new file mode 100644
index 0000000000..5bf7fadce0
--- /dev/null
+++ b/cpp/src/tests/Array.cpp
@@ -0,0 +1,78 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+#include <iostream>
+#include <sstream>
+#include "qpid/framing/Array.h"
+#include "qpid/framing/FieldValue.h"
+
+#include <boost/test/auto_unit_test.hpp>
+BOOST_AUTO_TEST_SUITE(Array);
+
+using namespace qpid::framing;
+
+void populate(std::vector<std::string>& data, int count = 10)
+{
+ for (int i = 0; i < count; i++) {
+ std::stringstream out;
+ out << "item-" << i;
+ data.push_back(out.str());
+ }
+}
+
+BOOST_AUTO_TEST_CASE(testEncodeDecode)
+{
+ std::vector<std::string> data;
+ populate(data);
+
+ Array a(data);
+
+ char buff[200];
+ Buffer wbuffer(buff, 200);
+ a.encode(wbuffer);
+
+ Array b;
+ Buffer rbuffer(buff, 200);
+ b.decode(rbuffer);
+ BOOST_CHECK_EQUAL(a, b);
+
+ std::vector<std::string> data2;
+ b.collect(data2);
+ //BOOST_CHECK_EQUAL(data, data2);
+ BOOST_CHECK(data == data2);
+}
+
+BOOST_AUTO_TEST_CASE(testAssignment)
+{
+ std::vector<std::string> data;
+ populate(data);
+ Array b;
+ {
+ Array a(data);
+ b = a;
+ BOOST_CHECK_EQUAL(a, b);
+ }
+ std::vector<std::string> data2;
+ b.collect(data2);
+ //BOOST_CHECK_EQUAL(data, data2);
+ BOOST_CHECK(data == data2);
+}
+
+BOOST_AUTO_TEST_SUITE_END();