activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r551573 - in /activemq/activemq-cpp/trunk/src/decaf/src/test/decaf: io/DataInputStreamTest.cpp io/DataInputStreamTest.h net/SocketFactoryTest.cpp net/SocketTest.cpp
Date Thu, 28 Jun 2007 14:24:50 GMT
Author: tabish
Date: Thu Jun 28 07:24:49 2007
New Revision: 551573

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

Building Decaf lib

Modified:
    activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/io/DataInputStreamTest.cpp
    activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/io/DataInputStreamTest.h
    activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/net/SocketFactoryTest.cpp
    activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/net/SocketTest.cpp

Modified: activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/io/DataInputStreamTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/io/DataInputStreamTest.cpp?view=diff&rev=551573&r1=551572&r2=551573
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/io/DataInputStreamTest.cpp (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/io/DataInputStreamTest.cpp Thu Jun
28 07:24:49 2007
@@ -109,3 +109,79 @@
     //std::cout << "char[2] Value = " << (int)arrayVal[2] << std::endl;
     CPPUNIT_ASSERT( arrayVal[2] == 'c' );
 }
+
+void DataInputStreamTest::testString() {
+
+    std::string data1 = "This is a Test";
+    std::string data2 = "of the readString method";
+    std::string data3 = "This one should fail";
+
+    std::vector<unsigned char> buffer;
+
+    buffer.insert( buffer.begin(), data1.begin(), data1.end() );
+    buffer.push_back( '\0' );
+    buffer.insert( buffer.end(), data2.begin(), data2.end() );
+    buffer.push_back( '\0' );
+    buffer.insert( buffer.end(), data3.begin(), data3.end() );
+
+    // Create the stream with the buffer we just wrote to.
+    ByteArrayInputStream myStream( buffer );
+    DataInputStream reader( &myStream );
+
+    std::string result1 = reader.readString();
+    std::string result2 = reader.readString();
+
+    CPPUNIT_ASSERT( result1 == data1 );
+    CPPUNIT_ASSERT( result2 == data2 );
+
+    try{
+        std::string result3 = reader.readString();
+        CPPUNIT_ASSERT( false );
+    } catch(...){
+        CPPUNIT_ASSERT( true );
+    }
+}
+
+void DataInputStreamTest::testUTF() {
+
+    std::string data1 = "This is a Test";
+    std::string data2 = "of the readString method";
+    std::string data3 = "This one should fail";
+
+    char sizeData[sizeof(short)] = {0};
+    short tempShort = 0;
+
+    std::vector<unsigned char> buffer;
+
+    tempShort = util::Endian::byteSwap( ((unsigned short)data1.size()) );
+    memcpy( sizeData, (char*)&tempShort, sizeof( short ) );
+    buffer.insert( buffer.end(), sizeData, sizeData + sizeof(short) );
+    buffer.insert( buffer.end(), data1.begin(), data1.end() );
+
+    tempShort = util::Endian::byteSwap( ((unsigned short)data2.size()) );
+    memcpy( sizeData, (char*)&tempShort, sizeof( short ) );
+    buffer.insert( buffer.end(), sizeData, sizeData + sizeof(short) );
+    buffer.insert( buffer.end(), data2.begin(), data2.end() );
+
+    tempShort = util::Endian::byteSwap( (unsigned short)(data3.size() + 10 ) );
+    memcpy( sizeData, (char*)&tempShort, sizeof( short ) );
+    buffer.insert( buffer.end(), sizeData, sizeData + sizeof(short) );
+    buffer.insert( buffer.end(), data3.begin(), data3.end() );
+
+    // Create the stream with the buffer we just wrote to.
+    ByteArrayInputStream myStream( buffer );
+    DataInputStream reader( &myStream );
+
+    std::string result1 = reader.readUTF();
+    std::string result2 = reader.readUTF();
+
+    CPPUNIT_ASSERT( result1 == data1 );
+    CPPUNIT_ASSERT( result2 == data2 );
+
+    try{
+        std::string result3 = reader.readUTF();
+        CPPUNIT_ASSERT( false );
+    } catch(...){
+        CPPUNIT_ASSERT( true );
+    }
+}

Modified: activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/io/DataInputStreamTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/io/DataInputStreamTest.h?view=diff&rev=551573&r1=551572&r2=551573
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/io/DataInputStreamTest.h (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/io/DataInputStreamTest.h Thu Jun
28 07:24:49 2007
@@ -40,6 +40,8 @@
 
         CPPUNIT_TEST_SUITE( DataInputStreamTest );
         CPPUNIT_TEST( test );
+        CPPUNIT_TEST( testString );
+        CPPUNIT_TEST( testUTF );
         CPPUNIT_TEST_SUITE_END();
 
     public:
@@ -49,6 +51,8 @@
         virtual void tearDown(){}
 
         void test();
+        void testString();
+        void testUTF();
 
     };
 

Modified: activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/net/SocketFactoryTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/net/SocketFactoryTest.cpp?view=diff&rev=551573&r1=551572&r2=551573
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/net/SocketFactoryTest.cpp (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/net/SocketFactoryTest.cpp Thu Jun
28 07:24:49 2007
@@ -17,7 +17,7 @@
 
 #include "SocketFactoryTest.h"
 
-CPPUNIT_TEST_SUITE_REGISTRATION( decaf::net::SocketFactoryTest );
+//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::net::SocketFactoryTest );
 
 #include <decaf/util/Properties.h>
 #include <decaf/net/SocketFactory.h>

Modified: activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/net/SocketTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/net/SocketTest.cpp?view=diff&rev=551573&r1=551572&r2=551573
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/net/SocketTest.cpp (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/net/SocketTest.cpp Thu Jun 28 07:24:49
2007
@@ -17,7 +17,7 @@
 
 #include "SocketTest.h"
 
-CPPUNIT_TEST_SUITE_REGISTRATION( decaf::net::SocketTest );
+//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::net::SocketTest );
 
 #include <decaf/net/TcpSocket.h>
 



Mime
View raw message