activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r543494 - in /activemq/activemq-cpp/trunk/src/decaf/src: main/Makefile.am main/decaf/util/Guid.cpp main/decaf/util/Guid.h test/Makefile.am test/decaf/util/GuidTest.cpp test/decaf/util/GuidTest.h
Date Fri, 01 Jun 2007 14:30:26 GMT
Author: tabish
Date: Fri Jun  1 07:30:25 2007
New Revision: 543494

URL: http://svn.apache.org/viewvc?view=rev&rev=543494
Log:
http://issues.apache.org/activemq/browse/AMQCPP-103

Building Decaf lib

Added:
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/Guid.cpp
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/Guid.h
    activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/GuidTest.cpp
    activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/GuidTest.h
Modified:
    activemq/activemq-cpp/trunk/src/decaf/src/main/Makefile.am
    activemq/activemq-cpp/trunk/src/decaf/src/test/Makefile.am

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/Makefile.am?view=diff&rev=543494&r1=543493&r2=543494
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/Makefile.am Fri Jun  1 07:30:25 2007
@@ -34,6 +34,7 @@
    decaf/util/concurrent/Mutex.cpp \
    decaf/util/concurrent/CountDownLatch.cpp \
    decaf/util/Date.cpp \
+   decaf/util/Guid.cpp \
    decaf/util/StringTokenizer.cpp \
    decaf/util/logging/LoggerHierarchy.cpp \
    decaf/util/logging/Logger.cpp \
@@ -94,6 +95,7 @@
    decaf/util/concurrent/Synchronizable.h \
    decaf/util/concurrent/Mutex.h \
    decaf/util/Date.h \
+   decaf/util/Guid.h \
    decaf/util/Properties.h \
    decaf/util/StringTokenizer.h \
    decaf/util/logging/Handler.h \

