diff options
Diffstat (limited to 'cpp/test/Ice/stream/Client.cpp')
-rwxr-xr-x | cpp/test/Ice/stream/Client.cpp | 457 |
1 files changed, 0 insertions, 457 deletions
diff --git a/cpp/test/Ice/stream/Client.cpp b/cpp/test/Ice/stream/Client.cpp index a2434f6b0ff..ac6c9b08399 100755 --- a/cpp/test/Ice/stream/Client.cpp +++ b/cpp/test/Ice/stream/Client.cpp @@ -22,14 +22,6 @@ using namespace std; -#if defined(_MSC_VER) && (_MSC_VER < 1300) // COMPILERBUG -// -// VC++ 6 compiler bugs doesn't allow using templates for the Stream API. -// -// see: http://support.microsoft.com/kb/240866 -// http://support.microsoft.com/kb/241569 -// -#else class TestObjectWriter : public Ice::ObjectWriter { public: @@ -158,38 +150,18 @@ public: { } }; -#endif int run(int argc, char** argv, const Ice::CommunicatorPtr& communicator) { -#if defined(_MSC_VER) && (_MSC_VER < 1300) -// -// VC++ 6 compiler bugs doesn't allow to write -// the Stream API using c++ templates. -// -// see: http://support.microsoft.com/kb/240866 -// http://support.microsoft.com/kb/241569 -// -#else MyClassFactoryWrapperPtr factoryWrapper = new MyClassFactoryWrapper; communicator->addObjectFactory(factoryWrapper, Test::MyClass::ice_staticId()); communicator->addObjectFactory(new MyInterfaceFactory, Test::MyInterface::ice_staticId()); -#endif Ice::InputStreamPtr in; Ice::OutputStreamPtr out; vector<Ice::Byte> data; -#if defined(_MSC_VER) && (_MSC_VER < 1300) -// -// VC++ 6 compiler bugs doesn't allow to write -// the Stream API using c++ templates. -// -// see: http://support.microsoft.com/kb/240866 -// http://support.microsoft.com/kb/241569 -// -#else // // Test the new stream api. // @@ -1086,435 +1058,6 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator) } cout << "ok" << endl; - -#endif - - // - // Test the old stream api. - // - - cout << "testing primitive types... " << flush; - - { - vector<Ice::Byte> byte; - in = Ice::createInputStream(communicator, byte); - } - - { - out = Ice::createOutputStream(communicator); - out->startEncapsulation(); - out->writeBool(true); - out->endEncapsulation(); - out->finished(data); - out = 0; - - in = Ice::createInputStream(communicator, data); - in->startEncapsulation(); - test(in->readBool()); - in->endEncapsulation(); - } - - { - vector<Ice::Byte> byte; - in = Ice::createInputStream(communicator, byte); - try - { - in->readBool(); - test(false); - } - catch(const Ice::UnmarshalOutOfBoundsException&) - { - } - } - - { - out = Ice::createOutputStream(communicator); - out->writeBool(true); - out->finished(data); - in = Ice::createInputStream(communicator, data); - test(in->readBool()); - } - - { - out = Ice::createOutputStream(communicator); - out->writeByte(1); - out->finished(data); - in = Ice::createInputStream(communicator, data); - test(in->readByte() == 1); - } - - { - out = Ice::createOutputStream(communicator); - out->writeShort(2); - out->finished(data); - in = Ice::createInputStream(communicator, data); - test(in->readShort() == 2); - } - - { - out = Ice::createOutputStream(communicator); - out->writeInt(3); - out->finished(data); - in = Ice::createInputStream(communicator, data); - test(in->readInt() == 3); - } - - { - out = Ice::createOutputStream(communicator); - out->writeLong(4); - out->finished(data); - in = Ice::createInputStream(communicator, data); - test(in->readLong() == 4); - } - - { - out = Ice::createOutputStream(communicator); - out->writeFloat(5.0); - out->finished(data); - in = Ice::createInputStream(communicator, data); - test(in->readFloat() == 5.0); - } - - { - out = Ice::createOutputStream(communicator); - out->writeDouble(6.0); - out->finished(data); - in = Ice::createInputStream(communicator, data); - test(in->readDouble() == 6.0); - } - - { - out = Ice::createOutputStream(communicator); - out->writeString("hello world"); - out->finished(data); - in = Ice::createInputStream(communicator, data); - test(in->readString() == "hello world"); - } - - cout << "ok" << endl; -#if defined(_MSC_VER) && (_MSC_VER < 1300) -// -// VC++ 6 compiler bugs doesn't allow to write -// the Stream API using c++ templates. -// -// see: http://support.microsoft.com/kb/240866 -// http://support.microsoft.com/kb/241569 -// -#else - cout << "testing constructed types... " << flush; - - { - out = Ice::createOutputStream(communicator); - Test::ice_writeMyEnum(out, Test::enum3); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Test::MyEnum e; - Test::ice_readMyEnum(in, e); - test(e == Test::enum3); - } - - { - out = Ice::createOutputStream(communicator); - Test::SmallStruct s; - s.bo = true; - s.by = 1; - s.sh = 2; - s.i = 3; - s.l = 4; - s.f = 5.0; - s.d = 6.0; - s.str = "7"; - s.e = Test::enum2; - s.p = Test::MyClassPrx::uncheckedCast(communicator->stringToProxy("test:default")); - Test::ice_writeSmallStruct(out, s); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Test::SmallStruct s2; - Test::ice_readSmallStruct(in, s2); - test(s2 == s); - } - - { - out = Ice::createOutputStream(communicator); - Test::ClassStructPtr s = new Test::ClassStruct(); - s->i = 10; - Test::ice_writeClassStruct(out, s); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Test::ClassStructPtr s2 = new Test::ClassStruct(); - Test::ice_readClassStruct(in, s2); - test(s2->i == s->i); - } -#endif - { - Ice::BoolSeq arr; - arr.push_back(true); - arr.push_back(false); - arr.push_back(true); - arr.push_back(false); - - out = Ice::createOutputStream(communicator); - out->writeBoolSeq(arr); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Ice::BoolSeq arr2 = in->readBoolSeq(); - test(arr2 == arr); - } - - { - Ice::ByteSeq arr; - arr.push_back(0x01); - arr.push_back(0x11); - arr.push_back(0x12); - arr.push_back(0x22); - - out = Ice::createOutputStream(communicator); - out->writeByteSeq(arr); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Ice::ByteSeq arr2 = in->readByteSeq(); - test(arr2 == arr); - } - - { - Ice::ShortSeq arr; - arr.push_back(0x01); - arr.push_back(0x11); - arr.push_back(0x12); - arr.push_back(0x22); - out = Ice::createOutputStream(communicator); - out->writeShortSeq(arr); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Ice::ShortSeq arr2 = in->readShortSeq(); - test(arr2 == arr); - } - - { - Ice::IntSeq arr; - arr.push_back(0x01); - arr.push_back(0x11); - arr.push_back(0x12); - arr.push_back(0x22); - out = Ice::createOutputStream(communicator); - out->writeIntSeq(arr); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Ice::IntSeq arr2 = in->readIntSeq(); - test(arr2 == arr); - } - - { - Ice::LongSeq arr; - arr.push_back(0x01); - arr.push_back(0x11); - arr.push_back(0x12); - arr.push_back(0x22); - out = Ice::createOutputStream(communicator); - out->writeLongSeq(arr); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Ice::LongSeq arr2 = in->readLongSeq(); - test(arr2 == arr); - } - - { - Ice::FloatSeq arr; - arr.push_back(1); - arr.push_back(2); - arr.push_back(3); - arr.push_back(4); - out = Ice::createOutputStream(communicator); - out->writeFloatSeq(arr); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Ice::FloatSeq arr2 = in->readFloatSeq(); - test(arr2 == arr); - } - - { - Ice::DoubleSeq arr; - arr.push_back(1); - arr.push_back(2); - arr.push_back(3); - arr.push_back(4); - out = Ice::createOutputStream(communicator); - out->writeDoubleSeq(arr); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Ice::DoubleSeq arr2 = in->readDoubleSeq(); - test(arr2 == arr); - } - - { - Ice::StringSeq arr; - arr.push_back("string1"); - arr.push_back("string2"); - arr.push_back("string3"); - arr.push_back("string4"); - out = Ice::createOutputStream(communicator); - out->writeStringSeq(arr); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Ice::StringSeq arr2 = in->readStringSeq(); - test(arr2 == arr); - } -#if defined(_MSC_VER) && (_MSC_VER < 1300) -// -// VC++ 6 compiler bugs doesn't allow to write -// the Stream API using c++ templates. -// -// see: http://support.microsoft.com/kb/240866 -// http://support.microsoft.com/kb/241569 -// -#else - { - Test::MyEnumS arr; - arr.push_back(Test::enum3); - arr.push_back(Test::enum2); - arr.push_back(Test::enum1); - arr.push_back(Test::enum2); - - out = Ice::createOutputStream(communicator); - Test::ice_writeMyEnumS(out, arr); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Test::MyEnumS arr2; - Test::ice_readMyEnumS(in, arr2); - test(arr2 == arr); - } - - { - Test::MyClassS arr; - for(int i = 0; i < 4; ++i) - { - Test::MyClassPtr c = new Test::MyClass; - c->c = c; - c->o = c; - c->s.e = Test::enum2; - - c->seq1.push_back(true); - c->seq1.push_back(false); - c->seq1.push_back(true); - c->seq1.push_back(false); - - c->seq2.push_back(1); - c->seq2.push_back(2); - c->seq2.push_back(3); - c->seq2.push_back(4); - - c->seq3.push_back(1); - c->seq3.push_back(2); - c->seq3.push_back(3); - c->seq3.push_back(4); - - c->seq4.push_back(1); - c->seq4.push_back(2); - c->seq4.push_back(3); - c->seq4.push_back(4); - - c->seq5.push_back(1); - c->seq5.push_back(2); - c->seq5.push_back(3); - c->seq5.push_back(4); - - c->seq6.push_back(1); - c->seq6.push_back(2); - c->seq6.push_back(3); - c->seq6.push_back(4); - - c->seq7.push_back(1); - c->seq7.push_back(2); - c->seq7.push_back(3); - c->seq7.push_back(4); - - c->seq8.push_back("string1"); - c->seq8.push_back("string2"); - c->seq8.push_back("string3"); - c->seq8.push_back("string4"); - - c->seq9.push_back(Test::enum3); - c->seq9.push_back(Test::enum2); - c->seq9.push_back(Test::enum1); - - c->d["hi"] = c; - } - out = Ice::createOutputStream(communicator); - Test::ice_writeMyClassS(out, arr); - out->writePendingObjects(); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Test::MyClassS arr2; - Test::ice_readMyClassS(in, arr2); - in->readPendingObjects(); - test(arr2.size() == arr.size()); - for(Test::MyClassS::size_type j = 0; j < arr2.size(); ++j) - { - test(arr2[j]); - test(arr2[j]->c == arr2[j]); - test(arr2[j]->o == arr2[j]); - test(arr2[j]->s.e == Test::enum2); - test(arr2[j]->seq1 == arr[j]->seq1); - test(arr2[j]->seq2 == arr[j]->seq2); - test(arr2[j]->seq3 == arr[j]->seq3); - test(arr2[j]->seq4 == arr[j]->seq4); - test(arr2[j]->seq5 == arr[j]->seq5); - test(arr2[j]->seq6 == arr[j]->seq6); - test(arr2[j]->seq7 == arr[j]->seq7); - test(arr2[j]->seq8 == arr[j]->seq8); - test(arr2[j]->seq9 == arr[j]->seq9); - test(arr2[j]->d["hi"] == arr2[j]); - } - } - - { - Test::MyInterfacePtr i = new Test::MyInterface(); - out = Ice::createOutputStream(communicator); - Test::ice_writeMyInterface(out, i); - out->writePendingObjects(); - out->finished(data); - in = Ice::createInputStream(communicator, data); - i = 0; - Test::ice_readMyInterface(in, i); - in->readPendingObjects(); - test(i); - } - - { - out = Ice::createOutputStream(communicator); - Test::MyClassPtr obj = new Test::MyClass; - obj->s.e = Test::enum2; - TestObjectWriterPtr writer = new TestObjectWriter(obj); - out->writeObject(writer); - out->writePendingObjects(); - out->finished(data); - test(writer->called); - } - - { - out = Ice::createOutputStream(communicator); - Test::MyClassPtr obj = new Test::MyClass; - obj->s.e = Test::enum2; - TestObjectWriterPtr writer = new TestObjectWriter(obj); - out->writeObject(writer); - out->writePendingObjects(); - out->finished(data); - test(writer->called); - factoryWrapper->setFactory(new TestObjectFactory); - in = Ice::createInputStream(communicator, data); - TestReadObjectCallbackPtr cb = new TestReadObjectCallback; - in->readObject(cb); - in->readPendingObjects(); - test(cb->obj); - TestObjectReaderPtr reader = TestObjectReaderPtr::dynamicCast(cb->obj); - test(reader); - test(reader->called); - test(reader->obj); - test(reader->obj->s.e == Test::enum2); - factoryWrapper->setFactory(0); - } - cout << "ok" << endl; -#endif return 0; } |