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/11/27 16:11:19 UTC
svn commit: r598662 - in
/activemq/activemq-cpp/decaf/trunk/src/test/decaf/nio: ByteBufferTest.cpp
ByteBufferTest.h
Author: tabish
Date: Tue Nov 27 07:11:18 2007
New Revision: 598662
URL: http://svn.apache.org/viewvc?rev=598662&view=rev
Log:
http://issues.apache.org/activemq/browse/AMQCPP-103
Starting the NIO implementation
Testing the ByteBuffer class
Modified:
activemq/activemq-cpp/decaf/trunk/src/test/decaf/nio/ByteBufferTest.cpp
activemq/activemq-cpp/decaf/trunk/src/test/decaf/nio/ByteBufferTest.h
Modified: activemq/activemq-cpp/decaf/trunk/src/test/decaf/nio/ByteBufferTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/test/decaf/nio/ByteBufferTest.cpp?rev=598662&r1=598661&r2=598662&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/test/decaf/nio/ByteBufferTest.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/test/decaf/nio/ByteBufferTest.cpp Tue Nov 27 07:11:18 2007
@@ -26,6 +26,33 @@
////////////////////////////////////////////////////////////////////////////////
void ByteBufferTest::test() {
- CPPUNIT_ASSERT( buffer != NULL );
- CPPUNIT_ASSERT( buffer->capacity() == 10 );
+ CPPUNIT_ASSERT( testBuffer1 != NULL );
+ CPPUNIT_ASSERT( testBuffer1->capacity() == testData1Size );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ByteBufferTest::testArray() {
+
+ testBuffer1->put( testData1, 0, testData1Size );
+ testBuffer1->position( 0 );
+
+ for( std::size_t ix = 0; ix < testBuffer1->capacity(); ++ix ) {
+ CPPUNIT_ASSERT( testBuffer1->get() == testData1[ix] );
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ByteBufferTest::testReadOnlyArray() {
+
+ ByteBuffer* readOnly = testBuffer1->asReadOnlyBuffer();
+
+ CPPUNIT_ASSERT( readOnly != NULL );
+ CPPUNIT_ASSERT( readOnly->isReadOnly() == true );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should throw UnsupportedOperationException",
+ readOnly->array(),
+ UnsupportedOperationException );
+
+ delete readOnly;
}
Modified: activemq/activemq-cpp/decaf/trunk/src/test/decaf/nio/ByteBufferTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/test/decaf/nio/ByteBufferTest.h?rev=598662&r1=598661&r2=598662&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/test/decaf/nio/ByteBufferTest.h (original)
+++ activemq/activemq-cpp/decaf/trunk/src/test/decaf/nio/ByteBufferTest.h Tue Nov 27 07:11:18 2007
@@ -30,21 +30,39 @@
CPPUNIT_TEST_SUITE( ByteBufferTest );
CPPUNIT_TEST( test );
+ CPPUNIT_TEST( testArray );
+ CPPUNIT_TEST( testReadOnlyArray );
CPPUNIT_TEST_SUITE_END();
private:
- ByteBuffer* buffer;
+ ByteBuffer* testBuffer1;
+ unsigned char* testData1;
+
+ static const std::size_t testData1Size = 100;
public:
ByteBufferTest() {}
virtual ~ByteBufferTest() {}
- void setUp() { buffer = new ByteBuffer(10); }
- void tearDown() { delete buffer; }
+ void setUp() {
+ testBuffer1 = new ByteBuffer(testData1Size);
+
+ testData1 = new unsigned char[testData1Size];
+ for( std::size_t i = 0; i < testData1Size; ++i ){
+ testData1[i] = (unsigned char)i;
+ }
+ }
+
+ void tearDown() {
+ delete testBuffer1;
+ delete testData1;
+ }
void test();
+ void testArray();
+ void testReadOnlyArray();
};