Added: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/Guid.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/Guid.cpp?view=auto&rev=543494
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/Guid.cpp (added)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/Guid.cpp Fri Jun  1 07:30:25
2007
@@ -0,0 +1,405 @@
+/*
+ * 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 "Guid.h"
+#include <stdexcept>
+
+using namespace decaf::util;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+using namespace std;
+
+////////////////////////////////////////////////////////////////////////////////
+Guid::Guid()
+{
+    // Clear internal uuid, would pass isNull
+    #if !defined(HAVE_OBJBASE_H)
+        memset(&uuid, 0, sizeof(uuid_t));
+    #else
+        ::UuidCreateNil(&uuid);
+    #endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Guid::Guid( const Guid& source )
+{
+    // Set this uuid to that of the source
+    *this = source;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Guid::Guid( const std::string& source )
+   throw ( IllegalArgumentException )
+{
+    if(source == "")
+    {
+        throw IllegalArgumentException(
+            __FILE__, __LINE__,
+            "GUID::fromBytes - Source was Empty");
+    }
+
+    // Set this uuid to that of the source
+    *this = source;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Guid::~Guid()
+{
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Guid::isNull() const
+{
+    #if !defined(HAVE_OBJBASE_H)
+        // Check the uuid APIs is null method
+        return uuid_is_null(*(const_cast<uuid_t*>(&uuid))) == 1 ? true : false;
+    #else
+         RPC_STATUS status;
+
+         BOOL result = ::UuidIsNil( const_cast<GUID*>( &uuid ), &status );
+
+         return (result == TRUE) ? true : false;
+   #endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Guid::setNull()
+{
+    #if !defined(HAVE_OBJBASE_H)
+        // use the uuid function to clear
+        uuid_clear(uuid);
+    #else
+        ::UuidCreateNil(&uuid);
+    #endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Guid& Guid::createGUID() throw( RuntimeException )
+{
+    #if !defined(HAVE_OBJBASE_H)
+        // Use the uuid_generate method to create a new GUID
+        uuid_generate(uuid);
+    #else
+        // Create a uuid with the Co Create GUID
+        RPC_STATUS lhResult = ::UuidCreate( &uuid );
+
+        if ( lhResult == RPC_S_UUID_NO_ADDRESS )
+        {
+            throw RuntimeException(
+                __FILE__, __LINE__,
+                "GUIG::createGUID - Failed Creating GUID");
+        }
+    #endif
+
+    return *this;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string Guid::toString() const throw( RuntimeException )
+{
+    std::string uuid_str = "";
+
+    #if !defined(HAVE_OBJBASE_H)
+        // Create storage for the string buffer
+        char buffer[36] = {0};
+
+        // parse the uuid to the string
+        uuid_unparse(*(const_cast<uuid_t*>(&uuid)), buffer);
+
+        // Store it in a string
+        uuid_str = buffer;
+    #else
+        // Convert the GUID object to a string.
+        unsigned char* guidStr = 0;
+
+        RPC_STATUS result = ::UuidToString(
+            const_cast<GUID*>(&uuid), &guidStr);
+
+        if(result == RPC_S_OUT_OF_MEMORY)
+        {
+            throw RuntimeException(
+                __FILE__, __LINE__,
+                "GUIG::createGUID - Failed Creating GUID");
+        }
+
+        uuid_str = (char*)guidStr;
+
+        // Dispose of the GUID string.
+        ::RpcStringFree(&guidStr);
+    #endif
+
+    return uuid_str;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Guid::operator std::string() const
+{
+    return toString();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+const unsigned char* Guid::toBytes() const
+{
+    unsigned char* buffer = new unsigned char[getRawBytesSize()];
+
+    // copy our buffer
+    #if !defined(HAVE_OBJBASE_H)
+        uuid_copy(buffer, *(const_cast<uuid_t*>(&uuid)));
+    #else
+        memcpy(buffer, &uuid, getRawBytesSize());
+    #endif
+
+    return &buffer[0];
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Guid& Guid::fromBytes( const unsigned char* bytes )
+   throw ( IllegalArgumentException )
+{
+    if(bytes == NULL)
+    {
+        throw IllegalArgumentException(
+            __FILE__, __LINE__,
+            "GUID::fromBytes - bytes pointer was NULL");
+    }
+
+    // Copy the data
+    #if !defined(HAVE_OBJBASE_H)
+        memcpy(uuid, bytes, getRawBytesSize());
+    #else
+        memcpy(&uuid, bytes, getRawBytesSize());
+    #endif
+
+    return *this;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Guid::getRawBytesSize() const
+{
+    #if !defined(HAVE_OBJBASE_H)
+        return sizeof(uuid_t);
+    #else
+        return sizeof(::GUID);
+    #endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Guid::operator const unsigned char*() const
+{
+    #if !defined(HAVE_OBJBASE_H)
+        return &uuid[0];
+    #else
+        return reinterpret_cast<const unsigned char*>(&uuid);
+    #endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Guid& Guid::operator=( const Guid& source )
+   throw ( IllegalArgumentException )
+{
+    #if !defined(HAVE_OBJBASE_H)
+        // Use the uuid method to copy
+        uuid_copy(uuid, *(const_cast<uuid_t*>(&source.uuid)));
+    #else
+        // Use mem copy
+        memcpy(&uuid, &source.uuid, getRawBytesSize());
+    #endif
+
+    return *this;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Guid& Guid::operator=( const std::string& source )
+    throw ( IllegalArgumentException )
+{
+    #if !defined(HAVE_OBJBASE_H)
+        // Parse a uuid from the passed in string
+        uuid_parse( const_cast<char*>(source.c_str()), uuid );
+    #else
+        if ( source.empty() )
+        {
+            ::UuidCreateNil( &uuid );
+        }
+        else
+        {
+            RPC_STATUS hResult =
+                ::UuidFromString( (unsigned char*)source.c_str(), &uuid );
+
+            if ( hResult == RPC_S_INVALID_STRING_UUID )
+            {
+                throw IllegalArgumentException(
+                    __FILE__, __LINE__,
+                    "GUID::fromBytes - Invalid GUID String");
+            }
+        }
+    #endif
+
+    return *this;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Guid::operator==( const Guid& source ) const
+{
+    #if !defined(HAVE_OBJBASE_H)
+        // uuid_compare returns 0 for equal
+        return uuid_compare(
+                *(const_cast<uuid_t*>(&uuid)),
+                *(const_cast<uuid_t*>(&source.uuid))) == 0 ? true : false;
+    #else
+        RPC_STATUS status;
+
+        BOOL result = ::UuidEqual(
+            const_cast<GUID*>( &uuid ),
+            const_cast<GUID*>( &source.uuid ),
+            &status );
+
+        return ( result == TRUE ) ? true : false;
+    #endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Guid::operator==( const std::string& source ) const
+{
+    return *this == Guid(source);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Guid::operator!=( const Guid& source ) const
+{
+    return !(*this == source);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Guid::operator!=( const std::string& source ) const
+{
+    return !( *this == source );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Guid::operator<( const Guid& source ) const
+{
+    #if !defined(HAVE_OBJBASE_H)
+        // uuid_compare returns 0 for equal
+        return uuid_compare(
+                 *(const_cast<uuid_t*>(&uuid)),
+                 *(const_cast<uuid_t*>(&source.uuid))) < 0 ? true : false;
+    #else
+        RPC_STATUS status;
+
+        int result = ::UuidCompare(
+            const_cast<GUID*>( &uuid ),
+            const_cast<GUID*>( &source.uuid ),
+            &status );
+
+        return ( result < 0 ) ? true : false;
+    #endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Guid::operator<( const std::string& source ) const
+{
+    return *this < Guid(source);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Guid::operator<=( const Guid& source ) const
+{
+    #if !defined(HAVE_OBJBASE_H)
+        // uuid_compare returns 0 for equal
+        return uuid_compare(
+                 *(const_cast<uuid_t*>(&uuid)),
+                 *(const_cast<uuid_t*>(&source.uuid))) <= 0 ? true : false;
+    #else
+        RPC_STATUS status;
+
+        int result = ::UuidCompare(
+           const_cast<GUID*>( &uuid ),
+           const_cast<GUID*>( &source.uuid ),
+           &status );
+
+        return ( result <= 0 ) ? true : false;
+    #endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Guid::operator<=( const std::string& source ) const
+{
+    return *this <= Guid(source);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Guid::operator>( const Guid& source ) const
+{
+    #if !defined(HAVE_OBJBASE_H)
+        // uuid_compare returns 0 for equal
+        return uuid_compare(
+                 *(const_cast<uuid_t*>(&uuid)),
+                 *(const_cast<uuid_t*>(&source.uuid))) > 0 ? true : false;
+    #else
+        RPC_STATUS status;
+
+        int result = ::UuidCompare(
+            const_cast<GUID*>( &uuid ),
+            const_cast<GUID*>( &source.uuid ),
+            &status );
+
+        return ( result > 0 ) ? true : false;
+    #endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Guid::operator>( const std::string& source ) const
+{
+    return *this > Guid(source);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Guid::operator>=( const Guid& source ) const
+{
+    #if !defined(HAVE_OBJBASE_H)
+        // uuid_compare returns 0 for equal
+        return uuid_compare(
+                 *(const_cast<uuid_t*>(&uuid)),
+                 *(const_cast<uuid_t*>(&source.uuid))) >= 0 ? true : false;
+    #else
+        RPC_STATUS status;
+
+        int result = ::UuidCompare(
+            const_cast<GUID*>(&uuid),
+            const_cast<GUID*>(&source.uuid),
+            &status);
+
+        return (result >= 0) ? true : false;
+    #endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Guid::operator>=( const std::string& source ) const
+{
+    return *this >= Guid(source);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string Guid::createGUIDString()
+{
+    return Guid().createGUID().toString();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+const unsigned char* createGUIDBytes()
+{
+    return Guid().createGUID().toBytes();
+}

Added: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/Guid.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/Guid.h?view=auto&rev=543494
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/Guid.h (added)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/Guid.h Fri Jun  1 07:30:25 2007
@@ -0,0 +1,189 @@
+/*
+ * 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.
+ */
+#ifndef _DECAF_UTIL_GUID_H_
+#define _DECAF_UTIL_GUID_H_
+
+#include <decaf/lang/exceptions/RuntimeException.h>
+#include <decaf/lang/exceptions/IllegalArgumentException.h>
+#include <decaf/util/Config.h>
+
+// #if defined(HAVE_OBJBASE_H) && defined(HAVE_RPCDCE_H)
+#if defined(HAVE_OBJBASE_H)
+    #include <objbase.h>
+    #include <rpcdce.h>
+#elif defined(HAVE_UUID_UUID_H)
+    #include <uuid/uuid.h>
+#elif defined(HAVE_UUID_H)
+    #include <uuid.h>
+#endif
+
+#include <string>
+
+namespace decaf{
+namespace util{
+
+    class DECAF_API Guid
+    {
+    public:
+
+        Guid();
+        Guid(const Guid& source);
+        Guid(const std::string& source)
+            throw ( lang::exceptions::IllegalArgumentException );
+        virtual ~Guid();
+
+        /**
+         * Determines if this GUID is null, if so it can be initialized with a
+         * call to <code>createGUID</code>.
+         * @return true for Null GUID, false otherwise.
+         */
+        bool isNull() const;
+
+        /**
+         * Clears the GUID's current value and sets it to a NULL GUID value
+         * will now pass <code>isNull</code>.
+         */
+        void setNull();
+
+        /**
+         * Generate a new GUID which will overwrite any current GUID value
+         * @return Reference to this object that now has a new GUID
+         */
+        Guid& createGUID() throw( lang::exceptions::RuntimeException );
+
+        /**
+         * Converts the GUID to a string and returns that string
+         * @return a string with this GUID's stringified value
+         */
+        std::string toString() const throw( lang::exceptions::RuntimeException );
+
+        /**
+         * Converts the GUID to a byte array and return a pointer to the
+         * new array, called takes ownership and must delete this array
+         * when done.
+         * @return a byte array with the GUID byte value, size = 16
+         */
+        const unsigned char* toBytes() const;
+
+        /**
+         * Initializes this GUID with the GUID specified in the bytes parameter
+         * @return reference to this object.
+         */
+        Guid& fromBytes( const unsigned char* bytes )
+            throw ( lang::exceptions::IllegalArgumentException );
+
+        /**
+         * Returns the Size in Bytes of the Raw bytes representation of the
+         * GUID.
+         * @return size of the Raw bytes representation
+         */
+        int getRawBytesSize() const;
+
+        /**
+         * string type cast operator
+         * @returns string representation of this GUID
+         */
+        operator std::string() const;
+
+        /**
+         * byte array cast operator, caller does not own this memeory
+         * @returns byte array with the GUID byte value representation
+         */
+        operator const unsigned char*() const;
+
+        /**
+         * Assignment operators
+         * @return Reference to this GUID object
+         */
+        Guid& operator=( const Guid& source )
+           throw ( lang::exceptions::IllegalArgumentException );
+        Guid& operator=( const std::string& source )
+           throw ( lang::exceptions::IllegalArgumentException );
+
+        /**
+         * Equality Comparison Operators
+         * @return true for equal. false otherwise
+         */
+        bool operator==( const Guid& source ) const;
+        bool operator==( const std::string& source ) const;
+
+        /**
+         * Inequality Comparison Operators
+         * @return true for equal. false otherwise
+         */
+        bool operator!=( const Guid& source ) const;
+        bool operator!=( const std::string& source ) const;
+
+        /**
+         * Less than operators
+         * @return true for equal. false otherwise
+         */
+        bool operator<(const Guid& source) const;
+        bool operator<(const std::string& source) const;
+
+        /**
+         * Less than or equal to operators
+         * @return true for equal. false otherwise
+         */
+        bool operator<=( const Guid& source ) const;
+        bool operator<=( const std::string& source ) const;
+
+        /**
+         * Greater than operators
+         * @return true for equal. false otherwise
+         */
+        bool operator>( const Guid& source ) const;
+        bool operator>( const std::string& source ) const;
+
+        /**
+         * Greater than or equal to operators
+         * @return true for equal. false otherwise
+         */
+        bool operator>=( const Guid& source ) const;
+        bool operator>=( const std::string& source ) const;
+
+    public:
+
+        /**
+         * Static Guid Creation Method, creates a GUID and returns it as a string
+         * @return Guid string.
+         */
+        static std::string createGUIDString();
+
+        /**
+         * Static Guid Create Method, create a GUID and returns the byte representation
+         * of the new GUID.
+         * @return Guid bytes array, size is 16
+         */
+        static const unsigned char* createGUIDBytes();
+
+    private:
+
+        // the uuid that this object represents.
+        #ifdef HAVE_OBJBASE_H
+            ::GUID uuid;
+        #elif defined(HAVE_UUID_T)
+            uuid_t uuid;
+        #else
+            #error Platform does not support any of the standard UUID types
+        #endif
+
+   };
+
+}}
+
+#endif /*_DECAF_UTIL_GUID_H_*/

