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/08/02 20:44:29 UTC
svn commit: r562219 - in /activemq/activemq-cpp/trunk/src/decaf/src:
main/decaf/lang/Integer.h test/decaf/lang/IntegerTest.cpp
test/decaf/lang/IntegerTest.h
Author: tabish
Date: Thu Aug 2 11:44:28 2007
New Revision: 562219
URL: http://svn.apache.org/viewvc?view=rev&rev=562219
Log:
http://issues.apache.org/activemq/browse/AMQCPP-103
Adding in more Types wrappers
Modified:
activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Integer.h
activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/lang/IntegerTest.cpp
activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/lang/IntegerTest.h
Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Integer.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Integer.h?view=diff&rev=562219&r1=562218&r2=562219
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Integer.h (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Integer.h Thu Aug 2 11:44:28 2007
@@ -228,8 +228,8 @@
* the second argument. The characters in the string must all be digits,
* of the specified radix (as determined by whether
* Character.digit(char, int) returns a nonnegative value) except that the
- * first character may be an ASCII minus sign '-' ('\u002D') to indicate
- * a negative value. The resulting byte value is returned.
+ * first character may be an ASCII minus sign '-' to indicate a negative
+ * value. The resulting byte value is returned.
*
* An exception of type NumberFormatException is thrown if any of the
* following situations occurs:
@@ -325,12 +325,12 @@
* Character.MAX_RADIX, then the radix 10 is used instead.
*
* If the first argument is negative, the first element of the result is
- * the ASCII minus character '-' ('\u002D'). If the first argument is not
+ * the ASCII minus character '-'. If the first argument is not
* negative, no sign character appears in the result.
*
* The remaining characters of the result represent the magnitude of the
* first argument. If the magnitude is zero, it is represented by a single
- * zero character '0' ('\u0030'); otherwise, the first character of the
+ * zero character '0'; otherwise, the first character of the
* representation of the magnitude will not be the zero character. The
* following ASCII characters are used as digits:
*
Modified: activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/lang/IntegerTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/lang/IntegerTest.cpp?view=diff&rev=562219&r1=562218&r2=562219
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/lang/IntegerTest.cpp (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/lang/IntegerTest.cpp Thu Aug 2 11:44:28 2007
@@ -21,6 +21,7 @@
using namespace decaf;
using namespace decaf::lang;
+////////////////////////////////////////////////////////////////////////////////
void IntegerTest::test(void)
{
int x = Integer::parseInt("12");
@@ -39,4 +40,70 @@
CPPUNIT_ASSERT( y1 == "255" );
CPPUNIT_ASSERT( z1 == "42" );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void IntegerTest::test2() {
+ Integer integer( 255 );
+
+ // Test cast functions
+ CPPUNIT_ASSERT( integer.byteValue() == 255 );
+ CPPUNIT_ASSERT( integer.shortValue() == 255 );
+ CPPUNIT_ASSERT( integer.intValue() == 255 );
+ CPPUNIT_ASSERT( integer.longValue() == 255 );
+ CPPUNIT_ASSERT( integer.floatValue() == 255.0f );
+ CPPUNIT_ASSERT( integer.doubleValue() == 255.0 );
+
+ // Comparison functions
+ CPPUNIT_ASSERT( integer.compareTo( 256 ) == -1 );
+ CPPUNIT_ASSERT( integer.compareTo( 255 ) == 0 );
+ CPPUNIT_ASSERT( integer.compareTo( 254 ) == 1 );
+ CPPUNIT_ASSERT( integer.equals( Integer( 255 ) ) == true );
+ CPPUNIT_ASSERT( integer.compareTo( Integer( 255 ) ) == 0 );
+ CPPUNIT_ASSERT( integer == Integer( 255 ) );
+
+ // decode
+ CPPUNIT_ASSERT( integer == Integer::decode( "255" ) );
+ CPPUNIT_ASSERT( integer == Integer::decode( "0xFF" ) );
+ CPPUNIT_ASSERT( integer == Integer::decode( "255" ) );
+ CPPUNIT_ASSERT( Integer::decode( "-255" ) == -255 );
+
+ // reverseBytes
+ CPPUNIT_ASSERT( (int)0xFF000000 == Integer::reverseBytes( 255 ) );
+
+ // reverse
+ CPPUNIT_ASSERT( Integer::reverse( Integer::reverse( 255 ) ) == 255 );
+
+ // parseInt
+ CPPUNIT_ASSERT( Integer::parseInt( "255") == 255 );
+ CPPUNIT_ASSERT( Integer::parseInt( "255", 10 ) == 255 );
+ CPPUNIT_ASSERT( Integer::parseInt( "255", 11 ) != 255 );
+ CPPUNIT_ASSERT( Integer::parseInt( "FF", 16 ) == 255 );
+
+ // valueOf
+ CPPUNIT_ASSERT( Integer::valueOf( 255 ) == 255 );
+ CPPUNIT_ASSERT( Integer::valueOf( "255" ) == 255 );
+ CPPUNIT_ASSERT( Integer::valueOf( "255", 10 ) == 255 );
+ CPPUNIT_ASSERT( (Integer::valueOf( "255", 11 )).intValue() != 255 );
+ CPPUNIT_ASSERT( Integer::valueOf( "FF", 16 ) == 255 );
+
+ // bitCount
+ CPPUNIT_ASSERT( Integer::bitCount( 255 ) == 8 );
+ CPPUNIT_ASSERT( Integer::bitCount( 0xFFFFFFFF ) == 32 );
+
+ //toXXXString
+ CPPUNIT_ASSERT( Integer::toString( 255 ) == "255" );
+ CPPUNIT_ASSERT( Integer::toString( 255, 16 ) == "ff" );
+ CPPUNIT_ASSERT( Integer::toHexString( 255 ) == "ff" );
+ CPPUNIT_ASSERT( Integer::toOctalString( 255 ) == "377" );
+ CPPUNIT_ASSERT( Integer::toBinaryString( 255 ) == "11111111" );
+ CPPUNIT_ASSERT( Integer::toString( 255255 ) == "255255" );
+
+ // highestOneBit
+ CPPUNIT_ASSERT( Integer::highestOneBit( 255 ) == 128 );
+ CPPUNIT_ASSERT( Integer::highestOneBit( 0xFF000000 ) == (int)0x80000000 );
+
+ // lowestOneBit
+ CPPUNIT_ASSERT( Integer::lowestOneBit( 255 ) == 1 );
+ CPPUNIT_ASSERT( Integer::lowestOneBit( 0xFF000000 ) == (int)0x01000000 );
}
Modified: activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/lang/IntegerTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/lang/IntegerTest.h?view=diff&rev=562219&r1=562218&r2=562219
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/lang/IntegerTest.h (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/lang/IntegerTest.h Thu Aug 2 11:44:28 2007
@@ -30,6 +30,7 @@
{
CPPUNIT_TEST_SUITE( IntegerTest );
CPPUNIT_TEST( test );
+ CPPUNIT_TEST( test2 );
CPPUNIT_TEST_SUITE_END();
public:
@@ -37,7 +38,8 @@
IntegerTest(void) {}
virtual ~IntegerTest(void) {}
- virtual void test(void);
+ virtual void test();
+ virtual void test2();
};