You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2010/03/20 22:57:24 UTC

svn commit: r925692 [12/14] - in /activemq/activemq-cpp/trunk/activemq-cpp/src: main/ main/activemq/commands/ main/activemq/io/ main/activemq/wireformat/openwire/ main/activemq/wireformat/openwire/marshal/ main/decaf/internal/io/ main/decaf/internal/ni...

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/ByteArrayBufferTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/ByteArrayBufferTest.cpp?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/ByteArrayBufferTest.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/ByteArrayBufferTest.cpp Sat Mar 20 21:57:20 2010
@@ -29,6 +29,11 @@ using namespace decaf::lang;
 using namespace decaf::lang::exceptions;
 
 ////////////////////////////////////////////////////////////////////////////////
+const int ByteArrayBufferTest::testData1Size = 100;
+const int ByteArrayBufferTest::SMALL_TEST_LENGTH = 5;
+const int ByteArrayBufferTest::BUFFER_LENGTH = 250;
+
+////////////////////////////////////////////////////////////////////////////////
 void ByteArrayBufferTest::test() {
 
     // Check that we have setup the array and our initial assumptions on state
@@ -48,12 +53,12 @@ void ByteArrayBufferTest::test() {
 ////////////////////////////////////////////////////////////////////////////////
 void ByteArrayBufferTest::testArray() {
 
-    testBuffer1->put( testData1, 0, testData1Size );
+    testBuffer1->put( testData1, testData1Size, 0, testData1Size );
     testBuffer1->position( 0 );
 
     testBuffer1->mark();
 
-    for( std::size_t ix = 0; ix < testBuffer1->capacity(); ++ix ) {
+    for( int ix = 0; ix < testBuffer1->capacity(); ++ix ) {
         CPPUNIT_ASSERT( testBuffer1->get() == testData1[ix] );
     }
 
@@ -62,7 +67,7 @@ void ByteArrayBufferTest::testArray() {
     unsigned char* array = testBuffer1->array();
     CPPUNIT_ASSERT( array != NULL );
 
-    for( std::size_t ix = 0; ix < testBuffer1->capacity(); ++ix ) {
+    for( int ix = 0; ix < testBuffer1->capacity(); ++ix ) {
         CPPUNIT_ASSERT( array[ix] == testData1[ix] );
     }
 }
@@ -70,7 +75,7 @@ void ByteArrayBufferTest::testArray() {
 ////////////////////////////////////////////////////////////////////////////////
 void ByteArrayBufferTest::testArrayOffset() {
 
-    testBuffer1->put( testData1, 0, testData1Size );
+    testBuffer1->put( testData1, testData1Size, 0, testData1Size );
     CPPUNIT_ASSERT( testBuffer1->arrayOffset() == 0 );
     testBuffer1->rewind();
     CPPUNIT_ASSERT( testBuffer1->arrayOffset() == 0 );
@@ -146,7 +151,7 @@ void ByteArrayBufferTest::testCompact() 
     testBuffer1->clear();
     testBuffer1->mark();
 
-    for( std::size_t ix = 0; ix < testData1Size; ++ix ){
+    for( int ix = 0; ix < testData1Size; ++ix ){
         testBuffer1->put( ix, testData1[ix] );
     }
 
@@ -156,7 +161,7 @@ void ByteArrayBufferTest::testCompact() 
     CPPUNIT_ASSERT( testBuffer1->position() == testBuffer1->capacity() );
     CPPUNIT_ASSERT( testBuffer1->limit() == testBuffer1->capacity() );
 
-    for( std::size_t ix = 0; ix < testBuffer1->capacity(); ix++ ) {
+    for( int ix = 0; ix < testBuffer1->capacity(); ix++ ) {
         CPPUNIT_ASSERT( testBuffer1->get( ix ) == testData1[ix] );
     }
 
@@ -176,7 +181,7 @@ void ByteArrayBufferTest::testCompact() 
     CPPUNIT_ASSERT( testBuffer1->position() == 0 );
     CPPUNIT_ASSERT( testBuffer1->limit() == testBuffer1->capacity() );
 
-    for( std::size_t ix = 0; ix < testBuffer1->capacity(); ix++ ) {
+    for( int ix = 0; ix < testBuffer1->capacity(); ix++ ) {
         CPPUNIT_ASSERT( testBuffer1->get( ix ) == testData1[ix] );
     }
 
@@ -194,7 +199,7 @@ void ByteArrayBufferTest::testCompact() 
     CPPUNIT_ASSERT( testBuffer1->position() == SMALL_TEST_LENGTH - 1  );
     CPPUNIT_ASSERT( testBuffer1->limit() == testBuffer1->capacity() );
 
-    for( std::size_t ix = 0; ix < SMALL_TEST_LENGTH - 1; ix++ ) {
+    for( int ix = 0; ix < SMALL_TEST_LENGTH - 1; ix++ ) {
         CPPUNIT_ASSERT( testBuffer1->get( ix ) == testData1[ix + 1] );
     }
 
@@ -214,11 +219,11 @@ void ByteArrayBufferTest::testCompareTo(
     testBuffer1->clear();
     ByteBuffer* other = ByteBuffer::allocate( testBuffer1->capacity() );
 
-    for( std::size_t ix = 0; ix < testData1Size; ++ix ){
+    for( int ix = 0; ix < testData1Size; ++ix ){
         testBuffer1->put( ix, testData1[ix] );
     }
 
-    for( std::size_t ix = 0; ix < testData1Size; ++ix ){
+    for( int ix = 0; ix < testData1Size; ++ix ){
         other->put( ix, testData1[ix] );
     }
 
@@ -238,7 +243,7 @@ void ByteArrayBufferTest::testCompareTo(
     unsigned char* data = new unsigned char[21];
     memset( data, 0, 21 );
     ByteBuffer* empty = ByteBuffer::allocate(21);
-    ByteBuffer* wrapped = ByteBuffer::wrap( data, (std::size_t)0, (std::size_t)21 );
+    ByteBuffer* wrapped = ByteBuffer::wrap( data, 21, 0, 21 );
 
     CPPUNIT_ASSERT( wrapped->compareTo( *empty ) == 0 );
 
@@ -255,7 +260,7 @@ void ByteArrayBufferTest::testDuplicate(
     testBuffer1->mark();
     testBuffer1->position( testBuffer1->limit() );
 
-    for( std::size_t ix = 0; ix < testData1Size; ++ix ){
+    for( int ix = 0; ix < testData1Size; ++ix ){
         testBuffer1->put( ix, testData1[ix] );
     }
 
@@ -266,7 +271,7 @@ void ByteArrayBufferTest::testDuplicate(
     CPPUNIT_ASSERT( testBuffer1->limit() == duplicate->limit() );
     CPPUNIT_ASSERT( testBuffer1->isReadOnly() == duplicate->isReadOnly() );
 
-    for( std::size_t ix = 0; ix < testBuffer1->capacity(); ix++ ) {
+    for( int ix = 0; ix < testBuffer1->capacity(); ix++ ) {
         CPPUNIT_ASSERT( testBuffer1->get( ix ) == duplicate->get( ix ) );
     }
 
@@ -310,7 +315,7 @@ void ByteArrayBufferTest::testGet() {
 
     testBuffer1->clear();
 
-    for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity(); i++ ) {
         CPPUNIT_ASSERT( testBuffer1->position() == i );
         CPPUNIT_ASSERT( testBuffer1->get() == testBuffer1->get(i) );
     }
@@ -328,7 +333,7 @@ void ByteArrayBufferTest::testGetbyteArr
     array.resize( 1 );
     testBuffer1->clear();
 
-    for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity(); i++ ) {
 
         CPPUNIT_ASSERT( testBuffer1->position() == i );
         ByteBuffer& ret = testBuffer1->get( array );
@@ -351,26 +356,26 @@ void ByteArrayBufferTest::testGetbyteArr
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "Should throw a BufferUnderflowException",
-        testBuffer1->get( array2, 0, testBuffer1->capacity() + 1 ),
+        testBuffer1->get( array2, testBuffer1->capacity() + 1, 0, testBuffer1->capacity() + 1 ),
         BufferUnderflowException );
 
     CPPUNIT_ASSERT( testBuffer1->position() == 0 );
 
-    testBuffer1->get( array, testBuffer1->capacity(), 0 );
+    testBuffer1->get( array, testBuffer1->capacity(), testBuffer1->capacity(), 0 );
 
     CPPUNIT_ASSERT( testBuffer1->position() == 0 );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "Should throw a NullPointerException",
-        testBuffer1->get( NULL, 0, 1 ),
+        testBuffer1->get( NULL, 0, 0, 1 ),
         NullPointerException );
 
     CPPUNIT_ASSERT( testBuffer1->position() == 0 );
 
     testBuffer1->clear();
-    ByteBuffer& ret = testBuffer1->get( array, 0, testBuffer1->capacity() );
+    ByteBuffer& ret = testBuffer1->get( array, testBuffer1->capacity(), 0, testBuffer1->capacity() );
     CPPUNIT_ASSERT( testBuffer1->position() == testBuffer1->capacity() );
-    for( std::size_t ix = 0; ix < testBuffer1->capacity() - 1; ix++ ) {
+    for( int ix = 0; ix < testBuffer1->capacity() - 1; ix++ ) {
         CPPUNIT_ASSERT( testBuffer1->get( ix ) == array[ix] );
     }
 
@@ -385,7 +390,7 @@ void ByteArrayBufferTest::testGetWithInd
 
     testBuffer1->clear();
 
-    for( std::size_t i = 0; i < testBuffer1->capacity(); i++) {
+    for( int i = 0; i < testBuffer1->capacity(); i++) {
         CPPUNIT_ASSERT( testBuffer1->position() == i );
         CPPUNIT_ASSERT( testBuffer1->get() == testBuffer1->get(i) );
     }
@@ -411,7 +416,7 @@ void ByteArrayBufferTest::testPutbyte() 
     delete readOnly;
 
     testBuffer1->clear();
-    for( size_t i = 0; i < testBuffer1->capacity(); i++) {
+    for( int i = 0; i < testBuffer1->capacity(); i++) {
         CPPUNIT_ASSERT( testBuffer1->position() == i );
         ByteBuffer& ret = testBuffer1->put( (unsigned char)i );
         CPPUNIT_ASSERT( testBuffer1->get(i) == i );
@@ -439,7 +444,7 @@ void ByteArrayBufferTest::testPutbyteArr
     delete readOnly;
 
     testBuffer1->clear();
-    for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity(); i++ ) {
         CPPUNIT_ASSERT( testBuffer1->position() == i );
         array[0] = (unsigned char)i;
         ByteBuffer& ret = testBuffer1->put( array );
@@ -460,10 +465,10 @@ void ByteArrayBufferTest::testPutbyteArr
     unsigned char* array = new unsigned char[testBuffer1->capacity()];
     unsigned char* array2 = new unsigned char[testBuffer1->capacity() + 1];
 
-    for( std::size_t ix = 0; ix < testBuffer1->capacity(); ++ix ){
+    for( int ix = 0; ix < testBuffer1->capacity(); ++ix ){
         array[ix] = 0;
     }
-    for( std::size_t ix = 0; ix < testBuffer1->capacity()+1; ++ix ){
+    for( int ix = 0; ix < testBuffer1->capacity()+1; ++ix ){
         array2[ix] = 0;
     }
 
@@ -471,33 +476,33 @@ void ByteArrayBufferTest::testPutbyteArr
     readOnly->clear();
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "Should throw a ReadOnlyBufferException",
-        readOnly->put( array, 0, testBuffer1->capacity() ),
+        readOnly->put( array, testBuffer1->capacity(), 0, testBuffer1->capacity() ),
         ReadOnlyBufferException );
     delete readOnly;
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "Should throw a BufferOverflowException",
-        testBuffer1->put( array2, 0, testBuffer1->capacity() + 1 ),
+        testBuffer1->put( array2, testBuffer1->capacity() + 1, 0, testBuffer1->capacity() + 1 ),
         BufferOverflowException );
 
     CPPUNIT_ASSERT( testBuffer1->position() == 0 );
-    testBuffer1->put( array, testBuffer1->capacity(), 0 );
+    testBuffer1->put( array, testBuffer1->capacity(), testBuffer1->capacity(), 0 );
     CPPUNIT_ASSERT( testBuffer1->position() == 0 );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "Should throw a NullPointerException",
-        testBuffer1->put( NULL, 2, Integer::MAX_VALUE ),
+        testBuffer1->put( NULL, 0, 2, Integer::MAX_VALUE ),
         NullPointerException );
 
     CPPUNIT_ASSERT( testBuffer1->position() == 0 );
 
-    for( std::size_t ix = 0; ix < testData1Size; ++ix ){
+    for( int ix = 0; ix < testData1Size; ++ix ){
         testBuffer1->put( ix, testData1[ix] );
     }
 
-    ByteBuffer& ret = testBuffer1->put( array, 0, testBuffer1->capacity() );
+    ByteBuffer& ret = testBuffer1->put( array, testBuffer1->capacity(), 0, testBuffer1->capacity() );
     CPPUNIT_ASSERT( testBuffer1->position() == testBuffer1->capacity() );
-    for( std::size_t ix = 0; ix < testBuffer1->capacity() - 1; ix++ ) {
+    for( int ix = 0; ix < testBuffer1->capacity() - 1; ix++ ) {
         CPPUNIT_ASSERT( testBuffer1->get( ix ) == array[ix] );
     }
     CPPUNIT_ASSERT( &ret == testBuffer1 );
@@ -532,7 +537,7 @@ void ByteArrayBufferTest::testPutByteBuf
         BufferOverflowException );
     delete toBig;
 
-    for( std::size_t ix = 0; ix < testData1Size; ++ix ){
+    for( int ix = 0; ix < testData1Size; ++ix ){
         other->put( ix, testData1[ix] );
     }
     other->clear();
@@ -541,7 +546,7 @@ void ByteArrayBufferTest::testPutByteBuf
     ByteBuffer& ret = testBuffer1->put( *other );
     CPPUNIT_ASSERT( other->position() == other->capacity() );
     CPPUNIT_ASSERT( testBuffer1->position() == testBuffer1->capacity() );
-    for( std::size_t ix = 0; ix < testBuffer1->capacity() - 1; ix++ ) {
+    for( int ix = 0; ix < testBuffer1->capacity() - 1; ix++ ) {
         CPPUNIT_ASSERT( testBuffer1->get( ix ) == other->get( ix ) );
     }
     CPPUNIT_ASSERT( &ret == testBuffer1 );
@@ -562,7 +567,7 @@ void ByteArrayBufferTest::testPutIndexed
 
     testBuffer1->clear();
 
-    for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity(); i++ ) {
         CPPUNIT_ASSERT( testBuffer1->position() == 0 );
         ByteBuffer& ret = testBuffer1->put( i, (unsigned char)i );
         CPPUNIT_ASSERT( testBuffer1->get(i) == i );
@@ -594,11 +599,11 @@ void ByteArrayBufferTest::testSlice() {
         InvalidMarkException );
 
     // slice share the same content with buf
-    for( std::size_t ix = 0; ix < slice->capacity(); ++ix ){
+    for( int ix = 0; ix < slice->capacity(); ++ix ){
         slice->put( ix, testData1[ix] );
     }
 
-    for( std::size_t ix = 0; ix < slice->capacity(); ix++ ) {
+    for( int ix = 0; ix < slice->capacity(); ix++ ) {
         CPPUNIT_ASSERT( testBuffer1->get( ix + 1 ) == slice->get( ix ) );
     }
     testBuffer1->put( 2, 100 );
@@ -621,13 +626,13 @@ void ByteArrayBufferTest::testToString()
 void ByteArrayBufferTest::testGetChar() {
 
     std::vector<char> chars;
-    for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity(); i++ ) {
         testBuffer1->put( i, (char)i);
         chars.push_back( (char)i );
     }
     testBuffer1->clear();
 
-    for( std::size_t i = 0; testBuffer1->remaining() != 0; i++ ) {
+    for( int i = 0; testBuffer1->remaining() != 0; i++ ) {
         CPPUNIT_ASSERT( testBuffer1->getChar() == chars[i] );
     }
 
@@ -641,13 +646,13 @@ void ByteArrayBufferTest::testGetChar() 
 void ByteArrayBufferTest::testGetChar2() {
 
     std::vector<char> chars;
-    for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity(); i++ ) {
         testBuffer1->put( i, (char)i);
         chars.push_back( (char)i );
     }
     testBuffer1->clear();
 
-    for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity(); i++ ) {
         CPPUNIT_ASSERT( testBuffer1->getChar( i ) == chars[i] );
     }
 
@@ -670,7 +675,7 @@ void ByteArrayBufferTest::testPutChar() 
 
     testBuffer1->clear();
 
-    for( std::size_t i = 0; testBuffer1->remaining() > 0; i++ ) {
+    for( int i = 0; testBuffer1->remaining() > 0; i++ ) {
 
         testBuffer1->mark();
         testBuffer1->putChar( (char)i );
@@ -697,7 +702,7 @@ void ByteArrayBufferTest::testPutChar2()
 
     testBuffer1->clear();
 
-    std::size_t i = 0;
+    int i = 0;
     for( ; i < testBuffer1->capacity(); i++ ) {
 
         testBuffer1->mark();
@@ -716,14 +721,14 @@ void ByteArrayBufferTest::testPutChar2()
 void ByteArrayBufferTest::testGetDouble() {
 
     std::vector<double> values;
-    for( std::size_t i = 0; i < testBuffer1->capacity() / sizeof( double ); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity() / (int)sizeof( double ); i++ ) {
         testBuffer1->putDouble( (double)i );
         values.push_back( (double)i );
     }
     testBuffer1->clear();
 
-    for( std::size_t i = 0;
-         testBuffer1->remaining() >= sizeof( double ); i++ ) {
+    for( int i = 0;
+         testBuffer1->remaining() >= (int)sizeof( double ); i++ ) {
 
         CPPUNIT_ASSERT( testBuffer1->getDouble() == values[i] );
     }
@@ -738,7 +743,7 @@ void ByteArrayBufferTest::testGetDouble(
 void ByteArrayBufferTest::testGetDouble2() {
 
     std::vector<double> values;
-    for( std::size_t i = 0; i < testBuffer1->capacity() / sizeof( double ); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity() / (int)sizeof( double ); i++ ) {
         testBuffer1->putDouble( (double)i );
         values.push_back( (double)i );
     }
@@ -747,7 +752,7 @@ void ByteArrayBufferTest::testGetDouble2
     std::size_t i = 0;
     std::size_t j = 0;
 
-    for( ; ( testBuffer1->capacity() - i ) >= sizeof( double ); i += sizeof( double ), j++ ) {
+    for( ; ( testBuffer1->capacity() - i ) >= (int)sizeof( double ); i += (int)sizeof( double ), j++ ) {
         CPPUNIT_ASSERT( testBuffer1->getDouble( i ) == values[j] );
     }
 
@@ -770,7 +775,7 @@ void ByteArrayBufferTest::testPutDouble(
 
     testBuffer1->clear();
 
-    for( std::size_t i = 0; testBuffer1->remaining() >= sizeof( double );
+    for( int i = 0; testBuffer1->remaining() >= (int)sizeof( double );
          i += sizeof( double ) ) {
 
         testBuffer1->mark();
@@ -800,7 +805,7 @@ void ByteArrayBufferTest::testPutDouble2
     testBuffer1->clear();
 
     std::size_t i = 0;
-    for( ; ( testBuffer1->capacity() - i ) >= sizeof( double ); i += sizeof( double ) ) {
+    for( ; ( testBuffer1->capacity() - i ) >= (int)sizeof( double ); i += (int)sizeof( double ) ) {
 
         testBuffer1->mark();
         testBuffer1->putDouble( i, i + 99.99 );
@@ -819,14 +824,14 @@ void ByteArrayBufferTest::testPutDouble2
 void ByteArrayBufferTest::testGetFloat() {
 
     std::vector<float> values;
-    for( std::size_t i = 0; i < testBuffer1->capacity() / sizeof( float ); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity() / (int)sizeof( float ); i++ ) {
         testBuffer1->putFloat( (float)i );
         values.push_back( (float)i );
     }
     testBuffer1->clear();
 
-    for( std::size_t i = 0;
-         testBuffer1->remaining() >= sizeof( float ); i++ ) {
+    for( int i = 0;
+         testBuffer1->remaining() >= (int)sizeof( float ); i++ ) {
 
         CPPUNIT_ASSERT( testBuffer1->getFloat() == values[i] );
     }
@@ -841,7 +846,7 @@ void ByteArrayBufferTest::testGetFloat()
 void ByteArrayBufferTest::testGetFloat2() {
 
     std::vector<float> values;
-    for( std::size_t i = 0; i < testBuffer1->capacity() / sizeof( float ); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity() / (int)sizeof( float ); i++ ) {
         testBuffer1->putFloat( (float)i );
         values.push_back( (float)i );
     }
@@ -850,7 +855,7 @@ void ByteArrayBufferTest::testGetFloat2(
     std::size_t i = 0;
     std::size_t j = 0;
 
-    for( ; ( testBuffer1->capacity() - i ) >= sizeof( float ); i += sizeof( float ), j++ ) {
+    for( ; ( testBuffer1->capacity() - i ) >= (int)sizeof( float ); i += (int)sizeof( float ), j++ ) {
         CPPUNIT_ASSERT( testBuffer1->getFloat( i ) == values[j] );
     }
 
@@ -873,7 +878,7 @@ void ByteArrayBufferTest::testPutFloat()
 
     testBuffer1->clear();
 
-    for( std::size_t i = 0; testBuffer1->remaining() >= sizeof( float );
+    for( int i = 0; testBuffer1->remaining() >= (int)sizeof( float );
          i += sizeof( float ) ) {
 
         testBuffer1->mark();
@@ -903,7 +908,7 @@ void ByteArrayBufferTest::testPutFloat2(
     testBuffer1->clear();
 
     std::size_t i = 0;
-    for( ; ( testBuffer1->capacity() - i ) >= sizeof( float ); i += sizeof( float ) ) {
+    for( ; ( testBuffer1->capacity() - i ) >= (int)sizeof( float ); i += sizeof( float ) ) {
 
         testBuffer1->mark();
         testBuffer1->putFloat( i, i + 99.99f );
@@ -922,14 +927,14 @@ void ByteArrayBufferTest::testPutFloat2(
 void ByteArrayBufferTest::testGetLong() {
 
     std::vector<long long> values;
-    for( std::size_t i = 0; i < testBuffer1->capacity() / sizeof( long long ); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity() / (int)sizeof( long long ); i++ ) {
         testBuffer1->putLong( (long long)i );
         values.push_back( (long long)i );
     }
     testBuffer1->clear();
 
-    for( std::size_t i = 0;
-         testBuffer1->remaining() >= sizeof( long long ); i++ ) {
+    for( int i = 0;
+         testBuffer1->remaining() >= (int)sizeof( long long ); i++ ) {
 
         CPPUNIT_ASSERT( testBuffer1->getLong() == values[i] );
     }
@@ -944,7 +949,7 @@ void ByteArrayBufferTest::testGetLong() 
 void ByteArrayBufferTest::testGetLong2() {
 
     std::vector<long long> values;
-    for( std::size_t i = 0; i < testBuffer1->capacity() / sizeof( long long ); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity() / (int)sizeof( long long ); i++ ) {
         testBuffer1->putLong( (long long)i );
         values.push_back( (long long)i );
     }
@@ -953,7 +958,7 @@ void ByteArrayBufferTest::testGetLong2()
     std::size_t i = 0;
     std::size_t j = 0;
 
-    for( ; ( testBuffer1->capacity() - i ) >= sizeof( long long ); i += sizeof( long long ), j++ ) {
+    for( ; ( testBuffer1->capacity() - i ) >= (int)sizeof( long long ); i += (int)sizeof( long long ), j++ ) {
         CPPUNIT_ASSERT( testBuffer1->getLong( i ) == values[j] );
     }
 
@@ -976,7 +981,7 @@ void ByteArrayBufferTest::testPutLong() 
 
     testBuffer1->clear();
 
-    for( std::size_t i = 0; testBuffer1->remaining() >= sizeof( long long );
+    for( int i = 0; testBuffer1->remaining() >= (int)sizeof( long long );
          i += sizeof( long long ) ) {
 
         testBuffer1->mark();
@@ -1005,7 +1010,7 @@ void ByteArrayBufferTest::testPutLong2()
     testBuffer1->clear();
 
     std::size_t i = 0;
-    for( ; ( testBuffer1->capacity() - i ) >= sizeof( long long ); i += sizeof( long long ) ) {
+    for( ; ( testBuffer1->capacity() - i ) >= (int)sizeof( long long ); i += (int)sizeof( long long ) ) {
 
         testBuffer1->mark();
         testBuffer1->putLong( i, i + 99 );
@@ -1023,14 +1028,14 @@ void ByteArrayBufferTest::testPutLong2()
 void ByteArrayBufferTest::testGetInt() {
 
     std::vector<int> values;
-    for( std::size_t i = 0; i < testBuffer1->capacity() / sizeof( int ); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity() / (int)sizeof( int ); i++ ) {
         testBuffer1->putInt( (int)i );
         values.push_back( (int)i );
     }
     testBuffer1->clear();
 
-    for( std::size_t i = 0;
-         testBuffer1->remaining() >= sizeof( int ); i++ ) {
+    for( int i = 0;
+         testBuffer1->remaining() >= (int)sizeof( int ); i++ ) {
 
         CPPUNIT_ASSERT( testBuffer1->getInt() == values[i] );
     }
@@ -1045,7 +1050,7 @@ void ByteArrayBufferTest::testGetInt() {
 void ByteArrayBufferTest::testGetInt2() {
 
     std::vector<int> values;
-    for( std::size_t i = 0; i < testBuffer1->capacity() / sizeof( int ); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity() / (int)sizeof( int ); i++ ) {
         testBuffer1->putInt( (int)i );
         values.push_back( (int)i );
     }
@@ -1054,7 +1059,7 @@ void ByteArrayBufferTest::testGetInt2() 
     std::size_t i = 0;
     std::size_t j = 0;
 
-    for( ; ( testBuffer1->capacity() - i ) >= sizeof( int ); i += sizeof( int ), j++ ) {
+    for( ; ( testBuffer1->capacity() - i ) >= (int)sizeof( int ); i += (int)sizeof( int ), j++ ) {
         CPPUNIT_ASSERT( testBuffer1->getInt( i ) == values[j] );
     }
 
@@ -1077,7 +1082,7 @@ void ByteArrayBufferTest::testPutInt() {
 
     testBuffer1->clear();
 
-    for( std::size_t i = 0; testBuffer1->remaining() >= sizeof( int );
+    for( int i = 0; testBuffer1->remaining() >= (int)sizeof( int );
          i += sizeof( int ) ) {
 
         testBuffer1->mark();
@@ -1106,7 +1111,7 @@ void ByteArrayBufferTest::testPutInt2() 
     testBuffer1->clear();
 
     std::size_t i = 0;
-    for( ; ( testBuffer1->capacity() - i ) >= sizeof( int ); i += sizeof( int ) ) {
+    for( ; ( testBuffer1->capacity() - i ) >= (int)sizeof( int ); i += sizeof( int ) ) {
 
         testBuffer1->mark();
         testBuffer1->putInt( i, (int)i + 99 );
@@ -1124,14 +1129,14 @@ void ByteArrayBufferTest::testPutInt2() 
 void ByteArrayBufferTest::testGetShort() {
 
     std::vector<short> values;
-    for( std::size_t i = 0; i < testBuffer1->capacity() / sizeof( short ); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity() / (int)sizeof( short ); i++ ) {
         testBuffer1->putShort( (short)i );
         values.push_back( (short)i );
     }
     testBuffer1->clear();
 
-    for( std::size_t i = 0;
-         testBuffer1->remaining() >= sizeof( short ); i++ ) {
+    for( int i = 0;
+         testBuffer1->remaining() >= (int)sizeof( short ); i++ ) {
 
         CPPUNIT_ASSERT( testBuffer1->getShort() == values[i] );
     }
@@ -1146,7 +1151,7 @@ void ByteArrayBufferTest::testGetShort()
 void ByteArrayBufferTest::testGetShort2() {
 
     std::vector<short> values;
-    for( std::size_t i = 0; i < testBuffer1->capacity() / sizeof( short ); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity() / (int)sizeof( short ); i++ ) {
         testBuffer1->putShort( (short)i );
         values.push_back( (short)i );
     }
@@ -1155,7 +1160,7 @@ void ByteArrayBufferTest::testGetShort2(
     std::size_t i = 0;
     std::size_t j = 0;
 
-    for( ; ( testBuffer1->capacity() - i ) >= sizeof( short ); i += sizeof( short ), j++ ) {
+    for( ; ( testBuffer1->capacity() - i ) >= (int)sizeof( short ); i += (int)sizeof( short ), j++ ) {
         CPPUNIT_ASSERT( testBuffer1->getShort( i ) == values[j] );
     }
 
@@ -1178,7 +1183,7 @@ void ByteArrayBufferTest::testPutShort()
 
     testBuffer1->clear();
 
-    for( std::size_t i = 0; testBuffer1->remaining() >= sizeof( short );
+    for( int i = 0; testBuffer1->remaining() >= (int)sizeof( short );
          i += sizeof( short ) ) {
 
         testBuffer1->mark();
@@ -1207,7 +1212,7 @@ void ByteArrayBufferTest::testPutShort2(
     testBuffer1->clear();
 
     std::size_t i = 0;
-    for( ; ( testBuffer1->capacity() - i ) >= sizeof( short ); i += sizeof( short ) ) {
+    for( ; ( testBuffer1->capacity() - i ) >= (int)sizeof( short ); i += (int)sizeof( short ) ) {
 
         testBuffer1->mark();
         testBuffer1->putShort( i, (short)(i + 99) );
@@ -1226,6 +1231,6 @@ void ByteArrayBufferTest::testWrapNullAr
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "Should throw a NullPointerException",
-        testBuffer1->wrap( NULL, 0, 3 ),
+        testBuffer1->wrap( NULL, 0, 0, 3 ),
         NullPointerException );
 }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/ByteArrayBufferTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/ByteArrayBufferTest.h?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/ByteArrayBufferTest.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/ByteArrayBufferTest.h Sat Mar 20 21:57:20 2010
@@ -82,9 +82,9 @@ namespace nio{
         decaf::nio::ByteBuffer* testBuffer1;
         unsigned char* testData1;
 
-        static const std::size_t testData1Size = 100;
-        static const std::size_t SMALL_TEST_LENGTH = 5;
-        static const std::size_t BUFFER_LENGTH = 250;
+        static const int testData1Size;
+        static const int SMALL_TEST_LENGTH;
+        static const int BUFFER_LENGTH;
 
     public:
 
@@ -95,7 +95,7 @@ namespace nio{
            testBuffer1 = decaf::nio::ByteBuffer::allocate( testData1Size );
 
             testData1 = new unsigned char[testData1Size];
-            for( std::size_t i = 0; i < testData1Size; ++i ){
+            for( int i = 0; i < testData1Size; ++i ){
                 testData1[i] = (unsigned char)i;
             }
         }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/CharArrayBufferTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/CharArrayBufferTest.cpp?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/CharArrayBufferTest.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/CharArrayBufferTest.cpp Sat Mar 20 21:57:20 2010
@@ -29,6 +29,67 @@ using namespace decaf::lang;
 using namespace decaf::lang::exceptions;
 
 ////////////////////////////////////////////////////////////////////////////////
+const int CharArrayBufferTest::testData1Size = 100;
+const int CharArrayBufferTest::SMALL_TEST_LENGTH = 5;
+const int CharArrayBufferTest::BUFFER_LENGTH = 250;
+
+////////////////////////////////////////////////////////////////////////////////
+namespace{
+
+    class MyCharSequence : public lang::CharSequence {
+    private:
+
+        std::string value;
+
+    public:
+
+        MyCharSequence( std::string value ) {
+            this->value = value;
+        }
+
+        virtual ~MyCharSequence() {}
+
+        virtual int length() const {
+            return (int)this->value.length();
+        }
+
+        virtual char charAt( int index ) const
+            throw( lang::exceptions::IndexOutOfBoundsException ) {
+
+            if( index > (int)this->value.length() ) {
+                throw decaf::lang::exceptions::IndexOutOfBoundsException(
+                    __FILE__, __LINE__,
+                    "MyCharSequence::charAt - index is to big: %d", index );
+            }
+
+            return this->value.at( index );
+        }
+
+        virtual CharSequence* subSequence( int start, int end ) const
+            throw( lang::exceptions::IndexOutOfBoundsException ) {
+
+            if( start > end ) {
+                throw decaf::lang::exceptions::IndexOutOfBoundsException(
+                    __FILE__, __LINE__,
+                    "CharArrayBuffer::subSequence - start > end" );
+            }
+
+            if( start > this->length() || end > this->length() ) {
+                throw decaf::lang::exceptions::IndexOutOfBoundsException(
+                    __FILE__, __LINE__,
+                    "CharArrayBuffer::subSequence - Sequence exceed limit" );
+            }
+
+            return new MyCharSequence( this->value.substr( start, end - start ) );
+        }
+
+        virtual std::string toString() const {
+            return this->value;
+        }
+    };
+}
+
+////////////////////////////////////////////////////////////////////////////////
 void CharArrayBufferTest::test() {
 
     // Check that we have setup the array and our initial assumptions on state
@@ -48,12 +109,12 @@ void CharArrayBufferTest::test() {
 ////////////////////////////////////////////////////////////////////////////////
 void CharArrayBufferTest::testArray() {
 
-    testBuffer1->put( testData1, 0, testData1Size );
+    testBuffer1->put( testData1, testData1Size, 0, testData1Size );
     testBuffer1->position( 0 );
 
     testBuffer1->mark();
 
-    for( std::size_t ix = 0; ix < testBuffer1->capacity(); ++ix ) {
+    for( int ix = 0; ix < testBuffer1->capacity(); ++ix ) {
         CPPUNIT_ASSERT( testBuffer1->get() == testData1[ix] );
     }
 
@@ -62,7 +123,7 @@ void CharArrayBufferTest::testArray() {
     char* array = testBuffer1->array();
     CPPUNIT_ASSERT( array != NULL );
 
-    for( std::size_t ix = 0; ix < testBuffer1->capacity(); ++ix ) {
+    for( int ix = 0; ix < testBuffer1->capacity(); ++ix ) {
         CPPUNIT_ASSERT( array[ix] == testData1[ix] );
     }
 }
@@ -70,7 +131,7 @@ void CharArrayBufferTest::testArray() {
 ////////////////////////////////////////////////////////////////////////////////
 void CharArrayBufferTest::testArrayOffset() {
 
-    testBuffer1->put( testData1, 0, testData1Size );
+    testBuffer1->put( testData1, testData1Size, 0, testData1Size );
     CPPUNIT_ASSERT( testBuffer1->arrayOffset() == 0 );
     testBuffer1->rewind();
     CPPUNIT_ASSERT( testBuffer1->arrayOffset() == 0 );
@@ -146,7 +207,7 @@ void CharArrayBufferTest::testCompact() 
     testBuffer1->clear();
     testBuffer1->mark();
 
-    for( std::size_t ix = 0; ix < testData1Size; ++ix ){
+    for( int ix = 0; ix < testData1Size; ++ix ){
         testBuffer1->put( ix, testData1[ix] );
     }
 
@@ -156,7 +217,7 @@ void CharArrayBufferTest::testCompact() 
     CPPUNIT_ASSERT( testBuffer1->position() == testBuffer1->capacity() );
     CPPUNIT_ASSERT( testBuffer1->limit() == testBuffer1->capacity() );
 
-    for( std::size_t ix = 0; ix < testBuffer1->capacity(); ix++ ) {
+    for( int ix = 0; ix < testBuffer1->capacity(); ix++ ) {
         CPPUNIT_ASSERT( testBuffer1->get( ix ) == testData1[ix] );
     }
 
@@ -176,7 +237,7 @@ void CharArrayBufferTest::testCompact() 
     CPPUNIT_ASSERT( testBuffer1->position() == 0 );
     CPPUNIT_ASSERT( testBuffer1->limit() == testBuffer1->capacity() );
 
-    for( std::size_t ix = 0; ix < testBuffer1->capacity(); ix++ ) {
+    for( int ix = 0; ix < testBuffer1->capacity(); ix++ ) {
         CPPUNIT_ASSERT( testBuffer1->get( ix ) == testData1[ix] );
     }
 
@@ -194,7 +255,7 @@ void CharArrayBufferTest::testCompact() 
     CPPUNIT_ASSERT( testBuffer1->position() == SMALL_TEST_LENGTH - 1  );
     CPPUNIT_ASSERT( testBuffer1->limit() == testBuffer1->capacity() );
 
-    for( std::size_t ix = 0; ix < SMALL_TEST_LENGTH - 1; ix++ ) {
+    for( int ix = 0; ix < SMALL_TEST_LENGTH - 1; ix++ ) {
         CPPUNIT_ASSERT( testBuffer1->get( ix ) == testData1[ix + 1] );
     }
 
@@ -214,11 +275,11 @@ void CharArrayBufferTest::testCompareTo(
     testBuffer1->clear();
     CharBuffer* other = CharBuffer::allocate( testBuffer1->capacity() );
 
-    for( std::size_t ix = 0; ix < testData1Size; ++ix ){
+    for( int ix = 0; ix < testData1Size; ++ix ){
         testBuffer1->put( ix, testData1[ix] );
     }
 
-    for( std::size_t ix = 0; ix < testData1Size; ++ix ){
+    for( int ix = 0; ix < testData1Size; ++ix ){
         other->put( ix, testData1[ix] );
     }
 
@@ -238,7 +299,7 @@ void CharArrayBufferTest::testCompareTo(
     char* data = new char[21];
     memset( data, 0, 21 );
     CharBuffer* empty = CharBuffer::allocate(21);
-    CharBuffer* wrapped = CharBuffer::wrap( data, (std::size_t)0, (std::size_t)21 );
+    CharBuffer* wrapped = CharBuffer::wrap( data, 21, 0, 21 );
 
     CPPUNIT_ASSERT( wrapped->compareTo( *empty ) == 0 );
 
@@ -255,7 +316,7 @@ void CharArrayBufferTest::testDuplicate(
     testBuffer1->mark();
     testBuffer1->position( testBuffer1->limit() );
 
-    for( std::size_t ix = 0; ix < testData1Size; ++ix ){
+    for( int ix = 0; ix < testData1Size; ++ix ){
         testBuffer1->put( ix, testData1[ix] );
     }
 
@@ -266,7 +327,7 @@ void CharArrayBufferTest::testDuplicate(
     CPPUNIT_ASSERT( testBuffer1->limit() == duplicate->limit() );
     CPPUNIT_ASSERT( testBuffer1->isReadOnly() == duplicate->isReadOnly() );
 
-    for( std::size_t ix = 0; ix < testBuffer1->capacity(); ix++ ) {
+    for( int ix = 0; ix < testBuffer1->capacity(); ix++ ) {
         CPPUNIT_ASSERT( testBuffer1->get( ix ) == duplicate->get( ix ) );
     }
 
@@ -310,7 +371,7 @@ void CharArrayBufferTest::testGet() {
 
     testBuffer1->clear();
 
-    for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity(); i++ ) {
         CPPUNIT_ASSERT( testBuffer1->position() == i );
         CPPUNIT_ASSERT( testBuffer1->get() == testBuffer1->get(i) );
     }
@@ -328,7 +389,7 @@ void CharArrayBufferTest::testGetbyteArr
     array.resize( 1 );
     testBuffer1->clear();
 
-    for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity(); i++ ) {
 
         CPPUNIT_ASSERT( testBuffer1->position() == i );
         CharBuffer& ret = testBuffer1->get( array );
@@ -351,26 +412,61 @@ void CharArrayBufferTest::testGetbyteArr
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "Should throw a BufferUnderflowException",
-        testBuffer1->get( array2, 0, testBuffer1->capacity() + 1 ),
+        testBuffer1->get( array2, testBuffer1->capacity() + 1, 0, testBuffer1->capacity() + 1 ),
         BufferUnderflowException );
 
     CPPUNIT_ASSERT( testBuffer1->position() == 0 );
 
-    testBuffer1->get( array, testBuffer1->capacity(), 0 );
+    testBuffer1->get( array, testBuffer1->capacity(), testBuffer1->capacity(), 0 );
 
     CPPUNIT_ASSERT( testBuffer1->position() == 0 );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->get( array, testBuffer1->capacity(), -1, testBuffer1->capacity() ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->get( array, testBuffer1->capacity(), testBuffer1->capacity() + 1, 1 ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->get( array, testBuffer1->capacity(), 2, -1 ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->get( array, testBuffer1->capacity(), 2, testBuffer1->capacity() ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->get( array, testBuffer1->capacity(), 1, Integer::MAX_VALUE ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->get( array, testBuffer1->capacity(), Integer::MAX_VALUE, 1 ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw NullPointerException",
+        testBuffer1->get( NULL, testBuffer1->capacity(), 1, Integer::MAX_VALUE ),
+        NullPointerException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
         "Should throw a NullPointerException",
-        testBuffer1->get( NULL, 0, 1 ),
+        testBuffer1->get( NULL, 0, 0, 1 ),
         NullPointerException );
 
     CPPUNIT_ASSERT( testBuffer1->position() == 0 );
 
     testBuffer1->clear();
-    CharBuffer& ret = testBuffer1->get( array, 0, testBuffer1->capacity() );
+    CharBuffer& ret = testBuffer1->get( array, testBuffer1->capacity(), 0, testBuffer1->capacity() );
     CPPUNIT_ASSERT( testBuffer1->position() == testBuffer1->capacity() );
-    for( std::size_t ix = 0; ix < testBuffer1->capacity() - 1; ix++ ) {
+    for( int ix = 0; ix < testBuffer1->capacity() - 1; ix++ ) {
         CPPUNIT_ASSERT( testBuffer1->get( ix ) == array[ix] );
     }
 
@@ -385,13 +481,18 @@ void CharArrayBufferTest::testGetWithInd
 
     testBuffer1->clear();
 
-    for( std::size_t i = 0; i < testBuffer1->capacity(); i++) {
+    for( int i = 0; i < testBuffer1->capacity(); i++) {
         CPPUNIT_ASSERT( testBuffer1->position() == i );
         CPPUNIT_ASSERT( testBuffer1->get() == testBuffer1->get(i) );
     }
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "Should throw a IndexOutOfBoundsException",
+        testBuffer1->get( -1 ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw a IndexOutOfBoundsException",
         testBuffer1->get( testBuffer1->limit() ),
         IndexOutOfBoundsException );
 }
@@ -411,7 +512,7 @@ void CharArrayBufferTest::testPutbyte() 
     delete readOnly;
 
     testBuffer1->clear();
-    for( size_t i = 0; i < testBuffer1->capacity(); i++) {
+    for( int i = 0; i < testBuffer1->capacity(); i++) {
         CPPUNIT_ASSERT( testBuffer1->position() == i );
         CharBuffer& ret = testBuffer1->put( (char)i );
         CPPUNIT_ASSERT( testBuffer1->get(i) == (char)i );
@@ -439,7 +540,7 @@ void CharArrayBufferTest::testPutbyteArr
     delete readOnly;
 
     testBuffer1->clear();
-    for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity(); i++ ) {
         CPPUNIT_ASSERT( testBuffer1->position() == i );
         array[0] = (char)i;
         CharBuffer& ret = testBuffer1->put( array );
@@ -460,10 +561,10 @@ void CharArrayBufferTest::testPutbyteArr
     char* array = new char[testBuffer1->capacity()];
     char* array2 = new char[testBuffer1->capacity() + 1];
 
-    for( std::size_t ix = 0; ix < testBuffer1->capacity(); ++ix ){
+    for( int ix = 0; ix < testBuffer1->capacity(); ++ix ){
         array[ix] = 0;
     }
-    for( std::size_t ix = 0; ix < testBuffer1->capacity() + 1; ++ix ){
+    for( int ix = 0; ix < testBuffer1->capacity() + 1; ++ix ){
         array2[ix] = 0;
     }
 
@@ -471,33 +572,33 @@ void CharArrayBufferTest::testPutbyteArr
     readOnly->clear();
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "Should throw a ReadOnlyBufferException",
-        readOnly->put( array, 0, testBuffer1->capacity() ),
+        readOnly->put( array, testBuffer1->capacity(), 0, testBuffer1->capacity() ),
         ReadOnlyBufferException );
     delete readOnly;
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "Should throw a BufferOverflowException",
-        testBuffer1->put( array2, 0, testBuffer1->capacity() + 1 ),
+        testBuffer1->put( array2, testBuffer1->capacity() + 1, 0, testBuffer1->capacity() + 1 ),
         BufferOverflowException );
 
     CPPUNIT_ASSERT( testBuffer1->position() == 0 );
-    testBuffer1->put( array, testBuffer1->capacity(), 0 );
+    testBuffer1->put( array, testBuffer1->capacity(), testBuffer1->capacity(), 0 );
     CPPUNIT_ASSERT( testBuffer1->position() == 0 );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "Should throw a NullPointerException",
-        testBuffer1->put( NULL, 2, Integer::MAX_VALUE ),
+        testBuffer1->put( NULL, 0, 2, Integer::MAX_VALUE ),
         NullPointerException );
 
     CPPUNIT_ASSERT( testBuffer1->position() == 0 );
 
-    for( std::size_t ix = 0; ix < testData1Size; ++ix ){
+    for( int ix = 0; ix < testData1Size; ++ix ){
         testBuffer1->put( ix, testData1[ix] );
     }
 
-    CharBuffer& ret = testBuffer1->put( array, 0, testBuffer1->capacity() );
+    CharBuffer& ret = testBuffer1->put( array, testBuffer1->capacity(), 0, testBuffer1->capacity() );
     CPPUNIT_ASSERT( testBuffer1->position() == testBuffer1->capacity() );
-    for( std::size_t ix = 0; ix < testBuffer1->capacity() - 1; ix++ ) {
+    for( int ix = 0; ix < testBuffer1->capacity() - 1; ix++ ) {
         CPPUNIT_ASSERT( testBuffer1->get( ix ) == array[ix] );
     }
     CPPUNIT_ASSERT( &ret == testBuffer1 );
@@ -532,7 +633,7 @@ void CharArrayBufferTest::testPutCharBuf
         BufferOverflowException );
     delete toBig;
 
-    for( std::size_t ix = 0; ix < testData1Size; ++ix ){
+    for( int ix = 0; ix < testData1Size; ++ix ){
         other->put( ix, testData1[ix] );
     }
     other->clear();
@@ -541,7 +642,7 @@ void CharArrayBufferTest::testPutCharBuf
     CharBuffer& ret = testBuffer1->put( *other );
     CPPUNIT_ASSERT( other->position() == other->capacity() );
     CPPUNIT_ASSERT( testBuffer1->position() == testBuffer1->capacity() );
-    for( std::size_t ix = 0; ix < testBuffer1->capacity() - 1; ix++ ) {
+    for( int ix = 0; ix < testBuffer1->capacity() - 1; ix++ ) {
         CPPUNIT_ASSERT( testBuffer1->get( ix ) == other->get( ix ) );
     }
     CPPUNIT_ASSERT( &ret == testBuffer1 );
@@ -562,7 +663,7 @@ void CharArrayBufferTest::testPutIndexed
 
     testBuffer1->clear();
 
-    for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity(); i++ ) {
         CPPUNIT_ASSERT( testBuffer1->position() == 0 );
         CharBuffer& ret = testBuffer1->put( i, (char)i );
         CPPUNIT_ASSERT( testBuffer1->get(i) == (char)i );
@@ -571,6 +672,11 @@ void CharArrayBufferTest::testPutIndexed
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "Should throw a IndexOutOfBoundsException",
+        testBuffer1->put( -1, 0 ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw a IndexOutOfBoundsException",
         testBuffer1->put( testBuffer1->limit(), 0 ),
         IndexOutOfBoundsException );
 }
@@ -594,11 +700,11 @@ void CharArrayBufferTest::testSlice() {
         InvalidMarkException );
 
     // slice share the same content with buf
-    for( std::size_t ix = 0; ix < slice->capacity(); ++ix ){
+    for( int ix = 0; ix < slice->capacity(); ++ix ){
         slice->put( ix, testData1[ix] );
     }
 
-    for( std::size_t ix = 0; ix < slice->capacity(); ix++ ) {
+    for( int ix = 0; ix < slice->capacity(); ix++ ) {
         CPPUNIT_ASSERT( testBuffer1->get( ix + 1 ) == slice->get( ix ) );
     }
     testBuffer1->put( 2, 100 );
@@ -611,7 +717,7 @@ void CharArrayBufferTest::testSlice() {
 void CharArrayBufferTest::testToString() {
 
     string expected = "";
-    for( std::size_t i = testBuffer1->position(); i < testBuffer1->limit(); i++ ) {
+    for( int i = testBuffer1->position(); i < testBuffer1->limit(); i++ ) {
         expected += testBuffer1->get(i);
     }
     string str = testBuffer1->toString();
@@ -623,14 +729,14 @@ void CharArrayBufferTest::testWrapNullAr
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "Should throw a NullPointerException",
-        testBuffer1->wrap( (char*)NULL, 0, 3 ),
+        testBuffer1->wrap( (char*)NULL, 0, 0, 3 ),
         NullPointerException );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void CharArrayBufferTest::testCharAt() {
 
-    for( std::size_t i = 0; i < testBuffer1->remaining(); i++ ) {
+    for( int i = 0; i < testBuffer1->remaining(); i++ ) {
         CPPUNIT_ASSERT( testBuffer1->get( testBuffer1->position() + i ) ==
                         testBuffer1->charAt(i) );
     }
@@ -639,6 +745,11 @@ void CharArrayBufferTest::testCharAt() {
         "Should throw a IndexOutOfBoundsException",
         testBuffer1->charAt( testBuffer1->remaining() ),
         IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw a IndexOutOfBoundsException",
+        testBuffer1->charAt( -1 ),
+        IndexOutOfBoundsException );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -678,7 +789,7 @@ void CharArrayBufferTest::testSubSequenc
 void CharArrayBufferTest::testPutString() {
 
     testBuffer1->clear();
-    for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity(); i++ ) {
         CPPUNIT_ASSERT( testBuffer1->position() == i );
         string testString = " ";
         testString[0] = (char)i;
@@ -738,7 +849,7 @@ void CharArrayBufferTest::testPutStringW
     CharBuffer& ret = testBuffer1->put( str, 0, str.length() );
     CPPUNIT_ASSERT( testBuffer1->position() == testBuffer1->capacity() );
 
-    for( std::size_t ix = 0; ix < testBuffer1->capacity(); ++ix ) {
+    for( int ix = 0; ix < testBuffer1->capacity(); ++ix ) {
         CPPUNIT_ASSERT( testBuffer1->get( ix ) == str.at( ix ) );
     }
 
@@ -919,7 +1030,7 @@ void CharArrayBufferTest::testReadCharBu
     CPPUNIT_ASSERT( "String" == target->toString() );
 
     // return -1 when nothing to read
-    CPPUNIT_ASSERT( string::npos == source->read( target ) );
+    CPPUNIT_ASSERT( -1 == source->read( target ) );
 
     // NullPointerException
     CPPUNIT_ASSERT_THROW_MESSAGE(
@@ -934,7 +1045,7 @@ void CharArrayBufferTest::testReadCharBu
 ////////////////////////////////////////////////////////////////////////////////
 void CharArrayBufferTest::testReadReadOnly() {
 
-    CharBuffer* source = CharBuffer::wrap( testData1, 0, testData1Size );
+    CharBuffer* source = CharBuffer::wrap( testData1, testData1Size, 0, testData1Size );
     CharBuffer* target = testBuffer1->asReadOnlyBuffer();
 
     // NullPointerException
@@ -971,7 +1082,7 @@ void CharArrayBufferTest::testReadOverfl
 ////////////////////////////////////////////////////////////////////////////////
 void CharArrayBufferTest::testReadSelf() {
 
-    CharBuffer* source = CharBuffer::wrap( testData1, 0, testData1Size );
+    CharBuffer* source = CharBuffer::wrap( testData1, testData1Size, 0, testData1Size );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "Should throw a IllegalArgumentException",

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/CharArrayBufferTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/CharArrayBufferTest.h?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/CharArrayBufferTest.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/CharArrayBufferTest.h Sat Mar 20 21:57:20 2010
@@ -72,61 +72,9 @@ namespace nio{
         decaf::nio::CharBuffer* testBuffer1;
         char* testData1;
 
-        static const std::size_t testData1Size = 100;
-        static const std::size_t SMALL_TEST_LENGTH = 5;
-        static const std::size_t BUFFER_LENGTH = 250;
-
-        class MyCharSequence : public lang::CharSequence {
-        private:
-
-            std::string value;
-
-        public:
-
-            MyCharSequence( std::string value ) {
-                this->value = value;
-            }
-
-            virtual ~MyCharSequence() {}
-
-            virtual std::size_t length() const {
-                return this->value.length();
-            }
-
-            virtual char charAt( std::size_t index ) const
-                throw( lang::exceptions::IndexOutOfBoundsException ) {
-
-                if( index > this->value.length() ) {
-                    throw decaf::lang::exceptions::IndexOutOfBoundsException(
-                        __FILE__, __LINE__,
-                        "MyCharSequence::charAt - index is to big: %d", index );
-                }
-
-                return this->value.at( index );
-            }
-
-            virtual CharSequence* subSequence( std::size_t start, std::size_t end ) const
-                throw( lang::exceptions::IndexOutOfBoundsException ) {
-
-                if( start > end ) {
-                    throw decaf::lang::exceptions::IndexOutOfBoundsException(
-                        __FILE__, __LINE__,
-                        "CharArrayBuffer::subSequence - start > end" );
-                }
-
-                if( start > this->length() || end > this->length() ) {
-                    throw decaf::lang::exceptions::IndexOutOfBoundsException(
-                        __FILE__, __LINE__,
-                        "CharArrayBuffer::subSequence - Sequence exceed limit" );
-                }
-
-                return new MyCharSequence( this->value.substr( start, end - start ) );
-            }
-
-            virtual std::string toString() const {
-                return this->value;
-            }
-        };
+        static const int testData1Size;
+        static const int SMALL_TEST_LENGTH;
+        static const int BUFFER_LENGTH;
 
     public:
 
@@ -137,7 +85,7 @@ namespace nio{
             testBuffer1 = decaf::nio::CharBuffer::allocate( testData1Size );
 
             testData1 = new char[testData1Size];
-            for( std::size_t i = 0; i < testData1Size; ++i ){
+            for( int i = 0; i < testData1Size; ++i ){
                 testData1[i] = (char)i;
             }
         }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/DoubleArrayBufferTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/DoubleArrayBufferTest.cpp?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/DoubleArrayBufferTest.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/DoubleArrayBufferTest.cpp Sat Mar 20 21:57:20 2010
@@ -28,6 +28,11 @@ using namespace decaf::lang;
 using namespace decaf::lang::exceptions;
 
 ////////////////////////////////////////////////////////////////////////////////
+const int DoubleArrayBufferTest::testData1Size = 100;
+const int DoubleArrayBufferTest::SMALL_TEST_LENGTH = 5;
+const int DoubleArrayBufferTest::BUFFER_LENGTH = 250;
+
+////////////////////////////////////////////////////////////////////////////////
 void DoubleArrayBufferTest::test() {
 
     // Check that we have setup the array and our initial assumptions on state
@@ -127,7 +132,7 @@ void DoubleArrayBufferTest::testAsReadOn
     CPPUNIT_ASSERT( testBuffer1->position() == readOnly->position() );
     CPPUNIT_ASSERT( testBuffer1->limit() == readOnly->limit() );
 
-    for( std::size_t i = 0; i < testBuffer1->capacity(); ++i ) {
+    for( int i = 0; i < testBuffer1->capacity(); ++i ) {
         CPPUNIT_ASSERT( testBuffer1->get( i ) == readOnly->get( i ) );
     }
 
@@ -296,7 +301,7 @@ void DoubleArrayBufferTest::testEquals()
 void DoubleArrayBufferTest::testGet() {
 
     testBuffer1->clear();
-    for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity(); i++ ) {
         CPPUNIT_ASSERT( testBuffer1->position() == i );
         CPPUNIT_ASSERT( testBuffer1->get() == testBuffer1->get(i) );
     }
@@ -313,7 +318,7 @@ void DoubleArrayBufferTest::testGetDoubl
     std::vector<double> array(1);
     testBuffer1->clear();
 
-    for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity(); i++ ) {
         CPPUNIT_ASSERT( testBuffer1->position() == i );
         DoubleBuffer& ret = testBuffer1->get( array );
         CPPUNIT_ASSERT( array[0] == testBuffer1->get(i) );
@@ -330,44 +335,81 @@ void DoubleArrayBufferTest::testGetDoubl
 void DoubleArrayBufferTest::testGetDoubleArray2() {
 
     testBuffer1->clear();
-    double* array = new double[testBuffer1->capacity()];
+    double* array1 = new double[testBuffer1->capacity()];
+    double* array2 = new double[testBuffer1->capacity() + 1];
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "Should throw BufferUnderflowException",
-        testBuffer1->get( array, 0, testBuffer1->capacity() + 1 ),
+        testBuffer1->get( array2, testBuffer1->capacity() + 1, 0, testBuffer1->capacity() + 1 ),
         BufferUnderflowException );
 
     CPPUNIT_ASSERT( testBuffer1->position() == 0 );
 
-    testBuffer1->get( array, 10, 0 );
+    testBuffer1->get( array1, testBuffer1->capacity(), 10, 0 );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
-        "Should throw BufferUnderflowException",
-        testBuffer1->get( array, 1, Integer::MAX_VALUE ),
-        BufferUnderflowException );
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->get( array1, testBuffer1->capacity(), -1, testBuffer1->capacity() ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->get( array1, testBuffer1->capacity(), testBuffer1->capacity() + 1, 1 ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->get( array1, testBuffer1->capacity(), 2, -1 ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->get( array1, testBuffer1->capacity(), 2, testBuffer1->capacity() ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->get( array1, testBuffer1->capacity(), 1, Integer::MAX_VALUE ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->get( array1, testBuffer1->capacity(), Integer::MAX_VALUE, 1 ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw NullPointerException",
+        testBuffer1->get( NULL, testBuffer1->capacity(), 1, Integer::MAX_VALUE ),
+        NullPointerException );
 
     CPPUNIT_ASSERT( testBuffer1->position() == 0 );
 
     testBuffer1->clear();
-    DoubleBuffer& ret = testBuffer1->get( array, 0, testBuffer1->capacity() );
+    DoubleBuffer& ret = testBuffer1->get( array1, testBuffer1->capacity(), 0, testBuffer1->capacity() );
     CPPUNIT_ASSERT( testBuffer1->position() == testBuffer1->capacity() );
-    assertContentEquals( testBuffer1, array, 0, testBuffer1->capacity() );
+    assertContentEquals( testBuffer1, array1, 0, testBuffer1->capacity() );
     CPPUNIT_ASSERT( &ret == testBuffer1 );
 
-    delete [] array;
+    delete [] array1;
+    delete [] array2;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void DoubleArrayBufferTest::testGet2() {
 
     testBuffer1->clear();
-    for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity(); i++ ) {
         CPPUNIT_ASSERT( testBuffer1->position() == i );
         CPPUNIT_ASSERT( testBuffer1->get() == testBuffer1->get(i) );
     }
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "Should throw IndexOutOfBoundsException",
+        testBuffer1->get( -1 ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
         testBuffer1->get( testBuffer1->limit() ),
         IndexOutOfBoundsException );
 }
@@ -382,7 +424,7 @@ void DoubleArrayBufferTest::testPutDoubl
 
     testBuffer1->clear();
 
-    for( std::size_t i = 0; i < testBuffer1->capacity(); i++) {
+    for( int i = 0; i < testBuffer1->capacity(); i++) {
         CPPUNIT_ASSERT( testBuffer1->position() == i );
         DoubleBuffer& ret = testBuffer1->put( (double)i );
         CPPUNIT_ASSERT( testBuffer1->get(i) == (double)i );
@@ -401,17 +443,17 @@ void DoubleArrayBufferTest::testPutDoubl
     double* array = new double[1];
 
     testBuffer1->clear();
-    for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity(); i++ ) {
         CPPUNIT_ASSERT( testBuffer1->position() == i );
         array[0] = (double) i;
-        DoubleBuffer& ret = testBuffer1->put( array, 0, 1 );
+        DoubleBuffer& ret = testBuffer1->put( array, 1, 0, 1 );
         CPPUNIT_ASSERT( testBuffer1->get(i) == (double)i );
         CPPUNIT_ASSERT( &ret == testBuffer1 );
     }
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "Should throw BufferOverflowException",
-        testBuffer1->put( array, 0, 1 ),
+        testBuffer1->put( array, 1, 0, 1 ),
         BufferOverflowException );
 
     delete [] array;
@@ -426,18 +468,53 @@ void DoubleArrayBufferTest::testPutDoubl
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "Should throw BufferOverflowException",
-        testBuffer1->put( array2, 0, testBuffer1->capacity() + 1 ),
+        testBuffer1->put( array2, testBuffer1->capacity() + 1, 0, testBuffer1->capacity() + 1 ),
         BufferOverflowException );
 
     CPPUNIT_ASSERT( testBuffer1->position() == 0 );
 
-    testBuffer1->put( array1, testBuffer1->capacity() + 1, 0 );
+    testBuffer1->put( array1, testBuffer1->capacity(), testBuffer1->capacity() + 1, 0 );
     CPPUNIT_ASSERT( testBuffer1->position() == 0 );
 
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->put( array1, testBuffer1->capacity(), -1, testBuffer1->capacity() ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->put( array1, testBuffer1->capacity(), testBuffer1->capacity() + 1, 1 ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->put( array1, testBuffer1->capacity(), 2, -1 ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->put( array1, testBuffer1->capacity(), 2, testBuffer1->capacity() ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->put( array1, testBuffer1->capacity(), 1, Integer::MAX_VALUE ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->put( array1, testBuffer1->capacity(), Integer::MAX_VALUE, 1 ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw NullPointerException",
+        testBuffer1->put( NULL, testBuffer1->capacity(), 1, Integer::MAX_VALUE ),
+        NullPointerException );
+
     CPPUNIT_ASSERT( testBuffer1->position() == 0 );
 
     loadTestData2( array1, 0, testBuffer1->capacity() );
-    DoubleBuffer& ret = testBuffer1->put( array1, 0, testBuffer1->capacity() );
+    DoubleBuffer& ret = testBuffer1->put( array1, testBuffer1->capacity(), 0, testBuffer1->capacity() );
     CPPUNIT_ASSERT( testBuffer1->position() == testBuffer1->capacity() );
     assertContentEquals( testBuffer1, array1, 0, testBuffer1->capacity() );
     CPPUNIT_ASSERT( &ret == testBuffer1 );
@@ -481,7 +558,7 @@ void DoubleArrayBufferTest::testGetWithI
 
     testBuffer1->clear();
 
-    for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity(); i++ ) {
         CPPUNIT_ASSERT( testBuffer1->position() == 0 );
         DoubleBuffer& ret = testBuffer1->put( i, (double)i );
         CPPUNIT_ASSERT( testBuffer1->get(i) == (double)i );
@@ -490,6 +567,11 @@ void DoubleArrayBufferTest::testGetWithI
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "Should throw IndexOutOfBoundsException",
+        testBuffer1->put( -1, 0 ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
         testBuffer1->put( testBuffer1->limit(), 0 ),
         IndexOutOfBoundsException );
 }
@@ -507,7 +589,7 @@ void DoubleArrayBufferTest::testPutIndex
 
     testBuffer1->clear();
 
-    for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity(); i++ ) {
         CPPUNIT_ASSERT( testBuffer1->position() == 0 );
         DoubleBuffer& ret = testBuffer1->put( i, (double)i );
         CPPUNIT_ASSERT( testBuffer1->get(i) == i );

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/DoubleArrayBufferTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/DoubleArrayBufferTest.h?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/DoubleArrayBufferTest.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/DoubleArrayBufferTest.h Sat Mar 20 21:57:20 2010
@@ -57,9 +57,9 @@ namespace nio{
         decaf::nio::DoubleBuffer* testBuffer1;
         double* testData1;
 
-        static const std::size_t testData1Size = 100;
-        static const std::size_t SMALL_TEST_LENGTH = 5;
-        static const std::size_t BUFFER_LENGTH = 250;
+        static const int testData1Size;
+        static const int SMALL_TEST_LENGTH;
+        static const int BUFFER_LENGTH;
 
     public:
 
@@ -70,7 +70,7 @@ namespace nio{
             testBuffer1 = decaf::nio::DoubleBuffer::allocate( testData1Size );
 
             testData1 = new double[testData1Size];
-            for( std::size_t i = 0; i < testData1Size; ++i ){
+            for( int i = 0; i < testData1Size; ++i ){
                 testData1[i] = (double)i;
             }
         }
@@ -105,36 +105,36 @@ namespace nio{
 
     protected:
 
-        void loadTestData1( double* array, std::size_t offset, std::size_t length ) {
-            for( std::size_t i = 0; i < length; i++ ) {
+        void loadTestData1( double* array, int offset, int length ) {
+            for( int i = 0; i < length; i++ ) {
                 array[offset + i] = (double)i;
             }
         }
 
-        void loadTestData2( double* array, std::size_t offset, std::size_t length ) {
-            for( std::size_t i = 0; i < length; i++ ) {
+        void loadTestData2( double* array, int offset, int length ) {
+            for( int i = 0; i < length; i++ ) {
                 array[offset + i] = (double)length - i;
             }
         }
 
         void loadTestData1( decaf::nio::DoubleBuffer* buf ) {
             buf->clear();
-            for( std::size_t i = 0; i < buf->capacity(); i++ ) {
+            for( int i = 0; i < buf->capacity(); i++ ) {
                 buf->put( i, (double)i );
             }
         }
 
         void loadTestData2( decaf::nio::DoubleBuffer* buf ) {
             buf->clear();
-            for( std::size_t i = 0; i < buf->capacity(); i++ ) {
+            for( int i = 0; i < buf->capacity(); i++ ) {
                 buf->put(i, (double) buf->capacity() - i);
             }
         }
 
         void assertContentEquals( decaf::nio::DoubleBuffer* buf, double* array,
-                                  std::size_t offset, std::size_t length) {
+                                  int offset, int length) {
 
-            for( std::size_t i = 0; i < length; i++ ) {
+            for( int i = 0; i < length; i++ ) {
                 CPPUNIT_ASSERT( buf->get(i) == array[offset + i] );
             }
         }
@@ -142,17 +142,17 @@ namespace nio{
         void assertContentEquals( decaf::nio::DoubleBuffer* buf,
                                   decaf::nio::DoubleBuffer* other ) {
             CPPUNIT_ASSERT( buf->capacity() == other->capacity() );
-            for( std::size_t i = 0; i < buf->capacity(); i++ ) {
+            for( int i = 0; i < buf->capacity(); i++ ) {
                 CPPUNIT_ASSERT(buf->get(i) == other->get(i) );
             }
         }
 
         void assertContentLikeTestData1(
-            decaf::nio::DoubleBuffer* buf, std::size_t startIndex,
-            double startValue, std::size_t length ) {
+            decaf::nio::DoubleBuffer* buf, int startIndex,
+            double startValue, int length ) {
 
             double value = startValue;
-            for( std::size_t i = 0; i < length; i++ ) {
+            for( int i = 0; i < length; i++ ) {
                 CPPUNIT_ASSERT( buf->get( startIndex + i ) == value );
                 value = value + 1.0;
             }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/FloatArrayBufferTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/FloatArrayBufferTest.cpp?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/FloatArrayBufferTest.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/FloatArrayBufferTest.cpp Sat Mar 20 21:57:20 2010
@@ -28,6 +28,11 @@ using namespace decaf::lang;
 using namespace decaf::lang::exceptions;
 
 ////////////////////////////////////////////////////////////////////////////////
+const int FloatArrayBufferTest::testData1Size = 100;
+const int FloatArrayBufferTest::SMALL_TEST_LENGTH = 5;
+const int FloatArrayBufferTest::BUFFER_LENGTH = 250;
+
+////////////////////////////////////////////////////////////////////////////////
 void FloatArrayBufferTest::test() {
 
     // Check that we have setup the array and our initial assumptions on state
@@ -127,7 +132,7 @@ void FloatArrayBufferTest::testAsReadOnl
     CPPUNIT_ASSERT( testBuffer1->position() == readOnly->position() );
     CPPUNIT_ASSERT( testBuffer1->limit() == readOnly->limit() );
 
-    for( std::size_t i = 0; i < testBuffer1->capacity(); ++i ) {
+    for( int i = 0; i < testBuffer1->capacity(); ++i ) {
         CPPUNIT_ASSERT( testBuffer1->get( i ) == readOnly->get( i ) );
     }
 
@@ -296,7 +301,7 @@ void FloatArrayBufferTest::testEquals() 
 void FloatArrayBufferTest::testGet() {
 
     testBuffer1->clear();
-    for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity(); i++ ) {
         CPPUNIT_ASSERT( testBuffer1->position() == i );
         CPPUNIT_ASSERT( testBuffer1->get() == testBuffer1->get(i) );
     }
@@ -313,7 +318,7 @@ void FloatArrayBufferTest::testGetFloatA
     std::vector<float> array(1);
     testBuffer1->clear();
 
-    for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity(); i++ ) {
         CPPUNIT_ASSERT( testBuffer1->position() == i );
         FloatBuffer& ret = testBuffer1->get( array );
         CPPUNIT_ASSERT( array[0] == testBuffer1->get(i) );
@@ -330,44 +335,81 @@ void FloatArrayBufferTest::testGetFloatA
 void FloatArrayBufferTest::testGetFloatArray2() {
 
     testBuffer1->clear();
-    float* array = new float[testBuffer1->capacity()];
+    float* array1 = new float[testBuffer1->capacity()];
+    float* array2 = new float[testBuffer1->capacity() + 1];
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "Should throw BufferUnderflowException",
-        testBuffer1->get( array, 0, testBuffer1->capacity() + 1 ),
+        testBuffer1->get( array2, testBuffer1->capacity() + 1, 0, testBuffer1->capacity() + 1 ),
         BufferUnderflowException );
 
     CPPUNIT_ASSERT( testBuffer1->position() == 0 );
 
-    testBuffer1->get( array, 10, 0 );
+    testBuffer1->get( array1, testBuffer1->capacity(), 10, 0 );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
-        "Should throw BufferUnderflowException",
-        testBuffer1->get( array, 1, Integer::MAX_VALUE ),
-        BufferUnderflowException );
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->get( array1, testBuffer1->capacity(), -1, testBuffer1->capacity() ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->get( array1, testBuffer1->capacity(), testBuffer1->capacity() + 1, 1 ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->get( array1, testBuffer1->capacity(), 2, -1 ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->get( array1, testBuffer1->capacity(), 2, testBuffer1->capacity() ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->get( array1, testBuffer1->capacity(), 1, Integer::MAX_VALUE ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->get( array1, testBuffer1->capacity(), Integer::MAX_VALUE, 1 ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw NullPointerException",
+        testBuffer1->get( NULL, testBuffer1->capacity(), 1, Integer::MAX_VALUE ),
+        NullPointerException );
 
     CPPUNIT_ASSERT( testBuffer1->position() == 0 );
 
     testBuffer1->clear();
-    FloatBuffer& ret = testBuffer1->get( array, 0, testBuffer1->capacity() );
+    FloatBuffer& ret = testBuffer1->get( array1, testBuffer1->capacity(), 0, testBuffer1->capacity() );
     CPPUNIT_ASSERT( testBuffer1->position() == testBuffer1->capacity() );
-    assertContentEquals( testBuffer1, array, 0, testBuffer1->capacity() );
+    assertContentEquals( testBuffer1, array1, 0, testBuffer1->capacity() );
     CPPUNIT_ASSERT( &ret == testBuffer1 );
 
-    delete [] array;
+    delete [] array1;
+    delete [] array2;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void FloatArrayBufferTest::testGet2() {
 
     testBuffer1->clear();
-    for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity(); i++ ) {
         CPPUNIT_ASSERT( testBuffer1->position() == i );
         CPPUNIT_ASSERT( testBuffer1->get() == testBuffer1->get(i) );
     }
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "Should throw IndexOutOfBoundsException",
+        testBuffer1->get( -1 ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
         testBuffer1->get( testBuffer1->limit() ),
         IndexOutOfBoundsException );
 }
@@ -382,7 +424,7 @@ void FloatArrayBufferTest::testPutFloat(
 
     testBuffer1->clear();
 
-    for( std::size_t i = 0; i < testBuffer1->capacity(); i++) {
+    for( int i = 0; i < testBuffer1->capacity(); i++) {
         CPPUNIT_ASSERT( testBuffer1->position() == i );
         FloatBuffer& ret = testBuffer1->put( (float)i );
         CPPUNIT_ASSERT( testBuffer1->get(i) == (float)i );
@@ -401,17 +443,17 @@ void FloatArrayBufferTest::testPutFloatA
     float* array = new float[1];
 
     testBuffer1->clear();
-    for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity(); i++ ) {
         CPPUNIT_ASSERT( testBuffer1->position() == i );
         array[0] = (float) i;
-        FloatBuffer& ret = testBuffer1->put( array, 0, 1 );
+        FloatBuffer& ret = testBuffer1->put( array, 1, 0, 1 );
         CPPUNIT_ASSERT( testBuffer1->get(i) == (float)i );
         CPPUNIT_ASSERT( &ret == testBuffer1 );
     }
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "Should throw BufferOverflowException",
-        testBuffer1->put( array, 0, 1 ),
+        testBuffer1->put( array, 1, 0, 1 ),
         BufferOverflowException );
 
     delete [] array;
@@ -426,18 +468,53 @@ void FloatArrayBufferTest::testPutFloatA
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "Should throw BufferOverflowException",
-        testBuffer1->put( array2, 0, testBuffer1->capacity() + 1 ),
+        testBuffer1->put( array2, testBuffer1->capacity() + 1, 0, testBuffer1->capacity() + 1 ),
         BufferOverflowException );
 
     CPPUNIT_ASSERT( testBuffer1->position() == 0 );
 
-    testBuffer1->put( array1, testBuffer1->capacity() + 1, 0 );
+    testBuffer1->put( array1, testBuffer1->capacity(), testBuffer1->capacity() + 1, 0 );
     CPPUNIT_ASSERT( testBuffer1->position() == 0 );
 
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->put( array1, testBuffer1->capacity(), -1, testBuffer1->capacity() ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->put( array1, testBuffer1->capacity(), testBuffer1->capacity() + 1, 1 ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->put( array1, testBuffer1->capacity(), 2, -1 ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->put( array1, testBuffer1->capacity(), 2, testBuffer1->capacity() ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->put( array1, testBuffer1->capacity(), 1, Integer::MAX_VALUE ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
+        testBuffer1->put( array1, testBuffer1->capacity(), Integer::MAX_VALUE, 1 ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw NullPointerException",
+        testBuffer1->put( NULL, testBuffer1->capacity(), 1, Integer::MAX_VALUE ),
+        NullPointerException );
+
     CPPUNIT_ASSERT( testBuffer1->position() == 0 );
 
     loadTestData2( array1, 0, testBuffer1->capacity() );
-    FloatBuffer& ret = testBuffer1->put( array1, 0, testBuffer1->capacity() );
+    FloatBuffer& ret = testBuffer1->put( array1, testBuffer1->capacity(), 0, testBuffer1->capacity() );
     CPPUNIT_ASSERT( testBuffer1->position() == testBuffer1->capacity() );
     assertContentEquals( testBuffer1, array1, 0, testBuffer1->capacity() );
     CPPUNIT_ASSERT( &ret == testBuffer1 );
@@ -481,7 +558,7 @@ void FloatArrayBufferTest::testGetWithIn
 
     testBuffer1->clear();
 
-    for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity(); i++ ) {
         CPPUNIT_ASSERT( testBuffer1->position() == 0 );
         FloatBuffer& ret = testBuffer1->put( i, (float)i );
         CPPUNIT_ASSERT( testBuffer1->get(i) == (float)i );
@@ -490,6 +567,11 @@ void FloatArrayBufferTest::testGetWithIn
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "Should throw IndexOutOfBoundsException",
+        testBuffer1->put( -1, 0 ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw IndexOutOfBoundsException",
         testBuffer1->put( testBuffer1->limit(), 0 ),
         IndexOutOfBoundsException );
 }
@@ -507,7 +589,7 @@ void FloatArrayBufferTest::testPutIndexe
 
     testBuffer1->clear();
 
-    for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+    for( int i = 0; i < testBuffer1->capacity(); i++ ) {
         CPPUNIT_ASSERT( testBuffer1->position() == 0 );
         FloatBuffer& ret = testBuffer1->put(i, (float)i );
         CPPUNIT_ASSERT( testBuffer1->get(i) == i );
@@ -516,6 +598,11 @@ void FloatArrayBufferTest::testPutIndexe
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "Should throw a IndexOutOfBoundsException",
+        testBuffer1->put( -1, 0 ),
+        IndexOutOfBoundsException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw a IndexOutOfBoundsException",
         testBuffer1->put( testBuffer1->limit(), 0 ),
         IndexOutOfBoundsException );
 }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/FloatArrayBufferTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/FloatArrayBufferTest.h?rev=925692&r1=925691&r2=925692&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/FloatArrayBufferTest.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/internal/nio/FloatArrayBufferTest.h Sat Mar 20 21:57:20 2010
@@ -57,9 +57,9 @@ namespace nio{
         decaf::nio::FloatBuffer* testBuffer1;
         float* testData1;
 
-        static const std::size_t testData1Size = 100;
-        static const std::size_t SMALL_TEST_LENGTH = 5;
-        static const std::size_t BUFFER_LENGTH = 250;
+        static const int testData1Size;
+        static const int SMALL_TEST_LENGTH;
+        static const int BUFFER_LENGTH;
 
     public:
 
@@ -70,7 +70,7 @@ namespace nio{
             testBuffer1 = decaf::nio::FloatBuffer::allocate( testData1Size );
 
             testData1 = new float[testData1Size];
-            for( std::size_t i = 0; i < testData1Size; ++i ){
+            for( int i = 0; i < testData1Size; ++i ){
                 testData1[i] = (float)i;
             }
         }
@@ -105,36 +105,36 @@ namespace nio{
 
     protected:
 
-        void loadTestData1( float* array, std::size_t offset, std::size_t length ) {
-            for( std::size_t i = 0; i < length; i++ ) {
+        void loadTestData1( float* array, int offset, int length ) {
+            for( int i = 0; i < length; i++ ) {
                 array[offset + i] = (float)i;
             }
         }
 
-        void loadTestData2( float* array, std::size_t offset, std::size_t length ) {
-            for( std::size_t i = 0; i < length; i++ ) {
+        void loadTestData2( float* array, int offset, int length ) {
+            for( int i = 0; i < length; i++ ) {
                 array[offset + i] = (float)length - i;
             }
         }
 
         void loadTestData1( decaf::nio::FloatBuffer* buf ) {
             buf->clear();
-            for( std::size_t i = 0; i < buf->capacity(); i++ ) {
+            for( int i = 0; i < buf->capacity(); i++ ) {
                 buf->put( i, (float)i );
             }
         }
 
         void loadTestData2( decaf::nio::FloatBuffer* buf ) {
             buf->clear();
-            for( std::size_t i = 0; i < buf->capacity(); i++ ) {
+            for( int i = 0; i < buf->capacity(); i++ ) {
                 buf->put(i, (float) buf->capacity() - i);
             }
         }
 
         void assertContentEquals( decaf::nio::FloatBuffer* buf, float* array,
-                                  std::size_t offset, std::size_t length) {
+                                  int offset, int length) {
 
-            for( std::size_t i = 0; i < length; i++ ) {
+            for( int i = 0; i < length; i++ ) {
                 CPPUNIT_ASSERT( buf->get(i) == array[offset + i] );
             }
         }
@@ -142,17 +142,17 @@ namespace nio{
         void assertContentEquals( decaf::nio::FloatBuffer* buf,
                                   decaf::nio::FloatBuffer* other ) {
             CPPUNIT_ASSERT( buf->capacity() == other->capacity() );
-            for( std::size_t i = 0; i < buf->capacity(); i++ ) {
+            for( int i = 0; i < buf->capacity(); i++ ) {
                 CPPUNIT_ASSERT(buf->get(i) == other->get(i) );
             }
         }
 
         void assertContentLikeTestData1(
-            decaf::nio::FloatBuffer* buf, std::size_t startIndex,
-            float startValue, std::size_t length ) {
+            decaf::nio::FloatBuffer* buf, int startIndex,
+            float startValue, int length ) {
 
             float value = startValue;
-            for( std::size_t i = 0; i < length; i++ ) {
+            for( int i = 0; i < length; i++ ) {
                 CPPUNIT_ASSERT( buf->get( startIndex + i ) == value );
                 value = value + 1.0f;
             }