activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r599004 - in /activemq/activemq-cpp/decaf/trunk/src/test/decaf/nio: ByteBufferTest.cpp ByteBufferTest.h
Date Wed, 28 Nov 2007 13:58:58 GMT
Author: tabish
Date: Wed Nov 28 05:58:57 2007
New Revision: 599004

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

Working on the NIO package

Modified:
    activemq/activemq-cpp/decaf/trunk/src/test/decaf/nio/ByteBufferTest.cpp
    activemq/activemq-cpp/decaf/trunk/src/test/decaf/nio/ByteBufferTest.h

Modified: activemq/activemq-cpp/decaf/trunk/src/test/decaf/nio/ByteBufferTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/test/decaf/nio/ByteBufferTest.cpp?rev=599004&r1=599003&r2=599004&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/test/decaf/nio/ByteBufferTest.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/test/decaf/nio/ByteBufferTest.cpp Wed Nov 28 05:58:57
2007
@@ -230,3 +230,60 @@
     delete other;
     delete data;
 }
+
+////////////////////////////////////////////////////////////////////////////////
+void ByteBufferTest::testDuplicate() {
+
+    testBuffer1->clear();
+    testBuffer1->mark();
+    testBuffer1->position( testBuffer1->limit() );
+
+    for( std::size_t ix = 0; ix < testData1Size; ++ix ){
+        testBuffer1->put( ix, testData1[ix] );
+    }
+
+    // duplicate's contents should be the same as buf
+    ByteBuffer* duplicate = testBuffer1->duplicate();
+    CPPUNIT_ASSERT( testBuffer1 != duplicate );
+    CPPUNIT_ASSERT( testBuffer1->position() == duplicate->position() );
+    CPPUNIT_ASSERT( testBuffer1->limit() == duplicate->limit() );
+    CPPUNIT_ASSERT( testBuffer1->isReadOnly() == duplicate->isReadOnly() );
+
+    for( std::size_t ix; ix < testBuffer1->capacity(); ix++ ) {
+        CPPUNIT_ASSERT( testBuffer1->get( ix ) == duplicate->get( ix ) );
+    }
+
+    // duplicate's position, mark, and limit should be independent to buf
+    duplicate->reset();
+    CPPUNIT_ASSERT( duplicate->position() == 0 );
+    duplicate->clear();
+    CPPUNIT_ASSERT( testBuffer1->position() == testBuffer1->limit() );
+    testBuffer1->reset();
+    CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+
+    delete duplicate;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ByteBufferTest::testEquals() {
+
+    // equal to self
+    CPPUNIT_ASSERT( testBuffer1->equals( *testBuffer1 ) );
+    ByteBuffer* readOnly = testBuffer1->asReadOnlyBuffer();
+    CPPUNIT_ASSERT( testBuffer1->equals( *readOnly ) );
+    ByteBuffer* duplicate = testBuffer1->duplicate();
+    CPPUNIT_ASSERT( testBuffer1->equals( *duplicate ) );
+
+    CPPUNIT_ASSERT( testBuffer1->capacity() > SMALL_TEST_LENGTH );
+
+    testBuffer1->limit( testBuffer1->capacity() ).position( 0 );
+    readOnly->limit( readOnly->capacity() ).position( 1 );
+    CPPUNIT_ASSERT( !testBuffer1->equals( *readOnly ) );
+
+    testBuffer1->limit( testBuffer1->capacity() - 1 ).position( 0 );
+    duplicate->limit( duplicate->capacity() ).position( 0 );
+    CPPUNIT_ASSERT( !testBuffer1->equals( *duplicate ) );
+
+    delete readOnly;
+    delete duplicate;
+}

Modified: activemq/activemq-cpp/decaf/trunk/src/test/decaf/nio/ByteBufferTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/test/decaf/nio/ByteBufferTest.h?rev=599004&r1=599003&r2=599004&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/test/decaf/nio/ByteBufferTest.h (original)
+++ activemq/activemq-cpp/decaf/trunk/src/test/decaf/nio/ByteBufferTest.h Wed Nov 28 05:58:57
2007
@@ -36,6 +36,8 @@
         CPPUNIT_TEST( testAsReadOnlyBuffer );
         CPPUNIT_TEST( testCompact );
         CPPUNIT_TEST( testCompareTo );
+        CPPUNIT_TEST( testDuplicate );
+        CPPUNIT_TEST( testEquals );
         CPPUNIT_TEST_SUITE_END();
 
     private:
@@ -73,6 +75,8 @@
         void testAsReadOnlyBuffer();
         void testCompact();
         void testCompareTo();
+        void testDuplicate();
+        void testEquals();
 
     };
 



Mime
View raw message