Modified: activemq/activemq-cpp/trunk/src/decaf/src/test/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/test/Makefile.am?view=diff&rev=543494&r1=543493&r2=543494
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/test/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/test/Makefile.am Fri Jun  1 07:30:25 2007
@@ -22,6 +22,7 @@
   decaf/lang/ThreadTest.cpp \
   decaf/util/StringTokenizerTest.cpp \
   decaf/util/DateTest.cpp \
+  decaf/util/GuidTest.cpp \
   decaf/util/concurrent/CountDownLatchTest.cpp \
   main.cpp
 

Added: activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/GuidTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/GuidTest.cpp?view=auto&rev=543494
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/GuidTest.cpp (added)
+++ activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/GuidTest.cpp Fri Jun  1 07:30:25
2007
@@ -0,0 +1,79 @@
+/*
+ * 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 "GuidTest.h"
+
+#include <decaf/util/Guid.h>
+
+CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::GuidTest );
+
+using namespace std;
+using namespace decaf;
+using namespace decaf::util;
+using namespace decaf::lang;
+
+void GuidTest::test() {
+
+    util::Guid guid;
+
+    guid.createGUID();
+
+    CPPUNIT_ASSERT( guid.toString() == (std::string)guid );
+
+    Guid copy = guid;
+
+    CPPUNIT_ASSERT( guid == copy );
+    CPPUNIT_ASSERT( !(guid < copy) );
+    CPPUNIT_ASSERT( guid <= copy );
+    CPPUNIT_ASSERT( !(guid > copy) );
+    CPPUNIT_ASSERT( guid >= copy );
+
+    std::string less = "0f2bd21c-9fee-4067-d739-c4d84a5d7f62";
+    std::string more = "1f2bd21c-9fee-4067-d739-c4d84a5d7f62";
+
+    CPPUNIT_ASSERT( less < more );
+    CPPUNIT_ASSERT( less <= more );
+    CPPUNIT_ASSERT( !(less > more) );
+    CPPUNIT_ASSERT( !(less >= more) );
+
+    less = more;
+
+    CPPUNIT_ASSERT( less == more );
+
+    const unsigned char* bytes = guid.toBytes();
+
+    Guid bytesGUID;
+    bytesGUID.fromBytes(bytes);
+
+    CPPUNIT_ASSERT( guid == bytesGUID );
+
+    delete [] bytes;
+
+    Guid bytesGUID2;
+    bytesGUID2.fromBytes((const unsigned char*)guid);
+
+    CPPUNIT_ASSERT( guid == bytesGUID2 );
+
+    Guid stringGUID(guid.toString());
+
+    CPPUNIT_ASSERT( stringGUID == guid );
+
+    Guid stringGUID2(guid.toString().c_str());
+
+    CPPUNIT_ASSERT( stringGUID2 == guid );
+    CPPUNIT_ASSERT( !(stringGUID2 != guid) );
+}

Added: activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/GuidTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/GuidTest.h?view=auto&rev=543494
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/GuidTest.h (added)
+++ activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/GuidTest.h Fri Jun  1 07:30:25
2007
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+#ifndef _DECAF_UTIL_GUIDTEST_H_
+#define _DECAF_UTIL_GUIDTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+namespace decaf{
+namespace util{
+
+    class GuidTest : public CppUnit::TestFixture
+    {
+        CPPUNIT_TEST_SUITE( GuidTest );
+        CPPUNIT_TEST( test );
+        CPPUNIT_TEST_SUITE_END();
+
+    public:
+
+        virtual ~GuidTest() {}
+
+        void test();
+    };
+
+}}
+
+#endif /*_DECAF_UTIL_GUIDTEST_H_*/



Mime
View raw message