From 6ee11959bff03826083c85943f14e6b4ceeaacff Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Tue, 6 Nov 2007 17:27:27 +0000 Subject: 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@592494 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/Array.cpp | 78 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 qpid/cpp/src/tests/Array.cpp (limited to 'qpid/cpp/src/tests/Array.cpp') diff --git a/qpid/cpp/src/tests/Array.cpp b/qpid/cpp/src/tests/Array.cpp new file mode 100644 index 0000000000..5bf7fadce0 --- /dev/null +++ b/qpid/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 +#include +#include "qpid/framing/Array.h" +#include "qpid/framing/FieldValue.h" + +#include +BOOST_AUTO_TEST_SUITE(Array); + +using namespace qpid::framing; + +void populate(std::vector& 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 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 data2; + b.collect(data2); + //BOOST_CHECK_EQUAL(data, data2); + BOOST_CHECK(data == data2); +} + +BOOST_AUTO_TEST_CASE(testAssignment) +{ + std::vector data; + populate(data); + Array b; + { + Array a(data); + b = a; + BOOST_CHECK_EQUAL(a, b); + } + std::vector data2; + b.collect(data2); + //BOOST_CHECK_EQUAL(data, data2); + BOOST_CHECK(data == data2); +} + +BOOST_AUTO_TEST_SUITE_END(); -- cgit v1.2.1