Author: tabish
Date: Sat May 31 11:17:57 2008
New Revision: 662058
URL: http://svn.apache.org/viewvc?rev=662058&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQCPP-172
Modified:
activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveList.cpp
activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveList.h
activemq/activemq-cpp/trunk/src/test/activemq/util/PrimitiveListTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/util/PrimitiveListTest.h
Modified: activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveList.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveList.cpp?rev=662058&r1=662057&r2=662058&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveList.cpp
(original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveList.cpp Sat
May 31 11:17:57 2008
@@ -54,14 +54,15 @@
////////////////////////////////////////////////////////////////////////////////
bool PrimitiveList::getBool( std::size_t index ) const
- throw( IndexOutOfBoundsException ){
+ throw( IndexOutOfBoundsException, NoSuchElementException ){
PrimitiveValueNode node = this->get( index );
return node.getBool();
}
////////////////////////////////////////////////////////////////////////////////
-void PrimitiveList::setBool( std::size_t index, bool value ){
+void PrimitiveList::setBool( std::size_t index, bool value )
+ throw( IndexOutOfBoundsException ){
PrimitiveValueNode node;
node.setBool( value );
@@ -71,14 +72,16 @@
////////////////////////////////////////////////////////////////////////////////
unsigned char PrimitiveList::getByte( std::size_t index ) const
- throw( IndexOutOfBoundsException ){
+ throw( IndexOutOfBoundsException, NoSuchElementException ){
PrimitiveValueNode node = this->get( index );
return node.getByte();
}
////////////////////////////////////////////////////////////////////////////////
-void PrimitiveList::setByte( std::size_t index, unsigned char value ){
+void PrimitiveList::setByte( std::size_t index, unsigned char value )
+ throw( IndexOutOfBoundsException ){
+
PrimitiveValueNode node;
node.setByte( value );
@@ -87,14 +90,16 @@
////////////////////////////////////////////////////////////////////////////////
char PrimitiveList::getChar( std::size_t index ) const
- throw( IndexOutOfBoundsException ){
+ throw( IndexOutOfBoundsException, NoSuchElementException ){
PrimitiveValueNode node = this->get( index );
return node.getChar();
}
////////////////////////////////////////////////////////////////////////////////
-void PrimitiveList::setChar( std::size_t index, char value ){
+void PrimitiveList::setChar( std::size_t index, char value )
+ throw( IndexOutOfBoundsException ){
+
PrimitiveValueNode node;
node.setChar( value );
@@ -103,14 +108,16 @@
////////////////////////////////////////////////////////////////////////////////
short PrimitiveList::getShort( std::size_t index ) const
- throw( IndexOutOfBoundsException ){
+ throw( IndexOutOfBoundsException, NoSuchElementException ){
PrimitiveValueNode node = this->get( index );
return node.getShort();
}
////////////////////////////////////////////////////////////////////////////////
-void PrimitiveList::setShort( std::size_t index, short value ){
+void PrimitiveList::setShort( std::size_t index, short value )
+ throw( IndexOutOfBoundsException ){
+
PrimitiveValueNode node;
node.setShort( value );
@@ -119,14 +126,16 @@
////////////////////////////////////////////////////////////////////////////////
int PrimitiveList::getInt( std::size_t index ) const
- throw( IndexOutOfBoundsException ){
+ throw( IndexOutOfBoundsException, NoSuchElementException ){
PrimitiveValueNode node = this->get( index );
return node.getInt();
}
////////////////////////////////////////////////////////////////////////////////
-void PrimitiveList::setInt( std::size_t index, int value ){
+void PrimitiveList::setInt( std::size_t index, int value )
+ throw( IndexOutOfBoundsException ){
+
PrimitiveValueNode node;
node.setInt( value );
@@ -135,14 +144,16 @@
////////////////////////////////////////////////////////////////////////////////
long long PrimitiveList::getLong( std::size_t index ) const
- throw( IndexOutOfBoundsException ){
+ throw( IndexOutOfBoundsException, NoSuchElementException ){
PrimitiveValueNode node = this->get( index );
return node.getLong();
}
////////////////////////////////////////////////////////////////////////////////
-void PrimitiveList::setLong( std::size_t index, long long value ){
+void PrimitiveList::setLong( std::size_t index, long long value )
+ throw( IndexOutOfBoundsException ){
+
PrimitiveValueNode node;
node.setLong( value );
@@ -151,14 +162,16 @@
////////////////////////////////////////////////////////////////////////////////
double PrimitiveList::getDouble( std::size_t index ) const
- throw( IndexOutOfBoundsException ){
+ throw( IndexOutOfBoundsException, NoSuchElementException ){
PrimitiveValueNode node = this->get( index );
return node.getDouble();
}
////////////////////////////////////////////////////////////////////////////////
-void PrimitiveList::setDouble( std::size_t index, double value ){
+void PrimitiveList::setDouble( std::size_t index, double value )
+ throw( IndexOutOfBoundsException ){
+
PrimitiveValueNode node;
node.setDouble( value );
@@ -167,14 +180,16 @@
////////////////////////////////////////////////////////////////////////////////
float PrimitiveList::getFloat( std::size_t index ) const
- throw( IndexOutOfBoundsException ){
+ throw( IndexOutOfBoundsException, NoSuchElementException ){
PrimitiveValueNode node = this->get( index );
return node.getFloat();
}
////////////////////////////////////////////////////////////////////////////////
-void PrimitiveList::setFloat( std::size_t index, float value ){
+void PrimitiveList::setFloat( std::size_t index, float value )
+ throw( IndexOutOfBoundsException ){
+
PrimitiveValueNode node;
node.setFloat( value );
@@ -183,14 +198,16 @@
////////////////////////////////////////////////////////////////////////////////
string PrimitiveList::getString( std::size_t index ) const
- throw( IndexOutOfBoundsException ){
+ throw( IndexOutOfBoundsException, NoSuchElementException ){
PrimitiveValueNode node = this->get( index );
return node.getString();
}
////////////////////////////////////////////////////////////////////////////////
-void PrimitiveList::setString( std::size_t index, const string& value ){
+void PrimitiveList::setString( std::size_t index, const string& value )
+ throw( IndexOutOfBoundsException ){
+
PrimitiveValueNode node;
node.setString( value );
@@ -199,7 +216,7 @@
////////////////////////////////////////////////////////////////////////////////
std::vector<unsigned char> PrimitiveList::getByteArray( std::size_t index )
const
- throw( decaf::lang::exceptions::IndexOutOfBoundsException ) {
+ throw( IndexOutOfBoundsException, NoSuchElementException ) {
PrimitiveValueNode node = this->get( index );
return node.getByteArray();
@@ -207,7 +224,8 @@
////////////////////////////////////////////////////////////////////////////////
void PrimitiveList::setByteArray( std::size_t index,
- const std::vector<unsigned char>& value ) {
+ const std::vector<unsigned char>& value )
+ throw( IndexOutOfBoundsException ){
PrimitiveValueNode node;
node.setByteArray( value );
Modified: activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveList.h
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveList.h?rev=662058&r1=662057&r2=662058&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveList.h
(original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveList.h Sat May
31 11:17:57 2008
@@ -52,44 +52,64 @@
std::string toString() const;
virtual bool getBool( std::size_t index ) const
+ throw( decaf::lang::exceptions::IndexOutOfBoundsException,
+ decaf::lang::exceptions::NoSuchElementException );
+ virtual void setBool( std::size_t index, bool value )
throw( decaf::lang::exceptions::IndexOutOfBoundsException );
- virtual void setBool( std::size_t index, bool value );
virtual unsigned char getByte( std::size_t index ) const
+ throw( decaf::lang::exceptions::IndexOutOfBoundsException,
+ decaf::lang::exceptions::NoSuchElementException );
+ virtual void setByte( std::size_t index, unsigned char value )
throw( decaf::lang::exceptions::IndexOutOfBoundsException );
- virtual void setByte( std::size_t index, unsigned char value );
virtual char getChar( std::size_t index ) const
+ throw( decaf::lang::exceptions::IndexOutOfBoundsException,
+ decaf::lang::exceptions::NoSuchElementException );
+ virtual void setChar( std::size_t index, char value )
throw( decaf::lang::exceptions::IndexOutOfBoundsException );
- virtual void setChar( std::size_t index, char value );
virtual short getShort( std::size_t index ) const
+ throw( decaf::lang::exceptions::IndexOutOfBoundsException,
+ decaf::lang::exceptions::NoSuchElementException );
+ virtual void setShort( std::size_t index, short value )
throw( decaf::lang::exceptions::IndexOutOfBoundsException );
- virtual void setShort( std::size_t index, short value );
virtual int getInt( std::size_t index ) const
+ throw( decaf::lang::exceptions::IndexOutOfBoundsException,
+ decaf::lang::exceptions::NoSuchElementException );
+ virtual void setInt( std::size_t index, int value )
throw( decaf::lang::exceptions::IndexOutOfBoundsException );
- virtual void setInt( std::size_t index, int value );
virtual long long getLong( std::size_t index ) const
+ throw( decaf::lang::exceptions::IndexOutOfBoundsException,
+ decaf::lang::exceptions::NoSuchElementException );
+ virtual void setLong( std::size_t index, long long value )
throw( decaf::lang::exceptions::IndexOutOfBoundsException );
- virtual void setLong( std::size_t index, long long value );
virtual double getDouble( std::size_t index ) const
+ throw( decaf::lang::exceptions::IndexOutOfBoundsException,
+ decaf::lang::exceptions::NoSuchElementException );
+ virtual void setDouble( std::size_t index, double value )
throw( decaf::lang::exceptions::IndexOutOfBoundsException );
- virtual void setDouble( std::size_t index, double value );
virtual float getFloat( std::size_t index ) const
+ throw( decaf::lang::exceptions::IndexOutOfBoundsException,
+ decaf::lang::exceptions::NoSuchElementException );
+ virtual void setFloat( std::size_t index, float value )
throw( decaf::lang::exceptions::IndexOutOfBoundsException );
- virtual void setFloat( std::size_t index, float value );
virtual std::string getString( std::size_t index ) const
+ throw( decaf::lang::exceptions::IndexOutOfBoundsException,
+ decaf::lang::exceptions::NoSuchElementException );
+ virtual void setString( std::size_t index, const std::string& value )
throw( decaf::lang::exceptions::IndexOutOfBoundsException );
- virtual void setString( std::size_t index, const std::string& value );
virtual std::vector<unsigned char> getByteArray( std::size_t index )
const
+ throw( decaf::lang::exceptions::IndexOutOfBoundsException,
+ decaf::lang::exceptions::NoSuchElementException );
+ virtual void setByteArray( std::size_t index, const
std::vector<unsigned char>& value )
throw( decaf::lang::exceptions::IndexOutOfBoundsException );
- virtual void setByteArray( std::size_t index, const
std::vector<unsigned char>& value );
};
Modified:
activemq/activemq-cpp/trunk/src/test/activemq/util/PrimitiveListTest.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/util/PrimitiveListTest.cpp?rev=662058&r1=662057&r2=662058&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/util/PrimitiveListTest.cpp
(original)
+++ activemq/activemq-cpp/trunk/src/test/activemq/util/PrimitiveListTest.cpp
Sat May 31 11:17:57 2008
@@ -26,68 +26,77 @@
PrimitiveList plist;
- try{
- plist.getBool( 0 );
- CPPUNIT_ASSERT( false );
- } catch( decaf::lang::exceptions::NoSuchElementException& e ){}
- plist.setBool( 0, true );
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should Throw IndexOutOfBoundsException",
+ plist.getBool( 0 ),
+ decaf::lang::exceptions::IndexOutOfBoundsException );
+
+ plist.add( true );
CPPUNIT_ASSERT( plist.getBool(0) == true );
- plist.setBool( 1, false );
+ plist.add( false );
CPPUNIT_ASSERT( plist.getBool(1) == false );
- try{
- plist.getByte( 0 );
- CPPUNIT_ASSERT( false );
- } catch( decaf::lang::exceptions::NoSuchElementException& e ){}
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should Throw NoSuchElementException",
+ plist.getByte( 0 ),
+ decaf::lang::exceptions::NoSuchElementException );
+
plist.setByte( 0, 1 );
CPPUNIT_ASSERT( plist.getByte(0) == 1 );
- try{
- plist.getChar( 0 );
- CPPUNIT_ASSERT( false );
- } catch( decaf::lang::exceptions::NoSuchElementException& e ){}
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should Throw NoSuchElementException",
+ plist.getChar( 0 ),
+ decaf::lang::exceptions::NoSuchElementException );
+
plist.setChar( 0, 'a' );
CPPUNIT_ASSERT( plist.getChar(0) == 'a' );
- try{
- plist.getShort( 0 );
- CPPUNIT_ASSERT( false );
- } catch( decaf::lang::exceptions::NoSuchElementException& e ){}
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should Throw NoSuchElementException",
+ plist.getShort( 0 ),
+ decaf::lang::exceptions::NoSuchElementException );
+
plist.setShort( 0, 2 );
CPPUNIT_ASSERT( plist.getShort(0) == 2 );
- try{
- plist.getInt( 0 );
- CPPUNIT_ASSERT( false );
- } catch( decaf::lang::exceptions::NoSuchElementException& e ){}
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should Throw NoSuchElementException",
+ plist.getInt( 0 ),
+ decaf::lang::exceptions::NoSuchElementException );
+
plist.setInt( 0, 3 );
CPPUNIT_ASSERT( plist.getInt(0) == 3 );
- try{
- plist.getLong( 0 );
- CPPUNIT_ASSERT( false );
- } catch( decaf::lang::exceptions::NoSuchElementException& e ){}
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should Throw NoSuchElementException",
+ plist.getLong( 0 ),
+ decaf::lang::exceptions::NoSuchElementException );
+
plist.setLong( 0, 4L );
CPPUNIT_ASSERT( plist.getLong(0) == 4L );
- try{
- plist.getDouble( 0 );
- CPPUNIT_ASSERT( false );
- } catch( decaf::lang::exceptions::NoSuchElementException& e ){}
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should Throw NoSuchElementException",
+ plist.getDouble( 0 ),
+ decaf::lang::exceptions::NoSuchElementException );
+
plist.setDouble( 0, 2.3 );
CPPUNIT_ASSERT( plist.getDouble(0) == 2.3 );
- try{
- plist.getFloat( 0 );
- CPPUNIT_ASSERT( false );
- } catch( decaf::lang::exceptions::NoSuchElementException& e ){}
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should Throw NoSuchElementException",
+ plist.getFloat( 0 ),
+ decaf::lang::exceptions::NoSuchElementException );
+
plist.setFloat( 0, 3.2f );
CPPUNIT_ASSERT( plist.getFloat(0) == 3.2f );
- try{
- plist.getString( 0 );
- CPPUNIT_ASSERT( false );
- } catch( decaf::lang::exceptions::NoSuchElementException& e ){}
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should Throw NoSuchElementException",
+ plist.getString( 0 ),
+ decaf::lang::exceptions::NoSuchElementException );
+
plist.setString( 0, "hello" );
CPPUNIT_ASSERT( plist.getString(0) == "hello" );
@@ -97,37 +106,43 @@
byteArray.push_back( 'c' );
byteArray.push_back( 'd' );
- try{
- plist.getByteArray( 0 );
- CPPUNIT_ASSERT( false );
- } catch( decaf::lang::exceptions::NoSuchElementException& e ){}
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should Throw NoSuchElementException",
+ plist.getByteArray( 0 ),
+ decaf::lang::exceptions::NoSuchElementException );
+
plist.setByteArray( 0, byteArray );
CPPUNIT_ASSERT( plist.getByteArray(0) == byteArray );
-
}
void PrimitiveListTest::testRemove(){
PrimitiveList plist;
- plist.setInt( 0, 5 );
- plist.setFloat( 1, 5.5f );
- plist.setInt( 2, 6 );
+ plist.add( 5 );
+ plist.add( 5.5f );
+ plist.add( 6 );
+ plist.remove( 0 );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should Throw NoSuchElementException",
+ plist.getInt( 0 ),
+ decaf::lang::exceptions::NoSuchElementException );
+
+ plist.remove( 0 );
plist.remove( 0 );
- try{
- plist.getInt(0);
- CPPUNIT_ASSERT( false );
- } catch( decaf::lang::exceptions::NoSuchElementException& e ){}
+
+ CPPUNIT_ASSERT( plist.isEmpty() );
}
void PrimitiveListTest::testCount(){
PrimitiveList plist;
CPPUNIT_ASSERT( plist.size() == 0 );
- plist.setInt( 0, 5 );
+ plist.add( 5 );
CPPUNIT_ASSERT( plist.size() == 1);
- plist.setFloat( 1, 5.5f );
+ plist.add( 5.5f );
CPPUNIT_ASSERT( plist.size() == 2 );
- plist.setInt( 2, 6 );
+ plist.add( 6 );
CPPUNIT_ASSERT( plist.size() == 3 );
plist.remove( 0 );
CPPUNIT_ASSERT( plist.size() == 2 );
@@ -138,9 +153,9 @@
void PrimitiveListTest::testCopy(){
PrimitiveList plist;
- plist.setInt( 0, 5 );
- plist.setFloat( 1, 5.5f );
- plist.setInt( 2, 6 );
+ plist.add( 5 );
+ plist.add( 5.5f );
+ plist.add( 6 );
PrimitiveList copy;
copy.copy( plist );
@@ -153,44 +168,44 @@
void PrimitiveListTest::testClear(){
PrimitiveList plist;
- plist.setInt( 0, 5 );
- plist.setFloat( 1, 5.5f );
- plist.setInt( 2, 6 );
+ plist.add( 5 );
+ plist.add( 5.5f );
+ plist.add( 6 );
plist.clear();
CPPUNIT_ASSERT( plist.size() == 0 );
- try{
- plist.getInt( 0 );
- CPPUNIT_ASSERT( false );
- } catch( decaf::lang::exceptions::NoSuchElementException& e ){}
-
- try{
- plist.getFloat( 1 );
- CPPUNIT_ASSERT( false );
- } catch( decaf::lang::exceptions::NoSuchElementException& e ){}
-
- try{
- plist.getInt( 2 );
- CPPUNIT_ASSERT( false );
- } catch( decaf::lang::exceptions::NoSuchElementException& e ){}
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should Throw IndexOutOfBoundsException",
+ plist.getInt( 0 ),
+ decaf::lang::exceptions::IndexOutOfBoundsException );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should Throw IndexOutOfBoundsException",
+ plist.getFloat( 1 ),
+ decaf::lang::exceptions::IndexOutOfBoundsException );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should Throw IndexOutOfBoundsException",
+ plist.getInt( 2 ),
+ decaf::lang::exceptions::IndexOutOfBoundsException );
}
void PrimitiveListTest::testContains(){
PrimitiveList plist;
-// CPPUNIT_ASSERT( plist.contains("int") == false );
-//
-// plist.setInt("int", 5 );
-// CPPUNIT_ASSERT( plist.contains("int") == true );
-//
-// plist.setFloat( "float", 5.5f );
-// CPPUNIT_ASSERT( plist.contains("float") == true );
-//
-// plist.setInt("int2", 6 );
-// CPPUNIT_ASSERT( plist.contains("int2") == true );
-//
-// plist.remove("int");
-// CPPUNIT_ASSERT( plist.contains("int") == false );
+ CPPUNIT_ASSERT( plist.contains( 255 ) == false );
+
+ plist.add( 5 );
+ CPPUNIT_ASSERT( plist.contains( 5 ) == true );
+
+ plist.add( 5.5f );
+ CPPUNIT_ASSERT( plist.contains( 5.5f ) == true );
+
+ plist.add( 6 );
+ CPPUNIT_ASSERT( plist.contains( 6 ) == true );
+
+ plist.remove( PrimitiveValueNode(5) );
+ CPPUNIT_ASSERT( plist.contains( 5 ) == false );
}
Modified: activemq/activemq-cpp/trunk/src/test/activemq/util/PrimitiveListTest.h
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/util/PrimitiveListTest.h?rev=662058&r1=662057&r2=662058&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/util/PrimitiveListTest.h
(original)
+++ activemq/activemq-cpp/trunk/src/test/activemq/util/PrimitiveListTest.h Sat
May 31 11:17:57 2008
@@ -29,12 +29,12 @@
class PrimitiveListTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( PrimitiveListTest );
-// CPPUNIT_TEST( testSetGet );
-// CPPUNIT_TEST( testRemove );
-// CPPUNIT_TEST( testCount );
-// CPPUNIT_TEST( testClear );
-// CPPUNIT_TEST( testCopy );
-// CPPUNIT_TEST( testContains );
+ CPPUNIT_TEST( testSetGet );
+ CPPUNIT_TEST( testRemove );
+ CPPUNIT_TEST( testCount );
+ CPPUNIT_TEST( testClear );
+ CPPUNIT_TEST( testCopy );
+ CPPUNIT_TEST( testContains );
CPPUNIT_TEST_SUITE_END();
public: