📄 alltests.cpp
字号:
// **********************************************************************//// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved.//// This copy of Ice is licensed to you under the terms described in the// ICE_LICENSE file included in this distribution.//// **********************************************************************#include <Ice/Ice.h>#include <IceUtil/Iterator.h>#include <TestCommon.h>#include <Test.h>#include <Wstring.h>using namespace std;class CallbackBase : public IceUtil::Monitor<IceUtil::Mutex>{public: CallbackBase() : _called(false) { } virtual ~CallbackBase() { } bool check() { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); while(!_called) { if(!timedWait(IceUtil::Time::seconds(5))) { return false; } } _called = false; return true; }protected: void called() { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); assert(!_called); _called = true; notify(); }private: bool _called;};class AMI_TestIntf_opBoolArrayI : public Test::AMI_TestIntf_opBoolArray, public CallbackBase{public: AMI_TestIntf_opBoolArrayI(Test::BoolSeq in) : _in(in) { } virtual void ice_response(const Test::BoolSeq& ret, const Test::BoolSeq& out) { test(out == _in); test(ret == _in); called(); } virtual void ice_exception(const ::Ice::Exception&) { test(false); }private: Test::BoolSeq _in;};typedef IceUtil::Handle<AMI_TestIntf_opBoolArrayI> AMI_TestIntf_opBoolArrayIPtr;class AMI_TestIntf_opByteArrayI : public Test::AMI_TestIntf_opByteArray, public CallbackBase{public: AMI_TestIntf_opByteArrayI(const pair<const Ice::Byte*, const Ice::Byte*>& in) : _in(in) { } virtual void ice_response(const pair<const Ice::Byte*, const Ice::Byte*>& ret, const pair<const Ice::Byte*, const Ice::Byte*>& out) { test(_in.second - _in.first == out.second - out.first); test(_in.second - _in.first == ret.second - ret.first); Ice::Byte* b = const_cast<Ice::Byte*>(_in.first); Ice::Byte* r = const_cast<Ice::Byte*>(ret.first); Ice::Byte* o = const_cast<Ice::Byte*>(out.first); while(b != _in.second) { test(*r++ == *b); test(*o++ == *b++); } called(); } virtual void ice_exception(const ::Ice::Exception&) { test(false); }private: pair<const Ice::Byte*, const Ice::Byte*> _in;};typedef IceUtil::Handle<AMI_TestIntf_opByteArrayI> AMI_TestIntf_opByteArrayIPtr;class AMI_TestIntf_opVariableArrayI : public Test::AMI_TestIntf_opVariableArray, public CallbackBase{public: AMI_TestIntf_opVariableArrayI(Test::VariableList in) : _in(in) { } virtual void ice_response(const Test::VariableList& ret, const Test::VariableList& out) { test(out == _in); test(ret == _in); called(); } virtual void ice_exception(const ::Ice::Exception&) { test(false); }private: Test::VariableList _in;};typedef IceUtil::Handle<AMI_TestIntf_opVariableArrayI> AMI_TestIntf_opVariableArrayIPtr;class AMI_TestIntf_opBoolRangeI : public Test::AMI_TestIntf_opBoolRange, public CallbackBase{public: AMI_TestIntf_opBoolRangeI(Test::BoolSeq in) : _in(in) { } virtual void ice_response(const Test::BoolSeq& ret, const Test::BoolSeq& out) { test(out == _in); test(ret == _in); called(); } virtual void ice_exception(const ::Ice::Exception&) { test(false); }private: Test::BoolSeq _in;};typedef IceUtil::Handle<AMI_TestIntf_opBoolRangeI> AMI_TestIntf_opBoolRangeIPtr;class AMI_TestIntf_opByteRangeI : public Test::AMI_TestIntf_opByteRange, public CallbackBase{public: AMI_TestIntf_opByteRangeI(Test::ByteList in) : _in(in) { } virtual void ice_response(const pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator>& ret, const pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator>& out) { test(ice_distance(out.first, out.second) == static_cast<Ice::Int>(_in.size())); test(ice_distance(ret.first, ret.second) == static_cast<Ice::Int>(_in.size())); Test::ByteList::const_iterator b; Test::ByteList::const_iterator o = out.first; Test::ByteList::const_iterator r = ret.first; for(b = _in.begin(); b != _in.end(); ++b) { test(*b == *o++); test(*b == *r++); } called(); } virtual void ice_exception(const ::Ice::Exception&) { test(false); }private: Test::ByteList _in;};typedef IceUtil::Handle<AMI_TestIntf_opByteRangeI> AMI_TestIntf_opByteRangeIPtr;class AMI_TestIntf_opVariableRangeI : public Test::AMI_TestIntf_opVariableRange, public CallbackBase{public: AMI_TestIntf_opVariableRangeI(Test::VariableList in) : _in(in) { } virtual void ice_response(const Test::VariableList& ret, const Test::VariableList& out) { test(out == _in); test(ret == _in); called(); } virtual void ice_exception(const ::Ice::Exception&) { test(false); }private: Test::VariableList _in;};typedef IceUtil::Handle<AMI_TestIntf_opVariableRangeI> AMI_TestIntf_opVariableRangeIPtr;class AMI_TestIntf_opBoolRangeTypeI : public Test::AMI_TestIntf_opBoolRangeType, public CallbackBase{public: AMI_TestIntf_opBoolRangeTypeI(Test::BoolSeq in) : _in(in) { } virtual void ice_response(const Test::BoolSeq& ret, const Test::BoolSeq& out) { test(out == _in); test(ret == _in); called(); } virtual void ice_exception(const ::Ice::Exception&) { test(false); }private: Test::BoolSeq _in;};typedef IceUtil::Handle<AMI_TestIntf_opBoolRangeTypeI> AMI_TestIntf_opBoolRangeTypeIPtr;class AMI_TestIntf_opByteRangeTypeI : public Test::AMI_TestIntf_opByteRangeType, public CallbackBase{public: AMI_TestIntf_opByteRangeTypeI(Test::ByteList in) : _in(in) { } virtual void ice_response(const Test::ByteList& ret, const Test::ByteList& out) { test(out == _in); test(ret == _in); called(); } virtual void ice_exception(const ::Ice::Exception&) { test(false); }private: Test::ByteList _in;};typedef IceUtil::Handle<AMI_TestIntf_opByteRangeTypeI> AMI_TestIntf_opByteRangeTypeIPtr;class AMI_TestIntf_opVariableRangeTypeI : public Test::AMI_TestIntf_opVariableRangeType, public CallbackBase{public: AMI_TestIntf_opVariableRangeTypeI(Test::VariableList in) : _in(in) { } virtual void ice_response(const Test::VariableList& ret, const Test::VariableList& out) { test(out == _in); test(ret == _in); called(); } virtual void ice_exception(const ::Ice::Exception&) { test(false); }private: Test::VariableList _in;};typedef IceUtil::Handle<AMI_TestIntf_opVariableRangeTypeI> AMI_TestIntf_opVariableRangeTypeIPtr;class AMI_TestIntf_opBoolSeqI : public Test::AMI_TestIntf_opBoolSeq, public CallbackBase{public: AMI_TestIntf_opBoolSeqI(deque<bool> in) : _in(in) { } virtual void ice_response(const deque<bool>& ret, const deque<bool>& out) { test(out == _in); test(ret == _in); called(); } virtual void ice_exception(const ::Ice::Exception&) { test(false); }private: deque<bool> _in;};typedef IceUtil::Handle<AMI_TestIntf_opBoolSeqI> AMI_TestIntf_opBoolSeqIPtr;class AMI_TestIntf_opBoolListI : public Test::AMI_TestIntf_opBoolList, public CallbackBase{public: AMI_TestIntf_opBoolListI(list<bool> in) : _in(in) { } virtual void ice_response(const list<bool>& ret, const list<bool>& out) { test(out == _in); test(ret == _in); called(); } virtual void ice_exception(const ::Ice::Exception&) { test(false); }private: list<bool> _in;};typedef IceUtil::Handle<AMI_TestIntf_opBoolListI> AMI_TestIntf_opBoolListIPtr;class AMI_TestIntf_opByteSeqI : public Test::AMI_TestIntf_opByteSeq, public CallbackBase{public: AMI_TestIntf_opByteSeqI(deque<Ice::Byte> in) : _in(in) { } virtual void ice_response(const deque<Ice::Byte>& ret, const deque<Ice::Byte>& out) { test(out == _in); test(ret == _in); called(); } virtual void ice_exception(const ::Ice::Exception&) { test(false); }private: deque<Ice::Byte> _in;};typedef IceUtil::Handle<AMI_TestIntf_opByteSeqI> AMI_TestIntf_opByteSeqIPtr;class AMI_TestIntf_opByteListI : public Test::AMI_TestIntf_opByteList, public CallbackBase{public: AMI_TestIntf_opByteListI(list<Ice::Byte> in) : _in(in) { } virtual void ice_response(const list<Ice::Byte>& ret, const list<Ice::Byte>& out) { test(out == _in); test(ret == _in); called(); } virtual void ice_exception(const ::Ice::Exception&) { test(false); }private: list<Ice::Byte> _in;};typedef IceUtil::Handle<AMI_TestIntf_opByteListI> AMI_TestIntf_opByteListIPtr;class AMI_TestIntf_opMyByteSeqI : public Test::AMI_TestIntf_opMyByteSeq, public CallbackBase{public: AMI_TestIntf_opMyByteSeqI(MyByteSeq in) : _in(in) { } virtual void ice_response(const MyByteSeq& ret, const MyByteSeq& out) { test(out == _in); test(ret == _in); called(); } virtual void ice_exception(const ::Ice::Exception&) { test(false); }private: MyByteSeq _in;};typedef IceUtil::Handle<AMI_TestIntf_opMyByteSeqI> AMI_TestIntf_opMyByteSeqIPtr;class AMI_TestIntf_opStringSeqI : public Test::AMI_TestIntf_opStringSeq, public CallbackBase{public: AMI_TestIntf_opStringSeqI(deque<string> in) : _in(in) { } virtual void ice_response(const deque<string>& ret, const deque<string>& out) { test(out == _in); test(ret == _in); called(); } virtual void ice_exception(const ::Ice::Exception&) { test(false); }private: deque<string> _in;};typedef IceUtil::Handle<AMI_TestIntf_opStringSeqI> AMI_TestIntf_opStringSeqIPtr;class AMI_TestIntf_opStringListI : public Test::AMI_TestIntf_opStringList, public CallbackBase{public: AMI_TestIntf_opStringListI(list<string> in) : _in(in) { } virtual void ice_response(const list<string>& ret, const list<string>& out) { test(out == _in); test(ret == _in); called(); } virtual void ice_exception(const ::Ice::Exception&) { test(false); }private: list<string> _in;};typedef IceUtil::Handle<AMI_TestIntf_opStringListI> AMI_TestIntf_opStringListIPtr;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -