activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r560336 - in /activemq/activemq-cpp/trunk/src/decaf/src: main/decaf/lang/Short.cpp test/decaf/lang/ShortTest.cpp
Date Fri, 27 Jul 2007 17:50:49 GMT
Author: tabish
Date: Fri Jul 27 10:50:47 2007
New Revision: 560336

URL: http://svn.apache.org/viewvc?view=rev&rev=560336
Log:
http://issues.apache.org/activemq/browse/AMQCPP-103

Implementing the Primitive Wrappers fully

Modified:
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Short.cpp
    activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/lang/ShortTest.cpp

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Short.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Short.cpp?view=diff&rev=560336&r1=560335&r2=560336
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Short.cpp (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Short.cpp Fri Jul 27 10:50:47
2007
@@ -17,6 +17,8 @@
 
 #include "Short.h"
 
+#include <sstream>
+
 using namespace decaf;
 using namespace decaf::lang;
 
@@ -37,14 +39,14 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 std::string Short::toString() const {
-    // TODO
-    return "";
+    return toString( this->value );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 std::string Short::toString( short value ) {
-    // TODO
-    return "";
+    std::ostringstream oss;
+    oss << value;
+    return oss.str();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -71,13 +73,8 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 short Short::reverseBytes( short value ) {
-
     short temp = value;
-
-    // TODO
-    //temp += ( value & 0xF0 ) >> 8;
-    //temp += ( value & 0x0F ) << 8;
-
+    temp = ( ( value & 0xFF00 ) >> 8 ) | ( ( value & 0x00FF ) << 8 );
     return temp;
 }
 

Modified: activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/lang/ShortTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/lang/ShortTest.cpp?view=diff&rev=560336&r1=560335&r2=560336
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/lang/ShortTest.cpp (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/lang/ShortTest.cpp Fri Jul 27 10:50:47
2007
@@ -37,8 +37,13 @@
     CPPUNIT_ASSERT( short1.floatValue() == 65.0f );
     CPPUNIT_ASSERT( short1.doubleValue() == 65.0 );
 
-    //CPPUNIT_ASSERT( short1.toString() == "65" );
-    //CPPUNIT_ASSERT( short1.toString( 99 ) == "99" );
+    CPPUNIT_ASSERT( short1.toString() == "65" );
+    CPPUNIT_ASSERT( short1.toString( 99 ) == "99" );
+
+    CPPUNIT_ASSERT( Short::reverseBytes( (short)0xFF00 ) == (short)0x00FF );
+    CPPUNIT_ASSERT( Short::reverseBytes( (short)0x0F00 ) == (short)0x000F );
+    CPPUNIT_ASSERT( Short::reverseBytes( (short)0xDE00 ) == (short)0x00DE );
+    CPPUNIT_ASSERT( Short::reverseBytes( (short)0x00AB ) == (short)0xAB00 );
 
 }
 



Mime
View raw message