diff options
author | Rajith Muditha Attapattu <rajith@apache.org> | 2011-05-27 15:44:23 +0000 |
---|---|---|
committer | Rajith Muditha Attapattu <rajith@apache.org> | 2011-05-27 15:44:23 +0000 |
commit | 66765100f4257159622cefe57bed50125a5ad017 (patch) | |
tree | a88ee23bb194eb91f0ebb2d9b23ff423e3ea8e37 /cpp/src/tests/Uuid.cpp | |
parent | 1aeaa7b16e5ce54f10c901d75c4d40f9f88b9db6 (diff) | |
parent | 88b98b2f4152ef59a671fad55a0d08338b6b78ca (diff) | |
download | qpid-python-rajith_jms_client.tar.gz |
Creating a branch for experimenting with some ideas for JMS client.rajith_jms_client
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/rajith_jms_client@1128369 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests/Uuid.cpp')
-rw-r--r-- | cpp/src/tests/Uuid.cpp | 137 |
1 files changed, 0 insertions, 137 deletions
diff --git a/cpp/src/tests/Uuid.cpp b/cpp/src/tests/Uuid.cpp deleted file mode 100644 index 0195455ca3..0000000000 --- a/cpp/src/tests/Uuid.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed 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 "qpid/framing/Uuid.h" -#include "qpid/framing/Buffer.h" -#include "qpid/types/Uuid.h" -#include "qpid/sys/alloca.h" - -#include "unit_test.h" - -#include <set> - -namespace qpid { -namespace tests { - -QPID_AUTO_TEST_SUITE(UuidTestSuite) - -using namespace std; -using namespace qpid::framing; - -struct UniqueSet : public std::set<Uuid> { - void operator()(const Uuid& uuid) { - BOOST_REQUIRE(find(uuid) == end()); - insert(uuid); - } -}; - -QPID_AUTO_TEST_CASE(testUuidCtor) { - // Uniqueness - boost::array<Uuid,1000> uuids; - for_each(uuids.begin(), uuids.end(), mem_fun_ref(&Uuid::generate)); - UniqueSet unique; - for_each(uuids.begin(), uuids.end(), unique); -} - -boost::array<uint8_t, 16> sample = {{'\x1b', '\x4e', '\x28', '\xba', '\x2f', '\xa1', '\x11', '\xd2', '\x88', '\x3f', '\xb9', '\xa7', '\x61', '\xbd', '\xe3', '\xfb'}}; -const string sampleStr("1b4e28ba-2fa1-11d2-883f-b9a761bde3fb"); -const string zeroStr("00000000-0000-0000-0000-000000000000"); - -QPID_AUTO_TEST_CASE(testUuidIstream) { - Uuid uuid; - istringstream in(sampleStr); - in >> uuid; - BOOST_CHECK(!in.fail()); - BOOST_CHECK(uuid == sample); - - istringstream is(zeroStr); - Uuid zero; - is >> zero; - BOOST_CHECK(!in.fail()); - BOOST_CHECK_EQUAL(zero, Uuid()); -} - -QPID_AUTO_TEST_CASE(testUuidOstream) { - Uuid uuid(sample.c_array()); - ostringstream out; - out << uuid; - BOOST_CHECK(out.good()); - BOOST_CHECK_EQUAL(out.str(), sampleStr); - - ostringstream os; - os << Uuid(); - BOOST_CHECK(out.good()); - BOOST_CHECK_EQUAL(os.str(), zeroStr); -} - -QPID_AUTO_TEST_CASE(testUuidIOstream) { - Uuid a(true), b(true); - ostringstream os; - os << a << endl << b; - Uuid aa, bb; - istringstream is(os.str()); - is >> aa >> ws >> bb; - BOOST_CHECK(os.good()); - BOOST_CHECK_EQUAL(a, aa); - BOOST_CHECK_EQUAL(b, bb); -} - -QPID_AUTO_TEST_CASE(testUuidEncodeDecode) { - char* buff = static_cast<char*>(::alloca(Uuid::size())); - Buffer wbuf(buff, Uuid::size()); - Uuid uuid(sample.c_array()); - uuid.encode(wbuf); - - Buffer rbuf(buff, Uuid::size()); - Uuid decoded; - decoded.decode(rbuf); - BOOST_CHECK_EQUAL(string(sample.begin(), sample.end()), - string(decoded.begin(), decoded.end())); -} - -QPID_AUTO_TEST_CASE(testTypesUuid) -{ - //tests for the Uuid class in the types namespace (introduced - //to avoid pulling in dependencies from framing) - types::Uuid a; - types::Uuid b(true); - types::Uuid c(true); - types::Uuid d(b); - types::Uuid e; - e = c; - - BOOST_CHECK(!a); - BOOST_CHECK(b); - - BOOST_CHECK(a != b); - BOOST_CHECK(b != c); - - BOOST_CHECK_EQUAL(b, d); - BOOST_CHECK_EQUAL(c, e); - - ostringstream out; - out << b; - istringstream in(out.str()); - in >> a; - BOOST_CHECK(!in.fail()); - BOOST_CHECK_EQUAL(a, b); -} - -QPID_AUTO_TEST_SUITE_END() - -}} // namespace qpid::tests |