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 2007/12/12 13:52:15 UTC
svn commit: r603604 - in /activemq/activemq-cpp/decaf/trunk/src/test: ./
decaf/internal/nio/
Author: tabish
Date: Wed Dec 12 04:52:13 2007
New Revision: 603604
URL: http://svn.apache.org/viewvc?rev=603604&view=rev
Log:
http://issues.apache.org/activemq/browse/AMQCPP-153
Working on implementing the NIO package
Added:
activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/IntArrayBufferTest.cpp
activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/IntArrayBufferTest.h
activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/LongArrayBufferTest.cpp
activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/LongArrayBufferTest.h
activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/ShortArrayBufferTest.cpp
activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/ShortArrayBufferTest.h
Modified:
activemq/activemq-cpp/decaf/trunk/src/test/Makefile.am
activemq/activemq-cpp/decaf/trunk/src/test/testRegistry.cpp
Modified: activemq/activemq-cpp/decaf/trunk/src/test/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/test/Makefile.am?rev=603604&r1=603603&r2=603604&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/test/Makefile.am (original)
+++ activemq/activemq-cpp/decaf/trunk/src/test/Makefile.am Wed Dec 12 04:52:13 2007
@@ -23,6 +23,9 @@
decaf/internal/nio/CharArrayBufferTest.cpp \
decaf/internal/nio/DoubleArrayBufferTest.cpp \
decaf/internal/nio/FloatArrayBufferTest.cpp \
+ decaf/internal/nio/LongArrayBufferTest.cpp \
+ decaf/internal/nio/IntArrayBufferTest.cpp \
+ decaf/internal/nio/ShortArrayBufferTest.cpp \
decaf/lang/ByteTest.cpp \
decaf/lang/CharacterTest.cpp \
decaf/lang/BooleanTest.cpp \
@@ -70,6 +73,9 @@
decaf/internal/nio/CharArrayBufferTest.h \
decaf/internal/nio/DoubleArrayBufferTest.h \
decaf/internal/nio/FloatArrayBufferTest.h \
+ decaf/internal/nio/LongArrayBufferTest.h \
+ decaf/internal/nio/IntArrayBufferTest.h \
+ decaf/internal/nio/ShortArrayBufferTest.h \
decaf/lang/ByteTest.h \
decaf/lang/CharacterTest.h \
decaf/lang/BooleanTest.h \
Added: activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/IntArrayBufferTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/IntArrayBufferTest.cpp?rev=603604&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/IntArrayBufferTest.cpp (added)
+++ activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/IntArrayBufferTest.cpp Wed Dec 12 04:52:13 2007
@@ -0,0 +1,556 @@
+/*
+ * 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 "IntArrayBufferTest.h"
+#include <decaf/lang/Integer.h>
+#include <decaf/lang/Double.h>
+#include <decaf/lang/Float.h>
+
+using namespace std;
+using namespace decaf;
+using namespace decaf::nio;
+using namespace decaf::internal::nio;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+void IntArrayBufferTest::test() {
+
+ // Check that we have setup the array and our initial assumptions on state
+ // are correct. This is the first test run.
+ CPPUNIT_ASSERT( testBuffer1 != NULL );
+ CPPUNIT_ASSERT( testBuffer1->capacity() == testData1Size );
+ CPPUNIT_ASSERT( testBuffer1->hasRemaining() == true );
+ CPPUNIT_ASSERT( testBuffer1->limit() == testBuffer1->capacity() );
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+ CPPUNIT_ASSERT( testBuffer1->isReadOnly() == false );
+ CPPUNIT_ASSERT( testBuffer1->toString() != "" );
+ CPPUNIT_ASSERT( testBuffer1->hasArray() == true );
+ CPPUNIT_ASSERT( testBuffer1->array() != NULL );
+ CPPUNIT_ASSERT( testBuffer1->arrayOffset() == 0 );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void IntArrayBufferTest::testArray() {
+
+ int* array = testBuffer1->array();
+
+ testBuffer1->put( 0, 10 );
+ CPPUNIT_ASSERT( array[0] == 10.0 );
+
+ assertContentEquals(
+ testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity() );
+
+ loadTestData1( array, testBuffer1->arrayOffset(), testBuffer1->capacity() );
+ assertContentEquals(
+ testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity()) ;
+
+ loadTestData2( array, testBuffer1->arrayOffset(), testBuffer1->capacity());
+ assertContentEquals(
+ testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity() );
+
+ loadTestData1( testBuffer1 );
+ assertContentEquals(
+ testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity() );
+
+ loadTestData2( testBuffer1 );
+ assertContentEquals(
+ testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity() );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void IntArrayBufferTest::testArrayOffset() {
+
+ int* array = testBuffer1->array();
+
+ assertContentEquals(testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity());
+
+ loadTestData1(array, testBuffer1->arrayOffset(), testBuffer1->capacity());
+ assertContentEquals(testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity());
+
+ loadTestData2(array, testBuffer1->arrayOffset(), testBuffer1->capacity());
+ assertContentEquals(testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity());
+
+ loadTestData1(testBuffer1);
+ assertContentEquals(testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity());
+
+ loadTestData2(testBuffer1);
+ assertContentEquals(testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity());
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void IntArrayBufferTest::testReadOnlyArray() {
+
+ IntBuffer* readOnly = testBuffer1->asReadOnlyBuffer();
+
+ CPPUNIT_ASSERT( readOnly != NULL );
+ CPPUNIT_ASSERT( readOnly->isReadOnly() == true );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw UnsupportedOperationException",
+ readOnly->array(),
+ UnsupportedOperationException );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw UnsupportedOperationException",
+ readOnly->arrayOffset(),
+ UnsupportedOperationException );
+
+ delete readOnly;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void IntArrayBufferTest::testAsReadOnlyBuffer() {
+
+ testBuffer1->clear();
+ testBuffer1->mark();
+ testBuffer1->position( testBuffer1->limit() );
+
+ // readonly's contents should be the same as testBuffer1
+ IntBuffer* readOnly = testBuffer1->asReadOnlyBuffer();
+ CPPUNIT_ASSERT( testBuffer1 != readOnly );
+ CPPUNIT_ASSERT( readOnly->isReadOnly() );
+ CPPUNIT_ASSERT( testBuffer1->position() == readOnly->position() );
+ CPPUNIT_ASSERT( testBuffer1->limit() == readOnly->limit() );
+
+ for( std::size_t i = 0; i < testBuffer1->capacity(); ++i ) {
+ CPPUNIT_ASSERT( testBuffer1->get( i ) == readOnly->get( i ) );
+ }
+
+ // readOnly's position, mark, and limit should be independent to testBuffer1
+ readOnly->reset();
+ CPPUNIT_ASSERT( readOnly->position() == 0 );
+ readOnly->clear();
+ CPPUNIT_ASSERT( testBuffer1->position() == testBuffer1->limit() );
+ testBuffer1->reset();
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+
+ delete readOnly;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void IntArrayBufferTest::testCompact() {
+
+ loadTestData1( testBuffer1 );
+
+ // case: buffer is full
+ testBuffer1->clear();
+ testBuffer1->mark();
+
+ IntBuffer& ret = testBuffer1->compact();
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+ CPPUNIT_ASSERT( testBuffer1->position() == testBuffer1->capacity() );
+ CPPUNIT_ASSERT( testBuffer1->limit() == testBuffer1->capacity() );
+
+ assertContentLikeTestData1( testBuffer1, 0, 0, testBuffer1->capacity() );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw InvalidMarkException",
+ testBuffer1->reset(),
+ InvalidMarkException );
+
+ // case: buffer is empty
+ testBuffer1->position(0);
+ testBuffer1->limit(0);
+ testBuffer1->mark();
+ ret = testBuffer1->compact();
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+ CPPUNIT_ASSERT( testBuffer1->limit() == testBuffer1->capacity() );
+
+ assertContentLikeTestData1(testBuffer1, 0, 0, testBuffer1->capacity());
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw InvalidMarkException",
+ testBuffer1->reset(),
+ InvalidMarkException );
+
+ // case: normal
+ CPPUNIT_ASSERT( testBuffer1->capacity() > 5 );
+
+ testBuffer1->position(1);
+ testBuffer1->limit(5);
+ testBuffer1->mark();
+ ret = testBuffer1->compact();
+ CPPUNIT_ASSERT( &ret == testBuffer1);
+ CPPUNIT_ASSERT( testBuffer1->position() == 4 );
+ CPPUNIT_ASSERT( testBuffer1->limit() == testBuffer1->capacity() );
+
+ assertContentLikeTestData1(testBuffer1, 0, 1, 4);
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw InvalidMarkException",
+ testBuffer1->reset(),
+ InvalidMarkException );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void IntArrayBufferTest::testCompareTo() {
+
+ IntBuffer* other = IntBuffer::allocate( testBuffer1->capacity() );
+
+ loadTestData1(testBuffer1);
+ loadTestData1(other);
+
+ CPPUNIT_ASSERT( 0 == testBuffer1->compareTo( *other ) );
+ CPPUNIT_ASSERT( 0 == other->compareTo( *testBuffer1 ) );
+ testBuffer1->position(1);
+ CPPUNIT_ASSERT( testBuffer1->compareTo( *other ) > 0 );
+ CPPUNIT_ASSERT( other->compareTo( *testBuffer1 ) < 0 );
+ other->position( 2 );
+ CPPUNIT_ASSERT( testBuffer1->compareTo( *other ) < 0 );
+ CPPUNIT_ASSERT( other->compareTo( *testBuffer1 ) > 0 );
+ testBuffer1->position(2);
+ other->limit(5);
+ CPPUNIT_ASSERT( testBuffer1->compareTo( *other ) > 0 );
+ CPPUNIT_ASSERT( other->compareTo( *testBuffer1 ) < 0 );
+
+ std::vector<int> array1( 1, 545645 );
+ std::vector<int> array2( 1, 545645 );
+ std::vector<int> array3( 1, 42 );
+
+ IntBuffer* dbuffer1 = IntBuffer::wrap( array1 );
+ IntBuffer* dbuffer2 = IntBuffer::wrap( array2 );
+ IntBuffer* dbuffer3 = IntBuffer::wrap( array3 );
+
+ CPPUNIT_ASSERT_MESSAGE(
+ "Failed equal comparison with NaN entry",
+ dbuffer1->compareTo( *dbuffer2 ) == 0 );
+ CPPUNIT_ASSERT_MESSAGE(
+ "Failed greater than comparison with NaN entry",
+ dbuffer3->compareTo( *dbuffer1 ) );
+ CPPUNIT_ASSERT_MESSAGE(
+ "Failed greater than comparison with NaN entry",
+ dbuffer1->compareTo( *dbuffer3 ) );
+
+ delete other;
+ delete dbuffer1;
+ delete dbuffer2;
+ delete dbuffer3;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void IntArrayBufferTest::testDuplicate() {
+ testBuffer1->clear();
+ testBuffer1->mark();
+ testBuffer1->position(testBuffer1->limit());
+
+ // duplicate's contents should be the same as testBuffer1
+ IntBuffer* 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() );
+ assertContentEquals( testBuffer1, duplicate );
+
+ // duplicate's position, mark, and limit should be independent to testBuffer1
+ 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 IntArrayBufferTest::testEquals() {
+
+ // equal to self
+ CPPUNIT_ASSERT( testBuffer1->equals( *testBuffer1 ) );
+ IntBuffer* readOnly = testBuffer1->asReadOnlyBuffer();
+ CPPUNIT_ASSERT( testBuffer1->equals( *readOnly ) );
+ IntBuffer* duplicate = testBuffer1->duplicate();
+ CPPUNIT_ASSERT( testBuffer1->equals( *duplicate ) );
+
+ CPPUNIT_ASSERT( testBuffer1->capacity() > 5 );
+
+ 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;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void IntArrayBufferTest::testGet() {
+
+ testBuffer1->clear();
+ for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+ CPPUNIT_ASSERT( testBuffer1->position() == i );
+ CPPUNIT_ASSERT( testBuffer1->get() == testBuffer1->get(i) );
+ }
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw BufferUnderflowException",
+ testBuffer1->get(),
+ BufferUnderflowException );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void IntArrayBufferTest::testGetIntArray() {
+
+ std::vector<int> array(1);
+ testBuffer1->clear();
+
+ for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+ CPPUNIT_ASSERT( testBuffer1->position() == i );
+ IntBuffer& ret = testBuffer1->get( array );
+ CPPUNIT_ASSERT( array[0] == testBuffer1->get(i) );
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+ }
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw BufferUnderflowException",
+ testBuffer1->get( array ),
+ BufferUnderflowException );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void IntArrayBufferTest::testGetIntArray2() {
+
+ testBuffer1->clear();
+ int* array = new int[testBuffer1->capacity()];
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw BufferUnderflowException",
+ testBuffer1->get( array, 0, testBuffer1->capacity() + 1 ),
+ BufferUnderflowException );
+
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+
+ testBuffer1->get( array, 10, 0 );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw BufferUnderflowException",
+ testBuffer1->get( array, 1, Integer::MAX_VALUE ),
+ BufferUnderflowException );
+
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+
+ testBuffer1->clear();
+ IntBuffer& ret = testBuffer1->get( array, 0, testBuffer1->capacity() );
+ CPPUNIT_ASSERT( testBuffer1->position() == testBuffer1->capacity() );
+ assertContentEquals( testBuffer1, array, 0, testBuffer1->capacity() );
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+
+ delete array;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void IntArrayBufferTest::testGet2() {
+
+ testBuffer1->clear();
+ for( std::size_t 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( testBuffer1->limit() ),
+ IndexOutOfBoundsException );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void IntArrayBufferTest::testHasArray() {
+ CPPUNIT_ASSERT( testBuffer1->hasArray() );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void IntArrayBufferTest::testPutInt() {
+
+ testBuffer1->clear();
+
+ for( std::size_t i = 0; i < testBuffer1->capacity(); i++) {
+ CPPUNIT_ASSERT( testBuffer1->position() == i );
+ IntBuffer& ret = testBuffer1->put( (int)i );
+ CPPUNIT_ASSERT( testBuffer1->get(i) == (int)i );
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+ }
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw BufferOverflowException",
+ testBuffer1->put( 0 ),
+ BufferOverflowException );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void IntArrayBufferTest::testPutIntArray() {
+
+ int* array = new int[1];
+
+ testBuffer1->clear();
+ for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+ CPPUNIT_ASSERT( testBuffer1->position() == i );
+ array[0] = (int) i;
+ IntBuffer& ret = testBuffer1->put( array, 0, 1 );
+ CPPUNIT_ASSERT( testBuffer1->get(i) == (int)i );
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+ }
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw BufferOverflowException",
+ testBuffer1->put( array, 0, 1 ),
+ BufferOverflowException );
+
+ delete array;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void IntArrayBufferTest::testPutIntArray2() {
+
+ testBuffer1->clear();
+ int* array1 = new int[ testBuffer1->capacity() ];
+ int* array2 = new int[ testBuffer1->capacity() + 1 ];
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw BufferOverflowException",
+ testBuffer1->put( array2, 0, testBuffer1->capacity() + 1 ),
+ BufferOverflowException );
+
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+
+ testBuffer1->put( array1, testBuffer1->capacity() + 1, 0 );
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+
+ loadTestData2( array1, 0, testBuffer1->capacity() );
+ IntBuffer& ret = testBuffer1->put( array1, 0, testBuffer1->capacity() );
+ CPPUNIT_ASSERT( testBuffer1->position() == testBuffer1->capacity() );
+ assertContentEquals( testBuffer1, array1, 0, testBuffer1->capacity() );
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void IntArrayBufferTest::testPutIntBuffer() {
+
+ IntBuffer* other = IntBuffer::allocate( testBuffer1->capacity() );
+ IntBuffer* other1 = IntBuffer::allocate( testBuffer1->capacity() + 1 );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw IllegalArgumentException",
+ testBuffer1->put( *testBuffer1 ),
+ IllegalArgumentException );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw BufferOverflowException",
+ testBuffer1->put( *other1 ),
+ BufferOverflowException );
+
+ loadTestData2(other);
+ other->clear();
+ testBuffer1->clear();
+ IntBuffer& ret = testBuffer1->put( *other );
+
+ CPPUNIT_ASSERT( other->position() == other->capacity() );
+ CPPUNIT_ASSERT( testBuffer1->position() == testBuffer1->capacity() );
+ assertContentEquals( other, testBuffer1 );
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+
+ delete other;
+ delete other1;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void IntArrayBufferTest::testGetWithIndex() {
+
+ testBuffer1->clear();
+
+ for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+ IntBuffer& ret = testBuffer1->put( i, (int)i );
+ CPPUNIT_ASSERT( testBuffer1->get(i) == (int)i );
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+ }
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw IndexOutOfBoundsException",
+ testBuffer1->put( testBuffer1->limit(), 0 ),
+ IndexOutOfBoundsException );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void IntArrayBufferTest::testPutIndexed() {
+
+ IntBuffer* readOnly = testBuffer1->asReadOnlyBuffer();
+ readOnly->clear();
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw a ReadOnlyBufferException",
+ readOnly->put( 0, 0 ),
+ ReadOnlyBufferException );
+ delete readOnly;
+
+ testBuffer1->clear();
+
+ for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+ IntBuffer& ret = testBuffer1->put(i, i );
+ CPPUNIT_ASSERT( testBuffer1->get(i) == (int)i );
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+ }
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw a IndexOutOfBoundsException",
+ testBuffer1->put( testBuffer1->limit(), 0 ),
+ IndexOutOfBoundsException );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void IntArrayBufferTest::testSlice() {
+
+ CPPUNIT_ASSERT( testBuffer1->capacity() > 5 );
+ testBuffer1->position(1);
+ testBuffer1->limit(testBuffer1->capacity() - 1);
+
+ IntBuffer* slice = testBuffer1->slice();
+ CPPUNIT_ASSERT( testBuffer1->isReadOnly() == slice->isReadOnly() );
+ CPPUNIT_ASSERT( slice->position() == 0 );
+ CPPUNIT_ASSERT( slice->limit() == testBuffer1->remaining() );
+ CPPUNIT_ASSERT( slice->capacity() == testBuffer1->remaining() );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw InvalidMarkException",
+ slice->reset(),
+ InvalidMarkException );
+
+ // slice share the same content with testBuffer1
+ // FIXME:
+ loadTestData1(slice);
+ assertContentLikeTestData1(testBuffer1, 1, 0, slice->capacity());
+ testBuffer1->put( 2, 500 );
+ CPPUNIT_ASSERT( slice->get(1) == 500 );
+
+ delete slice;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void IntArrayBufferTest::testToString() {
+
+ std::string str = testBuffer1->toString();
+ CPPUNIT_ASSERT( str.find("Int") != string::npos );
+ CPPUNIT_ASSERT( str.find( Integer::toString( testBuffer1->position() ) ) != string::npos );
+ CPPUNIT_ASSERT( str.find( Integer::toString( testBuffer1->limit() ) ) != string::npos );
+ CPPUNIT_ASSERT( str.find( Integer::toString( testBuffer1->capacity() ) ) != string::npos );
+}
Added: activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/IntArrayBufferTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/IntArrayBufferTest.h?rev=603604&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/IntArrayBufferTest.h (added)
+++ activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/IntArrayBufferTest.h Wed Dec 12 04:52:13 2007
@@ -0,0 +1,165 @@
+/*
+ * 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_INTERNAL_NIO_INTARRAYBUFFERTEST_H_
+#define _DECAF_INTERNAL_NIO_INTARRAYBUFFERTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <decaf/nio/IntBuffer.h>
+
+namespace decaf{
+namespace internal{
+namespace nio{
+
+ class IntArrayBufferTest : public CppUnit::TestFixture {
+
+ CPPUNIT_TEST_SUITE( IntArrayBufferTest );
+ CPPUNIT_TEST( test );
+ CPPUNIT_TEST( testArray );
+ CPPUNIT_TEST( testArrayOffset );
+ CPPUNIT_TEST( testReadOnlyArray );
+ CPPUNIT_TEST( testAsReadOnlyBuffer );
+ CPPUNIT_TEST( testCompact );
+ CPPUNIT_TEST( testCompareTo );
+ CPPUNIT_TEST( testDuplicate );
+ CPPUNIT_TEST( testEquals );
+ CPPUNIT_TEST( testHasArray );
+ CPPUNIT_TEST( testGet );
+ CPPUNIT_TEST( testGet2 );
+ CPPUNIT_TEST( testGetIntArray );
+ CPPUNIT_TEST( testGetIntArray2 );
+ CPPUNIT_TEST( testGetWithIndex );
+ CPPUNIT_TEST( testPutInt );
+ CPPUNIT_TEST( testPutIntArray );
+ CPPUNIT_TEST( testPutIntArray2 );
+ CPPUNIT_TEST( testPutIntBuffer );
+ CPPUNIT_TEST( testPutIndexed );
+ CPPUNIT_TEST( testSlice );
+ CPPUNIT_TEST( testToString );
+ CPPUNIT_TEST_SUITE_END();
+
+ decaf::nio::IntBuffer* testBuffer1;
+ int* 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;
+
+ public:
+
+ IntArrayBufferTest() {}
+ virtual ~IntArrayBufferTest() {}
+
+ void setUp() {
+ testBuffer1 = decaf::nio::IntBuffer::allocate( testData1Size );
+
+ testData1 = new int[testData1Size];
+ for( std::size_t i = 0; i < testData1Size; ++i ){
+ testData1[i] = (int)i;
+ }
+ }
+
+ void tearDown() {
+ delete testBuffer1;
+ delete testData1;
+ }
+
+ void test();
+ void testArray();
+ void testArrayOffset();
+ void testReadOnlyArray();
+ void testAsReadOnlyBuffer();
+ void testCompact();
+ void testCompareTo();
+ void testDuplicate();
+ void testEquals();
+ void testHasArray();
+ void testGet();
+ void testGet2();
+ void testGetIntArray();
+ void testGetIntArray2();
+ void testGetWithIndex();
+ void testPutInt();
+ void testPutIntArray();
+ void testPutIntArray2();
+ void testPutIntBuffer();
+ void testPutIndexed();
+ void testSlice();
+ void testToString();
+
+ protected:
+
+ void loadTestData1( int* array, std::size_t offset, std::size_t length ) {
+ for( std::size_t i = 0; i < length; i++ ) {
+ array[offset + i] = (int)i;
+ }
+ }
+
+ void loadTestData2( int* array, std::size_t offset, std::size_t length ) {
+ for( std::size_t i = 0; i < length; i++ ) {
+ array[offset + i] = (int)length - i;
+ }
+ }
+
+ void loadTestData1( decaf::nio::IntBuffer* buf ) {
+ buf->clear();
+ for( std::size_t i = 0; i < buf->capacity(); i++ ) {
+ buf->put( i, (int)i );
+ }
+ }
+
+ void loadTestData2( decaf::nio::IntBuffer* buf ) {
+ buf->clear();
+ for( std::size_t i = 0; i < buf->capacity(); i++ ) {
+ buf->put(i, (int) buf->capacity() - i);
+ }
+ }
+
+ void assertContentEquals( decaf::nio::IntBuffer* buf, int* array,
+ std::size_t offset, std::size_t length) {
+
+ for( std::size_t i = 0; i < length; i++ ) {
+ CPPUNIT_ASSERT( buf->get(i) == array[offset + i] );
+ }
+ }
+
+ void assertContentEquals( decaf::nio::IntBuffer* buf,
+ decaf::nio::IntBuffer* other ) {
+ CPPUNIT_ASSERT( buf->capacity() == other->capacity() );
+ for( std::size_t i = 0; i < buf->capacity(); i++ ) {
+ CPPUNIT_ASSERT(buf->get(i) == other->get(i) );
+ }
+ }
+
+ void assertContentLikeTestData1(
+ decaf::nio::IntBuffer* buf, std::size_t startIndex,
+ int startValue, std::size_t length ) {
+
+ int value = startValue;
+ for( std::size_t i = 0; i < length; i++ ) {
+ CPPUNIT_ASSERT( buf->get( startIndex + i ) == value );
+ value = value + 1;
+ }
+ }
+
+ };
+
+}}}
+
+#endif /*_DECAF_INTERNAL_NIO_INTARRAYBUFFERTEST_H_*/
Added: activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/LongArrayBufferTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/LongArrayBufferTest.cpp?rev=603604&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/LongArrayBufferTest.cpp (added)
+++ activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/LongArrayBufferTest.cpp Wed Dec 12 04:52:13 2007
@@ -0,0 +1,557 @@
+/*
+ * 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 "LongArrayBufferTest.h"
+#include <decaf/lang/Long.h>
+#include <decaf/lang/Integer.h>
+#include <decaf/lang/Double.h>
+#include <decaf/lang/Float.h>
+
+using namespace std;
+using namespace decaf;
+using namespace decaf::nio;
+using namespace decaf::internal::nio;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+void LongArrayBufferTest::test() {
+
+ // Check that we have setup the array and our initial assumptions on state
+ // are correct. This is the first test run.
+ CPPUNIT_ASSERT( testBuffer1 != NULL );
+ CPPUNIT_ASSERT( testBuffer1->capacity() == testData1Size );
+ CPPUNIT_ASSERT( testBuffer1->hasRemaining() == true );
+ CPPUNIT_ASSERT( testBuffer1->limit() == testBuffer1->capacity() );
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+ CPPUNIT_ASSERT( testBuffer1->isReadOnly() == false );
+ CPPUNIT_ASSERT( testBuffer1->toString() != "" );
+ CPPUNIT_ASSERT( testBuffer1->hasArray() == true );
+ CPPUNIT_ASSERT( testBuffer1->array() != NULL );
+ CPPUNIT_ASSERT( testBuffer1->arrayOffset() == 0 );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void LongArrayBufferTest::testArray() {
+
+ long long* array = testBuffer1->array();
+
+ testBuffer1->put( 0, 10 );
+ CPPUNIT_ASSERT( array[0] == 10.0 );
+
+ assertContentEquals(
+ testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity() );
+
+ loadTestData1( array, testBuffer1->arrayOffset(), testBuffer1->capacity() );
+ assertContentEquals(
+ testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity()) ;
+
+ loadTestData2( array, testBuffer1->arrayOffset(), testBuffer1->capacity());
+ assertContentEquals(
+ testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity() );
+
+ loadTestData1( testBuffer1 );
+ assertContentEquals(
+ testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity() );
+
+ loadTestData2( testBuffer1 );
+ assertContentEquals(
+ testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity() );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void LongArrayBufferTest::testArrayOffset() {
+
+ long long* array = testBuffer1->array();
+
+ assertContentEquals(testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity());
+
+ loadTestData1(array, testBuffer1->arrayOffset(), testBuffer1->capacity());
+ assertContentEquals(testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity());
+
+ loadTestData2(array, testBuffer1->arrayOffset(), testBuffer1->capacity());
+ assertContentEquals(testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity());
+
+ loadTestData1(testBuffer1);
+ assertContentEquals(testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity());
+
+ loadTestData2(testBuffer1);
+ assertContentEquals(testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity());
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void LongArrayBufferTest::testReadOnlyArray() {
+
+ LongBuffer* readOnly = testBuffer1->asReadOnlyBuffer();
+
+ CPPUNIT_ASSERT( readOnly != NULL );
+ CPPUNIT_ASSERT( readOnly->isReadOnly() == true );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw UnsupportedOperationException",
+ readOnly->array(),
+ UnsupportedOperationException );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw UnsupportedOperationException",
+ readOnly->arrayOffset(),
+ UnsupportedOperationException );
+
+ delete readOnly;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void LongArrayBufferTest::testAsReadOnlyBuffer() {
+
+ testBuffer1->clear();
+ testBuffer1->mark();
+ testBuffer1->position( testBuffer1->limit() );
+
+ // readonly's contents should be the same as testBuffer1
+ LongBuffer* readOnly = testBuffer1->asReadOnlyBuffer();
+ CPPUNIT_ASSERT( testBuffer1 != readOnly );
+ CPPUNIT_ASSERT( readOnly->isReadOnly() );
+ CPPUNIT_ASSERT( testBuffer1->position() == readOnly->position() );
+ CPPUNIT_ASSERT( testBuffer1->limit() == readOnly->limit() );
+
+ for( std::size_t i = 0; i < testBuffer1->capacity(); ++i ) {
+ CPPUNIT_ASSERT( testBuffer1->get( i ) == readOnly->get( i ) );
+ }
+
+ // readOnly's position, mark, and limit should be independent to testBuffer1
+ readOnly->reset();
+ CPPUNIT_ASSERT( readOnly->position() == 0 );
+ readOnly->clear();
+ CPPUNIT_ASSERT( testBuffer1->position() == testBuffer1->limit() );
+ testBuffer1->reset();
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+
+ delete readOnly;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void LongArrayBufferTest::testCompact() {
+
+ loadTestData1( testBuffer1 );
+
+ // case: buffer is full
+ testBuffer1->clear();
+ testBuffer1->mark();
+
+ LongBuffer& ret = testBuffer1->compact();
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+ CPPUNIT_ASSERT( testBuffer1->position() == testBuffer1->capacity() );
+ CPPUNIT_ASSERT( testBuffer1->limit() == testBuffer1->capacity() );
+
+ assertContentLikeTestData1( testBuffer1, 0, 0, testBuffer1->capacity() );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw InvalidMarkException",
+ testBuffer1->reset(),
+ InvalidMarkException );
+
+ // case: buffer is empty
+ testBuffer1->position(0);
+ testBuffer1->limit(0);
+ testBuffer1->mark();
+ ret = testBuffer1->compact();
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+ CPPUNIT_ASSERT( testBuffer1->limit() == testBuffer1->capacity() );
+
+ assertContentLikeTestData1(testBuffer1, 0, 0, testBuffer1->capacity());
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw InvalidMarkException",
+ testBuffer1->reset(),
+ InvalidMarkException );
+
+ // case: normal
+ CPPUNIT_ASSERT( testBuffer1->capacity() > 5 );
+
+ testBuffer1->position(1);
+ testBuffer1->limit(5);
+ testBuffer1->mark();
+ ret = testBuffer1->compact();
+ CPPUNIT_ASSERT( &ret == testBuffer1);
+ CPPUNIT_ASSERT( testBuffer1->position() == 4 );
+ CPPUNIT_ASSERT( testBuffer1->limit() == testBuffer1->capacity() );
+
+ assertContentLikeTestData1(testBuffer1, 0, 1, 4);
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw InvalidMarkException",
+ testBuffer1->reset(),
+ InvalidMarkException );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void LongArrayBufferTest::testCompareTo() {
+
+ LongBuffer* other = LongBuffer::allocate( testBuffer1->capacity() );
+
+ loadTestData1(testBuffer1);
+ loadTestData1(other);
+
+ CPPUNIT_ASSERT( 0 == testBuffer1->compareTo( *other ) );
+ CPPUNIT_ASSERT( 0 == other->compareTo( *testBuffer1 ) );
+ testBuffer1->position(1);
+ CPPUNIT_ASSERT( testBuffer1->compareTo( *other ) > 0 );
+ CPPUNIT_ASSERT( other->compareTo( *testBuffer1 ) < 0 );
+ other->position( 2 );
+ CPPUNIT_ASSERT( testBuffer1->compareTo( *other ) < 0 );
+ CPPUNIT_ASSERT( other->compareTo( *testBuffer1 ) > 0 );
+ testBuffer1->position(2);
+ other->limit(5);
+ CPPUNIT_ASSERT( testBuffer1->compareTo( *other ) > 0 );
+ CPPUNIT_ASSERT( other->compareTo( *testBuffer1 ) < 0 );
+
+ std::vector<long long> array1( 1, 555555 );
+ std::vector<long long> array2( 1, 555555 );
+ std::vector<long long> array3( 1, 42 );
+
+ LongBuffer* dbuffer1 = LongBuffer::wrap( array1 );
+ LongBuffer* dbuffer2 = LongBuffer::wrap( array2 );
+ LongBuffer* dbuffer3 = LongBuffer::wrap( array3 );
+
+ CPPUNIT_ASSERT_MESSAGE(
+ "Failed equal comparison with Long entry",
+ dbuffer1->compareTo( *dbuffer2 ) == 0 );
+ CPPUNIT_ASSERT_MESSAGE(
+ "Failed greater than comparison with Long entry",
+ dbuffer3->compareTo( *dbuffer1 ) );
+ CPPUNIT_ASSERT_MESSAGE(
+ "Failed greater than comparison with Long entry",
+ dbuffer1->compareTo( *dbuffer3 ) );
+
+ delete other;
+ delete dbuffer1;
+ delete dbuffer2;
+ delete dbuffer3;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void LongArrayBufferTest::testDuplicate() {
+ testBuffer1->clear();
+ testBuffer1->mark();
+ testBuffer1->position(testBuffer1->limit());
+
+ // duplicate's contents should be the same as testBuffer1
+ LongBuffer* 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() );
+ assertContentEquals( testBuffer1, duplicate );
+
+ // duplicate's position, mark, and limit should be independent to testBuffer1
+ 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 LongArrayBufferTest::testEquals() {
+
+ // equal to self
+ CPPUNIT_ASSERT( testBuffer1->equals( *testBuffer1 ) );
+ LongBuffer* readOnly = testBuffer1->asReadOnlyBuffer();
+ CPPUNIT_ASSERT( testBuffer1->equals( *readOnly ) );
+ LongBuffer* duplicate = testBuffer1->duplicate();
+ CPPUNIT_ASSERT( testBuffer1->equals( *duplicate ) );
+
+ CPPUNIT_ASSERT( testBuffer1->capacity() > 5 );
+
+ 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;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void LongArrayBufferTest::testGet() {
+
+ testBuffer1->clear();
+ for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+ CPPUNIT_ASSERT( testBuffer1->position() == i );
+ CPPUNIT_ASSERT( testBuffer1->get() == testBuffer1->get(i) );
+ }
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw BufferUnderflowException",
+ testBuffer1->get(),
+ BufferUnderflowException );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void LongArrayBufferTest::testGetLongArray() {
+
+ std::vector<long long> array(1);
+ testBuffer1->clear();
+
+ for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+ CPPUNIT_ASSERT( testBuffer1->position() == i );
+ LongBuffer& ret = testBuffer1->get( array );
+ CPPUNIT_ASSERT( array[0] == testBuffer1->get(i) );
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+ }
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw BufferUnderflowException",
+ testBuffer1->get( array ),
+ BufferUnderflowException );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void LongArrayBufferTest::testGetLongArray2() {
+
+ testBuffer1->clear();
+ long long* array = new long long[testBuffer1->capacity()];
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw BufferUnderflowException",
+ testBuffer1->get( array, 0, testBuffer1->capacity() + 1 ),
+ BufferUnderflowException );
+
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+
+ testBuffer1->get( array, 10, 0 );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw BufferUnderflowException",
+ testBuffer1->get( array, 1, Integer::MAX_VALUE ),
+ BufferUnderflowException );
+
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+
+ testBuffer1->clear();
+ LongBuffer& ret = testBuffer1->get( array, 0, testBuffer1->capacity() );
+ CPPUNIT_ASSERT( testBuffer1->position() == testBuffer1->capacity() );
+ assertContentEquals( testBuffer1, array, 0, testBuffer1->capacity() );
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+
+ delete array;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void LongArrayBufferTest::testGet2() {
+
+ testBuffer1->clear();
+ for( std::size_t 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( testBuffer1->limit() ),
+ IndexOutOfBoundsException );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void LongArrayBufferTest::testHasArray() {
+ CPPUNIT_ASSERT( testBuffer1->hasArray() );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void LongArrayBufferTest::testPutLong() {
+
+ testBuffer1->clear();
+
+ for( std::size_t i = 0; i < testBuffer1->capacity(); i++) {
+ CPPUNIT_ASSERT( testBuffer1->position() == i );
+ LongBuffer& ret = testBuffer1->put( (long long)i );
+ CPPUNIT_ASSERT( testBuffer1->get(i) == (long long)i );
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+ }
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw BufferOverflowException",
+ testBuffer1->put( 0 ),
+ BufferOverflowException );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void LongArrayBufferTest::testPutLongArray() {
+
+ long long* array = new long long[1];
+
+ testBuffer1->clear();
+ for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+ CPPUNIT_ASSERT( testBuffer1->position() == i );
+ array[0] = (long long) i;
+ LongBuffer& ret = testBuffer1->put( array, 0, 1 );
+ CPPUNIT_ASSERT( testBuffer1->get(i) == (long long)i );
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+ }
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw BufferOverflowException",
+ testBuffer1->put( array, 0, 1 ),
+ BufferOverflowException );
+
+ delete array;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void LongArrayBufferTest::testPutLongArray2() {
+
+ testBuffer1->clear();
+ long long* array1 = new long long[ testBuffer1->capacity() ];
+ long long* array2 = new long long[ testBuffer1->capacity() + 1 ];
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw BufferOverflowException",
+ testBuffer1->put( array2, 0, testBuffer1->capacity() + 1 ),
+ BufferOverflowException );
+
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+
+ testBuffer1->put( array1, testBuffer1->capacity() + 1, 0 );
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+
+ loadTestData2( array1, 0, testBuffer1->capacity() );
+ LongBuffer& ret = testBuffer1->put( array1, 0, testBuffer1->capacity() );
+ CPPUNIT_ASSERT( testBuffer1->position() == testBuffer1->capacity() );
+ assertContentEquals( testBuffer1, array1, 0, testBuffer1->capacity() );
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void LongArrayBufferTest::testPutLongBuffer() {
+
+ LongBuffer* other = LongBuffer::allocate( testBuffer1->capacity() );
+ LongBuffer* other1 = LongBuffer::allocate( testBuffer1->capacity() + 1 );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw IllegalArgumentException",
+ testBuffer1->put( *testBuffer1 ),
+ IllegalArgumentException );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw BufferOverflowException",
+ testBuffer1->put( *other1 ),
+ BufferOverflowException );
+
+ loadTestData2(other);
+ other->clear();
+ testBuffer1->clear();
+ LongBuffer& ret = testBuffer1->put( *other );
+
+ CPPUNIT_ASSERT( other->position() == other->capacity() );
+ CPPUNIT_ASSERT( testBuffer1->position() == testBuffer1->capacity() );
+ assertContentEquals( other, testBuffer1 );
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+
+ delete other;
+ delete other1;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void LongArrayBufferTest::testGetWithIndex() {
+
+ testBuffer1->clear();
+
+ for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+ LongBuffer& ret = testBuffer1->put( i, (long long)i );
+ CPPUNIT_ASSERT( testBuffer1->get(i) == (long long)i );
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+ }
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw IndexOutOfBoundsException",
+ testBuffer1->put( testBuffer1->limit(), 0 ),
+ IndexOutOfBoundsException );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void LongArrayBufferTest::testPutIndexed() {
+
+ LongBuffer* readOnly = testBuffer1->asReadOnlyBuffer();
+ readOnly->clear();
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw a ReadOnlyBufferException",
+ readOnly->put( 0, 0 ),
+ ReadOnlyBufferException );
+ delete readOnly;
+
+ testBuffer1->clear();
+
+ for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+ LongBuffer& ret = testBuffer1->put(i, i );
+ CPPUNIT_ASSERT( testBuffer1->get(i) == i );
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+ }
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw a IndexOutOfBoundsException",
+ testBuffer1->put( testBuffer1->limit(), 0 ),
+ IndexOutOfBoundsException );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void LongArrayBufferTest::testSlice() {
+
+ CPPUNIT_ASSERT( testBuffer1->capacity() > 5 );
+ testBuffer1->position(1);
+ testBuffer1->limit(testBuffer1->capacity() - 1);
+
+ LongBuffer* slice = testBuffer1->slice();
+ CPPUNIT_ASSERT( testBuffer1->isReadOnly() == slice->isReadOnly() );
+ CPPUNIT_ASSERT( slice->position() == 0 );
+ CPPUNIT_ASSERT( slice->limit() == testBuffer1->remaining() );
+ CPPUNIT_ASSERT( slice->capacity() == testBuffer1->remaining() );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw InvalidMarkException",
+ slice->reset(),
+ InvalidMarkException );
+
+ // slice share the same content with testBuffer1
+ // FIXME:
+ loadTestData1(slice);
+ assertContentLikeTestData1(testBuffer1, 1, 0, slice->capacity());
+ testBuffer1->put( 2, 500 );
+ CPPUNIT_ASSERT( slice->get(1) == 500 );
+
+ delete slice;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void LongArrayBufferTest::testToString() {
+
+ std::string str = testBuffer1->toString();
+ CPPUNIT_ASSERT( str.find("Long") != string::npos );
+ CPPUNIT_ASSERT( str.find( Integer::toString( testBuffer1->position() ) ) != string::npos );
+ CPPUNIT_ASSERT( str.find( Integer::toString( testBuffer1->limit() ) ) != string::npos );
+ CPPUNIT_ASSERT( str.find( Integer::toString( testBuffer1->capacity() ) ) != string::npos );
+}
Added: activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/LongArrayBufferTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/LongArrayBufferTest.h?rev=603604&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/LongArrayBufferTest.h (added)
+++ activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/LongArrayBufferTest.h Wed Dec 12 04:52:13 2007
@@ -0,0 +1,165 @@
+/*
+ * 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_INTERNAL_NIO_LONGARRAYBUFFERTEST_H_
+#define _DECAF_INTERNAL_NIO_LONGARRAYBUFFERTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <decaf/nio/LongBuffer.h>
+
+namespace decaf{
+namespace internal{
+namespace nio{
+
+ class LongArrayBufferTest : public CppUnit::TestFixture {
+
+ CPPUNIT_TEST_SUITE( LongArrayBufferTest );
+ CPPUNIT_TEST( test );
+ CPPUNIT_TEST( testArray );
+ CPPUNIT_TEST( testArrayOffset );
+ CPPUNIT_TEST( testReadOnlyArray );
+ CPPUNIT_TEST( testAsReadOnlyBuffer );
+ CPPUNIT_TEST( testCompact );
+ CPPUNIT_TEST( testCompareTo );
+ CPPUNIT_TEST( testDuplicate );
+ CPPUNIT_TEST( testEquals );
+ CPPUNIT_TEST( testHasArray );
+ CPPUNIT_TEST( testGet );
+ CPPUNIT_TEST( testGet2 );
+ CPPUNIT_TEST( testGetLongArray );
+ CPPUNIT_TEST( testGetLongArray2 );
+ CPPUNIT_TEST( testGetWithIndex );
+ CPPUNIT_TEST( testPutLong );
+ CPPUNIT_TEST( testPutLongArray );
+ CPPUNIT_TEST( testPutLongArray2 );
+ CPPUNIT_TEST( testPutLongBuffer );
+ CPPUNIT_TEST( testPutIndexed );
+ CPPUNIT_TEST( testSlice );
+ CPPUNIT_TEST( testToString );
+ CPPUNIT_TEST_SUITE_END();
+
+ decaf::nio::LongBuffer* testBuffer1;
+ long long* 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;
+
+ public:
+
+ LongArrayBufferTest() {}
+ virtual ~LongArrayBufferTest() {}
+
+ void setUp() {
+ testBuffer1 = decaf::nio::LongBuffer::allocate( testData1Size );
+
+ testData1 = new long long[testData1Size];
+ for( std::size_t i = 0; i < testData1Size; ++i ){
+ testData1[i] = (long long)i;
+ }
+ }
+
+ void tearDown() {
+ delete testBuffer1;
+ delete testData1;
+ }
+
+ void test();
+ void testArray();
+ void testArrayOffset();
+ void testReadOnlyArray();
+ void testAsReadOnlyBuffer();
+ void testCompact();
+ void testCompareTo();
+ void testDuplicate();
+ void testEquals();
+ void testHasArray();
+ void testGet();
+ void testGet2();
+ void testGetLongArray();
+ void testGetLongArray2();
+ void testGetWithIndex();
+ void testPutLong();
+ void testPutLongArray();
+ void testPutLongArray2();
+ void testPutLongBuffer();
+ void testPutIndexed();
+ void testSlice();
+ void testToString();
+
+ protected:
+
+ void loadTestData1( long long* array, std::size_t offset, std::size_t length ) {
+ for( std::size_t i = 0; i < length; i++ ) {
+ array[offset + i] = (long long)i;
+ }
+ }
+
+ void loadTestData2( long long* array, std::size_t offset, std::size_t length ) {
+ for( std::size_t i = 0; i < length; i++ ) {
+ array[offset + i] = (long long)length - i;
+ }
+ }
+
+ void loadTestData1( decaf::nio::LongBuffer* buf ) {
+ buf->clear();
+ for( std::size_t i = 0; i < buf->capacity(); i++ ) {
+ buf->put( i, (long long)i );
+ }
+ }
+
+ void loadTestData2( decaf::nio::LongBuffer* buf ) {
+ buf->clear();
+ for( std::size_t i = 0; i < buf->capacity(); i++ ) {
+ buf->put(i, (long long) buf->capacity() - i);
+ }
+ }
+
+ void assertContentEquals( decaf::nio::LongBuffer* buf, long long* array,
+ std::size_t offset, std::size_t length) {
+
+ for( std::size_t i = 0; i < length; i++ ) {
+ CPPUNIT_ASSERT( buf->get(i) == array[offset + i] );
+ }
+ }
+
+ void assertContentEquals( decaf::nio::LongBuffer* buf,
+ decaf::nio::LongBuffer* other ) {
+ CPPUNIT_ASSERT( buf->capacity() == other->capacity() );
+ for( std::size_t i = 0; i < buf->capacity(); i++ ) {
+ CPPUNIT_ASSERT(buf->get(i) == other->get(i) );
+ }
+ }
+
+ void assertContentLikeTestData1(
+ decaf::nio::LongBuffer* buf, std::size_t startIndex,
+ long long startValue, std::size_t length ) {
+
+ long long value = startValue;
+ for( std::size_t i = 0; i < length; i++ ) {
+ CPPUNIT_ASSERT( buf->get( startIndex + i ) == value );
+ value = value + 1;
+ }
+ }
+
+ };
+
+}}}
+
+#endif /*_DECAF_INTERNAL_NIO_LONGARRAYBUFFERTEST_H_*/
Added: activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/ShortArrayBufferTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/ShortArrayBufferTest.cpp?rev=603604&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/ShortArrayBufferTest.cpp (added)
+++ activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/ShortArrayBufferTest.cpp Wed Dec 12 04:52:13 2007
@@ -0,0 +1,556 @@
+/*
+ * 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 "ShortArrayBufferTest.h"
+#include <decaf/lang/Integer.h>
+#include <decaf/lang/Double.h>
+#include <decaf/lang/Float.h>
+
+using namespace std;
+using namespace decaf;
+using namespace decaf::nio;
+using namespace decaf::internal::nio;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+void ShortArrayBufferTest::test() {
+
+ // Check that we have setup the array and our initial assumptions on state
+ // are correct. This is the first test run.
+ CPPUNIT_ASSERT( testBuffer1 != NULL );
+ CPPUNIT_ASSERT( testBuffer1->capacity() == testData1Size );
+ CPPUNIT_ASSERT( testBuffer1->hasRemaining() == true );
+ CPPUNIT_ASSERT( testBuffer1->limit() == testBuffer1->capacity() );
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+ CPPUNIT_ASSERT( testBuffer1->isReadOnly() == false );
+ CPPUNIT_ASSERT( testBuffer1->toString() != "" );
+ CPPUNIT_ASSERT( testBuffer1->hasArray() == true );
+ CPPUNIT_ASSERT( testBuffer1->array() != NULL );
+ CPPUNIT_ASSERT( testBuffer1->arrayOffset() == 0 );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ShortArrayBufferTest::testArray() {
+
+ short* array = testBuffer1->array();
+
+ testBuffer1->put( 0, 10 );
+ CPPUNIT_ASSERT( array[0] == 10.0 );
+
+ assertContentEquals(
+ testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity() );
+
+ loadTestData1( array, testBuffer1->arrayOffset(), testBuffer1->capacity() );
+ assertContentEquals(
+ testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity()) ;
+
+ loadTestData2( array, testBuffer1->arrayOffset(), testBuffer1->capacity());
+ assertContentEquals(
+ testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity() );
+
+ loadTestData1( testBuffer1 );
+ assertContentEquals(
+ testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity() );
+
+ loadTestData2( testBuffer1 );
+ assertContentEquals(
+ testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity() );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ShortArrayBufferTest::testArrayOffset() {
+
+ short* array = testBuffer1->array();
+
+ assertContentEquals(testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity());
+
+ loadTestData1(array, testBuffer1->arrayOffset(), testBuffer1->capacity());
+ assertContentEquals(testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity());
+
+ loadTestData2(array, testBuffer1->arrayOffset(), testBuffer1->capacity());
+ assertContentEquals(testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity());
+
+ loadTestData1(testBuffer1);
+ assertContentEquals(testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity());
+
+ loadTestData2(testBuffer1);
+ assertContentEquals(testBuffer1, array, testBuffer1->arrayOffset(), testBuffer1->capacity());
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ShortArrayBufferTest::testReadOnlyArray() {
+
+ ShortBuffer* readOnly = testBuffer1->asReadOnlyBuffer();
+
+ CPPUNIT_ASSERT( readOnly != NULL );
+ CPPUNIT_ASSERT( readOnly->isReadOnly() == true );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw UnsupportedOperationException",
+ readOnly->array(),
+ UnsupportedOperationException );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw UnsupportedOperationException",
+ readOnly->arrayOffset(),
+ UnsupportedOperationException );
+
+ delete readOnly;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ShortArrayBufferTest::testAsReadOnlyBuffer() {
+
+ testBuffer1->clear();
+ testBuffer1->mark();
+ testBuffer1->position( testBuffer1->limit() );
+
+ // readonly's contents should be the same as testBuffer1
+ ShortBuffer* readOnly = testBuffer1->asReadOnlyBuffer();
+ CPPUNIT_ASSERT( testBuffer1 != readOnly );
+ CPPUNIT_ASSERT( readOnly->isReadOnly() );
+ CPPUNIT_ASSERT( testBuffer1->position() == readOnly->position() );
+ CPPUNIT_ASSERT( testBuffer1->limit() == readOnly->limit() );
+
+ for( std::size_t i = 0; i < testBuffer1->capacity(); ++i ) {
+ CPPUNIT_ASSERT( testBuffer1->get( i ) == readOnly->get( i ) );
+ }
+
+ // readOnly's position, mark, and limit should be independent to testBuffer1
+ readOnly->reset();
+ CPPUNIT_ASSERT( readOnly->position() == 0 );
+ readOnly->clear();
+ CPPUNIT_ASSERT( testBuffer1->position() == testBuffer1->limit() );
+ testBuffer1->reset();
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+
+ delete readOnly;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ShortArrayBufferTest::testCompact() {
+
+ loadTestData1( testBuffer1 );
+
+ // case: buffer is full
+ testBuffer1->clear();
+ testBuffer1->mark();
+
+ ShortBuffer& ret = testBuffer1->compact();
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+ CPPUNIT_ASSERT( testBuffer1->position() == testBuffer1->capacity() );
+ CPPUNIT_ASSERT( testBuffer1->limit() == testBuffer1->capacity() );
+
+ assertContentLikeTestData1( testBuffer1, 0, 0, testBuffer1->capacity() );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw InvalidMarkException",
+ testBuffer1->reset(),
+ InvalidMarkException );
+
+ // case: buffer is empty
+ testBuffer1->position(0);
+ testBuffer1->limit(0);
+ testBuffer1->mark();
+ ret = testBuffer1->compact();
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+ CPPUNIT_ASSERT( testBuffer1->limit() == testBuffer1->capacity() );
+
+ assertContentLikeTestData1(testBuffer1, 0, 0, testBuffer1->capacity());
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw InvalidMarkException",
+ testBuffer1->reset(),
+ InvalidMarkException );
+
+ // case: normal
+ CPPUNIT_ASSERT( testBuffer1->capacity() > 5 );
+
+ testBuffer1->position(1);
+ testBuffer1->limit(5);
+ testBuffer1->mark();
+ ret = testBuffer1->compact();
+ CPPUNIT_ASSERT( &ret == testBuffer1);
+ CPPUNIT_ASSERT( testBuffer1->position() == 4 );
+ CPPUNIT_ASSERT( testBuffer1->limit() == testBuffer1->capacity() );
+
+ assertContentLikeTestData1(testBuffer1, 0, 1, 4);
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw InvalidMarkException",
+ testBuffer1->reset(),
+ InvalidMarkException );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ShortArrayBufferTest::testCompareTo() {
+
+ ShortBuffer* other = ShortBuffer::allocate( testBuffer1->capacity() );
+
+ loadTestData1(testBuffer1);
+ loadTestData1(other);
+
+ CPPUNIT_ASSERT( 0 == testBuffer1->compareTo( *other ) );
+ CPPUNIT_ASSERT( 0 == other->compareTo( *testBuffer1 ) );
+ testBuffer1->position(1);
+ CPPUNIT_ASSERT( testBuffer1->compareTo( *other ) > 0 );
+ CPPUNIT_ASSERT( other->compareTo( *testBuffer1 ) < 0 );
+ other->position( 2 );
+ CPPUNIT_ASSERT( testBuffer1->compareTo( *other ) < 0 );
+ CPPUNIT_ASSERT( other->compareTo( *testBuffer1 ) > 0 );
+ testBuffer1->position(2);
+ other->limit(5);
+ CPPUNIT_ASSERT( testBuffer1->compareTo( *other ) > 0 );
+ CPPUNIT_ASSERT( other->compareTo( *testBuffer1 ) < 0 );
+
+ std::vector<short> array1( 1, 32678 );
+ std::vector<short> array2( 1, 32678 );
+ std::vector<short> array3( 1, 42 );
+
+ ShortBuffer* dbuffer1 = ShortBuffer::wrap( array1 );
+ ShortBuffer* dbuffer2 = ShortBuffer::wrap( array2 );
+ ShortBuffer* dbuffer3 = ShortBuffer::wrap( array3 );
+
+ CPPUNIT_ASSERT_MESSAGE(
+ "Failed equal comparison with Short entry",
+ dbuffer1->compareTo( *dbuffer2 ) == 0 );
+ CPPUNIT_ASSERT_MESSAGE(
+ "Failed greater than comparison with Short entry",
+ dbuffer3->compareTo( *dbuffer1 ) );
+ CPPUNIT_ASSERT_MESSAGE(
+ "Failed greater than comparison with Short entry",
+ dbuffer1->compareTo( *dbuffer3 ) );
+
+ delete other;
+ delete dbuffer1;
+ delete dbuffer2;
+ delete dbuffer3;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ShortArrayBufferTest::testDuplicate() {
+ testBuffer1->clear();
+ testBuffer1->mark();
+ testBuffer1->position(testBuffer1->limit());
+
+ // duplicate's contents should be the same as testBuffer1
+ ShortBuffer* 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() );
+ assertContentEquals( testBuffer1, duplicate );
+
+ // duplicate's position, mark, and limit should be independent to testBuffer1
+ 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 ShortArrayBufferTest::testEquals() {
+
+ // equal to self
+ CPPUNIT_ASSERT( testBuffer1->equals( *testBuffer1 ) );
+ ShortBuffer* readOnly = testBuffer1->asReadOnlyBuffer();
+ CPPUNIT_ASSERT( testBuffer1->equals( *readOnly ) );
+ ShortBuffer* duplicate = testBuffer1->duplicate();
+ CPPUNIT_ASSERT( testBuffer1->equals( *duplicate ) );
+
+ CPPUNIT_ASSERT( testBuffer1->capacity() > 5 );
+
+ 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;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ShortArrayBufferTest::testGet() {
+
+ testBuffer1->clear();
+ for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+ CPPUNIT_ASSERT( testBuffer1->position() == i );
+ CPPUNIT_ASSERT( testBuffer1->get() == testBuffer1->get(i) );
+ }
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw BufferUnderflowException",
+ testBuffer1->get(),
+ BufferUnderflowException );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ShortArrayBufferTest::testGetShortArray() {
+
+ std::vector<short> array(1);
+ testBuffer1->clear();
+
+ for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+ CPPUNIT_ASSERT( testBuffer1->position() == i );
+ ShortBuffer& ret = testBuffer1->get( array );
+ CPPUNIT_ASSERT( array[0] == testBuffer1->get(i) );
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+ }
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw BufferUnderflowException",
+ testBuffer1->get( array ),
+ BufferUnderflowException );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ShortArrayBufferTest::testGetShortArray2() {
+
+ testBuffer1->clear();
+ short* array = new short[testBuffer1->capacity()];
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw BufferUnderflowException",
+ testBuffer1->get( array, 0, testBuffer1->capacity() + 1 ),
+ BufferUnderflowException );
+
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+
+ testBuffer1->get( array, 10, 0 );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw BufferUnderflowException",
+ testBuffer1->get( array, 1, Integer::MAX_VALUE ),
+ BufferUnderflowException );
+
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+
+ testBuffer1->clear();
+ ShortBuffer& ret = testBuffer1->get( array, 0, testBuffer1->capacity() );
+ CPPUNIT_ASSERT( testBuffer1->position() == testBuffer1->capacity() );
+ assertContentEquals( testBuffer1, array, 0, testBuffer1->capacity() );
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+
+ delete array;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ShortArrayBufferTest::testGet2() {
+
+ testBuffer1->clear();
+ for( std::size_t 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( testBuffer1->limit() ),
+ IndexOutOfBoundsException );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ShortArrayBufferTest::testHasArray() {
+ CPPUNIT_ASSERT( testBuffer1->hasArray() );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ShortArrayBufferTest::testPutShort() {
+
+ testBuffer1->clear();
+
+ for( std::size_t i = 0; i < testBuffer1->capacity(); i++) {
+ CPPUNIT_ASSERT( testBuffer1->position() == i );
+ ShortBuffer& ret = testBuffer1->put( (short)i );
+ CPPUNIT_ASSERT( testBuffer1->get(i) == (short)i );
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+ }
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw BufferOverflowException",
+ testBuffer1->put( 0 ),
+ BufferOverflowException );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ShortArrayBufferTest::testPutShortArray() {
+
+ short* array = new short[1];
+
+ testBuffer1->clear();
+ for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+ CPPUNIT_ASSERT( testBuffer1->position() == i );
+ array[0] = (short) i;
+ ShortBuffer& ret = testBuffer1->put( array, 0, 1 );
+ CPPUNIT_ASSERT( testBuffer1->get(i) == (short)i );
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+ }
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw BufferOverflowException",
+ testBuffer1->put( array, 0, 1 ),
+ BufferOverflowException );
+
+ delete array;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ShortArrayBufferTest::testPutShortArray2() {
+
+ testBuffer1->clear();
+ short* array1 = new short[ testBuffer1->capacity() ];
+ short* array2 = new short[ testBuffer1->capacity() + 1 ];
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw BufferOverflowException",
+ testBuffer1->put( array2, 0, testBuffer1->capacity() + 1 ),
+ BufferOverflowException );
+
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+
+ testBuffer1->put( array1, testBuffer1->capacity() + 1, 0 );
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+
+ loadTestData2( array1, 0, testBuffer1->capacity() );
+ ShortBuffer& ret = testBuffer1->put( array1, 0, testBuffer1->capacity() );
+ CPPUNIT_ASSERT( testBuffer1->position() == testBuffer1->capacity() );
+ assertContentEquals( testBuffer1, array1, 0, testBuffer1->capacity() );
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ShortArrayBufferTest::testPutShortBuffer() {
+
+ ShortBuffer* other = ShortBuffer::allocate( testBuffer1->capacity() );
+ ShortBuffer* other1 = ShortBuffer::allocate( testBuffer1->capacity() + 1 );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw IllegalArgumentException",
+ testBuffer1->put( *testBuffer1 ),
+ IllegalArgumentException );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw BufferOverflowException",
+ testBuffer1->put( *other1 ),
+ BufferOverflowException );
+
+ loadTestData2(other);
+ other->clear();
+ testBuffer1->clear();
+ ShortBuffer& ret = testBuffer1->put( *other );
+
+ CPPUNIT_ASSERT( other->position() == other->capacity() );
+ CPPUNIT_ASSERT( testBuffer1->position() == testBuffer1->capacity() );
+ assertContentEquals( other, testBuffer1 );
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+
+ delete other;
+ delete other1;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ShortArrayBufferTest::testGetWithIndex() {
+
+ testBuffer1->clear();
+
+ for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+ ShortBuffer& ret = testBuffer1->put( i, (short)i );
+ CPPUNIT_ASSERT( testBuffer1->get(i) == (short)i );
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+ }
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw IndexOutOfBoundsException",
+ testBuffer1->put( testBuffer1->limit(), 0 ),
+ IndexOutOfBoundsException );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ShortArrayBufferTest::testPutIndexed() {
+
+ ShortBuffer* readOnly = testBuffer1->asReadOnlyBuffer();
+ readOnly->clear();
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw a ReadOnlyBufferException",
+ readOnly->put( 0, 0 ),
+ ReadOnlyBufferException );
+ delete readOnly;
+
+ testBuffer1->clear();
+
+ for( std::size_t i = 0; i < testBuffer1->capacity(); i++ ) {
+ CPPUNIT_ASSERT( testBuffer1->position() == 0 );
+ ShortBuffer& ret = testBuffer1->put(i, i );
+ CPPUNIT_ASSERT( testBuffer1->get(i) == (short)i );
+ CPPUNIT_ASSERT( &ret == testBuffer1 );
+ }
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw a IndexOutOfBoundsException",
+ testBuffer1->put( testBuffer1->limit(), 0 ),
+ IndexOutOfBoundsException );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ShortArrayBufferTest::testSlice() {
+
+ CPPUNIT_ASSERT( testBuffer1->capacity() > 5 );
+ testBuffer1->position(1);
+ testBuffer1->limit(testBuffer1->capacity() - 1);
+
+ ShortBuffer* slice = testBuffer1->slice();
+ CPPUNIT_ASSERT( testBuffer1->isReadOnly() == slice->isReadOnly() );
+ CPPUNIT_ASSERT( slice->position() == 0 );
+ CPPUNIT_ASSERT( slice->limit() == testBuffer1->remaining() );
+ CPPUNIT_ASSERT( slice->capacity() == testBuffer1->remaining() );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw InvalidMarkException",
+ slice->reset(),
+ InvalidMarkException );
+
+ // slice share the same content with testBuffer1
+ // FIXME:
+ loadTestData1(slice);
+ assertContentLikeTestData1(testBuffer1, 1, 0, slice->capacity());
+ testBuffer1->put( 2, 500 );
+ CPPUNIT_ASSERT( slice->get(1) == 500 );
+
+ delete slice;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ShortArrayBufferTest::testToString() {
+
+ std::string str = testBuffer1->toString();
+ CPPUNIT_ASSERT( str.find("Short") != string::npos );
+ CPPUNIT_ASSERT( str.find( Integer::toString( testBuffer1->position() ) ) != string::npos );
+ CPPUNIT_ASSERT( str.find( Integer::toString( testBuffer1->limit() ) ) != string::npos );
+ CPPUNIT_ASSERT( str.find( Integer::toString( testBuffer1->capacity() ) ) != string::npos );
+}
Added: activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/ShortArrayBufferTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/ShortArrayBufferTest.h?rev=603604&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/ShortArrayBufferTest.h (added)
+++ activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/ShortArrayBufferTest.h Wed Dec 12 04:52:13 2007
@@ -0,0 +1,165 @@
+/*
+ * 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_INTERNAL_NIO_SHORTARRAYBUFFERTEST_H_
+#define _DECAF_INTERNAL_NIO_SHORTARRAYBUFFERTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <decaf/nio/ShortBuffer.h>
+
+namespace decaf{
+namespace internal{
+namespace nio{
+
+ class ShortArrayBufferTest : public CppUnit::TestFixture {
+
+ CPPUNIT_TEST_SUITE( ShortArrayBufferTest );
+ CPPUNIT_TEST( test );
+ CPPUNIT_TEST( testArray );
+ CPPUNIT_TEST( testArrayOffset );
+ CPPUNIT_TEST( testReadOnlyArray );
+ CPPUNIT_TEST( testAsReadOnlyBuffer );
+ CPPUNIT_TEST( testCompact );
+ CPPUNIT_TEST( testCompareTo );
+ CPPUNIT_TEST( testDuplicate );
+ CPPUNIT_TEST( testEquals );
+ CPPUNIT_TEST( testHasArray );
+ CPPUNIT_TEST( testGet );
+ CPPUNIT_TEST( testGet2 );
+ CPPUNIT_TEST( testGetShortArray );
+ CPPUNIT_TEST( testGetShortArray2 );
+ CPPUNIT_TEST( testGetWithIndex );
+ CPPUNIT_TEST( testPutShort );
+ CPPUNIT_TEST( testPutShortArray );
+ CPPUNIT_TEST( testPutShortArray2 );
+ CPPUNIT_TEST( testPutShortBuffer );
+ CPPUNIT_TEST( testPutIndexed );
+ CPPUNIT_TEST( testSlice );
+ CPPUNIT_TEST( testToString );
+ CPPUNIT_TEST_SUITE_END();
+
+ decaf::nio::ShortBuffer* testBuffer1;
+ short* 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;
+
+ public:
+
+ ShortArrayBufferTest() {}
+ virtual ~ShortArrayBufferTest() {}
+
+ void setUp() {
+ testBuffer1 = decaf::nio::ShortBuffer::allocate( testData1Size );
+
+ testData1 = new short[testData1Size];
+ for( std::size_t i = 0; i < testData1Size; ++i ){
+ testData1[i] = (short)i;
+ }
+ }
+
+ void tearDown() {
+ delete testBuffer1;
+ delete testData1;
+ }
+
+ void test();
+ void testArray();
+ void testArrayOffset();
+ void testReadOnlyArray();
+ void testAsReadOnlyBuffer();
+ void testCompact();
+ void testCompareTo();
+ void testDuplicate();
+ void testEquals();
+ void testHasArray();
+ void testGet();
+ void testGet2();
+ void testGetShortArray();
+ void testGetShortArray2();
+ void testGetWithIndex();
+ void testPutShort();
+ void testPutShortArray();
+ void testPutShortArray2();
+ void testPutShortBuffer();
+ void testPutIndexed();
+ void testSlice();
+ void testToString();
+
+ protected:
+
+ void loadTestData1( short* array, std::size_t offset, std::size_t length ) {
+ for( std::size_t i = 0; i < length; i++ ) {
+ array[offset + i] = (short)i;
+ }
+ }
+
+ void loadTestData2( short* array, std::size_t offset, std::size_t length ) {
+ for( std::size_t i = 0; i < length; i++ ) {
+ array[offset + i] = (short)length - i;
+ }
+ }
+
+ void loadTestData1( decaf::nio::ShortBuffer* buf ) {
+ buf->clear();
+ for( std::size_t i = 0; i < buf->capacity(); i++ ) {
+ buf->put( i, (short)i );
+ }
+ }
+
+ void loadTestData2( decaf::nio::ShortBuffer* buf ) {
+ buf->clear();
+ for( std::size_t i = 0; i < buf->capacity(); i++ ) {
+ buf->put(i, (short) buf->capacity() - i);
+ }
+ }
+
+ void assertContentEquals( decaf::nio::ShortBuffer* buf, short* array,
+ std::size_t offset, std::size_t length) {
+
+ for( std::size_t i = 0; i < length; i++ ) {
+ CPPUNIT_ASSERT( buf->get(i) == array[offset + i] );
+ }
+ }
+
+ void assertContentEquals( decaf::nio::ShortBuffer* buf,
+ decaf::nio::ShortBuffer* other ) {
+ CPPUNIT_ASSERT( buf->capacity() == other->capacity() );
+ for( std::size_t i = 0; i < buf->capacity(); i++ ) {
+ CPPUNIT_ASSERT(buf->get(i) == other->get(i) );
+ }
+ }
+
+ void assertContentLikeTestData1(
+ decaf::nio::ShortBuffer* buf, std::size_t startIndex,
+ short startValue, std::size_t length ) {
+
+ short value = startValue;
+ for( std::size_t i = 0; i < length; i++ ) {
+ CPPUNIT_ASSERT( buf->get( startIndex + i ) == value );
+ value = value + 1;
+ }
+ }
+
+ };
+
+}}}
+
+#endif /*_DECAF_INTERNAL_NIO_SHORTARRAYBUFFERTEST_H_*/
Modified: activemq/activemq-cpp/decaf/trunk/src/test/testRegistry.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/test/testRegistry.cpp?rev=603604&r1=603603&r2=603604&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/test/testRegistry.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/test/testRegistry.cpp Wed Dec 12 04:52:13 2007
@@ -32,6 +32,12 @@
CPPUNIT_TEST_SUITE_REGISTRATION( decaf::internal::nio::DoubleArrayBufferTest );
#include <decaf/internal/nio/FloatArrayBufferTest.h>
CPPUNIT_TEST_SUITE_REGISTRATION( decaf::internal::nio::FloatArrayBufferTest );
+#include <decaf/internal/nio/LongArrayBufferTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( decaf::internal::nio::LongArrayBufferTest );
+#include <decaf/internal/nio/IntArrayBufferTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( decaf::internal::nio::IntArrayBufferTest );
+#include <decaf/internal/nio/ShortArrayBufferTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( decaf::internal::nio::ShortArrayBufferTest );
#include <decaf/nio/BufferTest.h>
CPPUNIT_TEST_SUITE_REGISTRATION( decaf::nio::BufferTest );