activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r902126 - /activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/DataInputStreamTest.cpp
Date Fri, 22 Jan 2010 15:39:02 GMT
Author: tabish
Date: Fri Jan 22 15:39:01 2010
New Revision: 902126

URL: http://svn.apache.org/viewvc?rev=902126&view=rev
Log:
Change the code to fix an "invalid read of size 1" in valgrind.

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/DataInputStreamTest.cpp

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/DataInputStreamTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/DataInputStreamTest.cpp?rev=902126&r1=902125&r2=902126&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/DataInputStreamTest.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/io/DataInputStreamTest.cpp Fri
Jan 22 15:39:01 2010
@@ -159,8 +159,14 @@
         std::vector<unsigned char> result;
         result.resize( testData.length() );
         is->readFully( result );
-        CPPUNIT_ASSERT_MESSAGE( "Incorrect data read",
-            string( (const char*)&result[0], 0, result.size() ) == testData );
+
+        string expected = "";
+        for( size_t ix = 0; ix < result.size(); ++ix ) {
+            expected += (char)result[ix];
+        }
+
+        CPPUNIT_ASSERT_MESSAGE("Incorrect data read", expected == testData );
+
     } catch( IOException &e ) {
         CPPUNIT_FAIL("IOException during readFully test : " + e.getMessage());
     }
@@ -175,8 +181,14 @@
         openDataInputStream();
         unsigned char* rbytes = new unsigned char[ testData.length() ];
         is->readFully( rbytes, 0, testData.length() );
-        CPPUNIT_ASSERT_MESSAGE("Incorrect data read",
-            string( (const char*)rbytes, 0, testData.length() ) == testData );
+
+        string expected = "";
+        for( size_t ix = 0; ix < testData.length(); ++ix ) {
+            expected += (char)rbytes[ix];
+        }
+
+        CPPUNIT_ASSERT_MESSAGE("Incorrect data read", expected == testData );
+
         delete [] rbytes;
     } catch( IOException &e ) {
         CPPUNIT_FAIL("IOException during readFully test : " + e.getMessage());



Mime
View raw message