summaryrefslogtreecommitdiff
path: root/cpp/test
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/test')
-rwxr-xr-xcpp/test/Ice/custom/AllTests.cpp215
-rw-r--r--cpp/test/Ice/custom/CustomMap.h38
-rw-r--r--cpp/test/Ice/custom/Makefile.mak2
-rw-r--r--cpp/test/Ice/custom/MyByteSeq.h2
-rw-r--r--cpp/test/Ice/custom/Test.ice17
-rw-r--r--cpp/test/Ice/custom/TestAMD.ice17
-rw-r--r--cpp/test/Ice/custom/TestAMDI.cpp22
-rw-r--r--cpp/test/Ice/custom/TestAMDI.h10
-rw-r--r--cpp/test/Ice/custom/TestI.cpp21
-rw-r--r--cpp/test/Ice/custom/TestI.h9
-rw-r--r--cpp/test/Ice/optional/AllTests.cpp30
11 files changed, 376 insertions, 7 deletions
diff --git a/cpp/test/Ice/custom/AllTests.cpp b/cpp/test/Ice/custom/AllTests.cpp
index 0f6853e19a5..de4f598f5e9 100755
--- a/cpp/test/Ice/custom/AllTests.cpp
+++ b/cpp/test/Ice/custom/AllTests.cpp
@@ -1405,8 +1405,8 @@ public:
void opOutArrayByteSeq(const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>& data, const InParamPtr& cookie)
{
- Test::ByteSeq dumy;
- const Test::ByteSeq& in = getIn(dumy, cookie);
+ Test::ByteSeq dummy;
+ const Test::ByteSeq& in = getIn(dummy, cookie);
Test::ByteSeq out(data.first, data.second);
Test::ByteSeq::const_iterator p1;
Test::ByteSeq::const_iterator p2;
@@ -1421,8 +1421,8 @@ public:
void opOutRangeByteSeq(const ::std::pair< ::Test::ByteSeq::const_iterator, ::Test::ByteSeq::const_iterator>& data,
const InParamPtr& cookie)
{
- Test::ByteSeq dumy;
- const Test::ByteSeq& in = getIn(dumy, cookie);
+ Test::ByteSeq dummy;
+ const Test::ByteSeq& in = getIn(dummy, cookie);
Test::ByteSeq out(data.first, data.second);
Test::ByteSeq::const_iterator p1;
Test::ByteSeq::const_iterator p2;
@@ -1434,6 +1434,34 @@ public:
called();
}
+ void opIntStringDict(const Test::IntStringDict& ret, const Test::IntStringDict& out, const InParamPtr& cookie)
+ {
+ Test::IntStringDict dummy; // just for type
+ const Test::IntStringDict& in = getIn(dummy, cookie);
+
+ test(ret == in);
+ test(out == in);
+ called();
+ }
+
+ void opVarDict(const Test::CustomMap<Ice::Long, Ice::Long>& ret,
+ const Test::CustomMap<std::string, Ice::Int>& out, const InParamPtr& cookie)
+ {
+ Test::CustomMap<std::string, Ice::Int> dummy; // just for type
+ const Test::CustomMap<std::string, Ice::Int>& in = getIn(dummy, cookie);
+
+ test(out == in);
+
+ test(ret.size() == 1000);
+ for(Test::CustomMap<Ice::Long, Ice::Long>::const_iterator i = ret.begin(); i != ret.end(); ++i)
+ {
+ test(i->second == i->first * i->first);
+ }
+
+ called();
+ }
+
+
void throwExcept1(const Ice::AsyncResultPtr& result)
{
wstring in = getIn(in, InParamPtr::dynamicCast(result->getCookie()));
@@ -2020,6 +2048,46 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated)
cout << "ok" << endl;
+ cout << "testing alternate dictionaries... " << flush;
+
+ {
+ Test::IntStringDict idict;
+
+ idict[1] = "one";
+ idict[2] = "two";
+ idict[3] = "three";
+ idict[-1] = "minus one";
+
+ Test::IntStringDict out;
+ out[5] = "five";
+
+ Test::IntStringDict ret = t->opIntStringDict(idict, out);
+ test(out == idict);
+ test(ret == idict);
+ }
+
+ {
+ Test::CustomMap<std::string, Ice::Int> idict;
+
+ idict["one"] = 1;
+ idict["two"] = 2;
+ idict["three"] = 3;
+ idict["minus one"] = -1;
+
+ Test::CustomMap<std::string, Ice::Int> out;
+ out["five"] = 5;
+
+ Test::CustomMap<Ice::Long, Ice::Long> ret = t->opVarDict(idict, out);
+ test(out == idict);
+ test(ret.size() == 1000);
+ for(Test::CustomMap<Ice::Long, Ice::Long>::const_iterator i = ret.begin(); i != ret.end(); ++i)
+ {
+ test(i->second == i->first * i->first);
+ }
+ }
+
+ cout << "ok" << endl;
+
if(!collocated)
{
cout << "testing alternate sequences with AMI... " << flush;
@@ -4276,6 +4344,145 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated)
}
cout << "ok" << endl;
#endif
+
+ cout << "testing alternate dictionaries with new AMI... " << flush;
+ {
+ {
+ Test::IntStringDict idict;
+
+ idict[1] = "one";
+ idict[2] = "two";
+ idict[3] = "three";
+ idict[-1] = "minus one";
+
+ Test::IntStringDict out;
+ out[5] = "five";
+
+ Ice::AsyncResultPtr r = t->begin_opIntStringDict(idict);
+ Test::IntStringDict ret = t->end_opIntStringDict(out, r);
+ test(out == idict);
+ test(ret == idict);
+ }
+
+ {
+ Test::CustomMap<std::string, Ice::Int> idict;
+
+ idict["one"] = 1;
+ idict["two"] = 2;
+ idict["three"] = 3;
+ idict["minus one"] = -1;
+
+ Test::CustomMap<std::string, Ice::Int> out;
+ out["five"] = 5;
+
+ Ice::AsyncResultPtr r = t->begin_opVarDict(idict);
+ Test::CustomMap<Ice::Long, Ice::Long> ret = t->end_opVarDict(out, r);
+ test(out == idict);
+ test(ret.size() == 1000);
+ for(Test::CustomMap<Ice::Long, Ice::Long>::const_iterator i = ret.begin(); i != ret.end(); ++i)
+ {
+ test(i->second == i->first * i->first);
+ }
+ }
+ }
+ cout << "ok" << endl;
+
+ cout << "testing alternate dictionaries with new AMI callbacks... " << flush;
+ {
+ {
+ Test::IntStringDict idict;
+
+ idict[1] = "one";
+ idict[2] = "two";
+ idict[3] = "three";
+ idict[-1] = "minus one";
+
+ Test::IntStringDict out;
+ out[5] = "five";
+
+ CallbackPtr cb = new Callback();
+ Test::Callback_TestIntf_opIntStringDictPtr callback =
+ Test::newCallback_TestIntf_opIntStringDict(cb, &Callback::opIntStringDict, &Callback::noEx);
+ t->begin_opIntStringDict(idict, callback, newInParam(idict));
+ cb->check();
+ }
+
+ {
+ Test::CustomMap<std::string, Ice::Int> idict;
+
+ idict["one"] = 1;
+ idict["two"] = 2;
+ idict["three"] = 3;
+ idict["minus one"] = -1;
+
+ Test::CustomMap<std::string, Ice::Int> out;
+ out["five"] = 5;
+
+ CallbackPtr cb = new Callback();
+ Test::Callback_TestIntf_opVarDictPtr callback =
+ Test::newCallback_TestIntf_opVarDict(cb, &Callback::opVarDict, &Callback::noEx);
+ t->begin_opVarDict(idict, callback, newInParam(idict));
+ cb->check();
+ }
+ }
+ cout << "ok" << endl;
+
+#ifdef ICE_CPP11
+ cout << "testing alternate dictionaries with new C++11 AMI callbacks... " << flush;
+ {
+ {
+ Test::IntStringDict idict;
+
+ idict[1] = "one";
+ idict[2] = "two";
+ idict[3] = "three";
+ idict[-1] = "minus one";
+
+ Test::IntStringDict out;
+ out[5] = "five";
+
+ CallbackPtr cb = new Callback();
+
+ t->begin_opIntStringDict(idict,
+ [=](const Test::IntStringDict& ret, const Test::IntStringDict& out)
+ {
+ cb->opIntStringDict(ret, out, newInParam(idict));
+ },
+ [=](const Ice::Exception& ex)
+ {
+ cb->noEx(ex, newInParam(idict));
+ });
+ cb->check();
+ }
+
+ {
+ Test::CustomMap<std::string, Ice::Int> idict;
+
+ idict["one"] = 1;
+ idict["two"] = 2;
+ idict["three"] = 3;
+ idict["minus one"] = -1;
+
+ Test::CustomMap<std::string, Ice::Int> out;
+ out["five"] = 5;
+
+ CallbackPtr cb = new Callback();
+
+ t->begin_opVarDict(idict,
+ [=](const Test::CustomMap<Ice::Long, Ice::Long>& ret,
+ const Test::CustomMap<std::string, Ice::Int>& out)
+ {
+ cb->opVarDict(ret, out, newInParam(idict));
+ },
+ [=](const Ice::Exception& ex)
+ {
+ cb->noEx(ex, newInParam(idict));
+ });
+ cb->check();
+ }
+ }
+ cout << "ok" << endl;
+#endif
}
cout << "testing class mapped structs ... " << flush;
diff --git a/cpp/test/Ice/custom/CustomMap.h b/cpp/test/Ice/custom/CustomMap.h
new file mode 100644
index 00000000000..49eb3d2e785
--- /dev/null
+++ b/cpp/test/Ice/custom/CustomMap.h
@@ -0,0 +1,38 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2012 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.
+//
+// **********************************************************************
+
+#ifndef CUSTOM_MAP_H
+#define CUSTOM_MAP_H
+
+#include <IceUtil/Config.h>
+
+#ifdef ICE_CPP11
+# include <unordered_map>
+#else
+# include <map>
+#endif
+
+namespace Test
+{
+
+#ifdef ICE_CPP11
+template<typename K, typename V>
+class CustomMap : public std::unordered_map<K, V>
+{
+};
+#else
+template<typename K, typename V>
+class CustomMap : public std::map<K, V>
+{
+};
+#endif
+
+}
+
+#endif
diff --git a/cpp/test/Ice/custom/Makefile.mak b/cpp/test/Ice/custom/Makefile.mak
index 5aa4f7d34e6..83051789c84 100644
--- a/cpp/test/Ice/custom/Makefile.mak
+++ b/cpp/test/Ice/custom/Makefile.mak
@@ -56,7 +56,7 @@ SRCS = $(COBJS:.obj=.cpp) \
!include $(top_srcdir)/config/Make.rules.mak
SLICE2CPPFLAGS = --stream $(SLICE2CPPFLAGS)
-CPPFLAGS = -I. -I../../include $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN -Zm300
+CPPFLAGS = -I. -I../../include $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN -Zm300 -bigobj
!if "$(GENERATE_PDB)" == "yes"
CPDBFLAGS = /pdb:$(CLIENT:.exe=.pdb)
diff --git a/cpp/test/Ice/custom/MyByteSeq.h b/cpp/test/Ice/custom/MyByteSeq.h
index e9d21b4adb3..78a880783d9 100644
--- a/cpp/test/Ice/custom/MyByteSeq.h
+++ b/cpp/test/Ice/custom/MyByteSeq.h
@@ -19,6 +19,8 @@ public:
typedef Ice::Byte* iterator;
typedef Ice::Byte* const_iterator;
+ typedef Ice::Byte value_type;
+
MyByteSeq();
MyByteSeq(size_t);
MyByteSeq(const MyByteSeq&);
diff --git a/cpp/test/Ice/custom/Test.ice b/cpp/test/Ice/custom/Test.ice
index 738e6c817d6..c3b40f188a5 100644
--- a/cpp/test/Ice/custom/Test.ice
+++ b/cpp/test/Ice/custom/Test.ice
@@ -9,7 +9,7 @@
#pragma once
-[["cpp:include:deque", "cpp:include:list", "cpp:include:MyByteSeq.h"]]
+[["cpp:include:deque", "cpp:include:list", "cpp:include:MyByteSeq.h", "cpp:include:CustomMap.h"]]
module Test
{
@@ -110,6 +110,15 @@ sequence<ClassOtherStruct> ClassOtherStructSeq;
};
sequence<ClassStruct> ClassStructSeq;
+["cpp:type:Test::CustomMap<Ice::Int, std::string>"] dictionary<int, string> IntStringDict;
+dictionary<long, long> LongLongDict;
+dictionary<string, int> StringIntDict;
+
+class DictClass
+{
+ IntStringDict isdict;
+};
+
["ami"] class TestIntf
{
["cpp:array"] DoubleSeq opDoubleArray(["cpp:array"] DoubleSeq inSeq, out ["cpp:array"] DoubleSeq outSeq);
@@ -202,6 +211,12 @@ sequence<ClassStruct> ClassStructSeq;
void opOutRangeByteSeq(ByteSeq org, out ["cpp:range"] ByteSeq copy);
+ IntStringDict opIntStringDict(IntStringDict idict, out IntStringDict odict);
+
+ ["cpp:type:::Test::CustomMap< ::Ice::Long, ::Ice::Long>"] LongLongDict
+ opVarDict(["cpp:type:::Test::CustomMap<std::string, ::Ice::Int>"] StringIntDict idict,
+ out ["cpp:type:::Test::CustomMap<std::string, ::Ice::Int>"] StringIntDict odict);
+
void shutdown();
};
diff --git a/cpp/test/Ice/custom/TestAMD.ice b/cpp/test/Ice/custom/TestAMD.ice
index 295f81980b1..f4bb852d942 100644
--- a/cpp/test/Ice/custom/TestAMD.ice
+++ b/cpp/test/Ice/custom/TestAMD.ice
@@ -9,7 +9,7 @@
#pragma once
-[["cpp:include:deque", "cpp:include:list", "cpp:include:MyByteSeq.h"]]
+[["cpp:include:deque", "cpp:include:list", "cpp:include:MyByteSeq.h", "cpp:include:CustomMap.h"]]
module Test
{
@@ -108,6 +108,15 @@ sequence<ClassOtherStruct> ClassOtherStructSeq;
};
sequence<ClassStruct> ClassStructSeq;
+["cpp:type:Test::CustomMap<Ice::Int, std::string>"] dictionary<int, string> IntStringDict;
+dictionary<long, long> LongLongDict;
+dictionary<string, int> StringIntDict;
+
+class DictClass
+{
+ IntStringDict isdict;
+};
+
["amd", "ami"] class TestIntf
{
DoubleSeq opDoubleArray(["cpp:array"] DoubleSeq inSeq, out DoubleSeq outSeq);
@@ -191,6 +200,12 @@ sequence<ClassStruct> ClassStructSeq;
void opOutRangeByteSeq(ByteSeq org, out ["cpp:range"] ByteSeq copy);
+ IntStringDict opIntStringDict(IntStringDict idict, out IntStringDict odict);
+
+ ["cpp:type:::Test::CustomMap< ::Ice::Long, ::Ice::Long>"] LongLongDict
+ opVarDict(["cpp:type:::Test::CustomMap<std::string, ::Ice::Int>"] StringIntDict idict,
+ out ["cpp:type:::Test::CustomMap<std::string, ::Ice::Int>"] StringIntDict odict);
+
void shutdown();
};
diff --git a/cpp/test/Ice/custom/TestAMDI.cpp b/cpp/test/Ice/custom/TestAMDI.cpp
index 79c1ac30e31..d8624cf48ea 100644
--- a/cpp/test/Ice/custom/TestAMDI.cpp
+++ b/cpp/test/Ice/custom/TestAMDI.cpp
@@ -308,6 +308,28 @@ TestIntfI::opOutRangeByteSeq_async(const ::Test::AMD_TestIntf_opOutRangeByteSeqP
::Test::ByteSeq::const_iterator>(inS.begin(), inS.end()));
}
+void
+TestIntfI::opIntStringDict_async(const ::Test::AMD_TestIntf_opIntStringDictPtr& cb,
+ const ::Test::IntStringDict& inDict,
+ const ::Ice::Current&)
+{
+ cb->ice_response(inDict, inDict);
+}
+
+void
+TestIntfI::opVarDict_async(const ::Test::AMD_TestIntf_opVarDictPtr& cb,
+ const ::Test::CustomMap<std::string, Ice::Int>& inDict,
+ const ::Ice::Current&)
+{
+ Test::CustomMap<Ice::Long, Ice::Long> result;
+ for(Ice::Long i = 0; i < 1000; ++i)
+ {
+ result[i] = i*i;
+ }
+ cb->ice_response(result, inDict);
+}
+
+
void
TestIntfI::shutdown_async(const Test::AMD_TestIntf_shutdownPtr& shutdownCB,
const Ice::Current& current)
diff --git a/cpp/test/Ice/custom/TestAMDI.h b/cpp/test/Ice/custom/TestAMDI.h
index f44c4569f93..759434157b2 100644
--- a/cpp/test/Ice/custom/TestAMDI.h
+++ b/cpp/test/Ice/custom/TestAMDI.h
@@ -151,6 +151,16 @@ public:
const ::Test::ByteSeq&,
const ::Ice::Current&);
+ virtual void opIntStringDict_async(const ::Test::AMD_TestIntf_opIntStringDictPtr&,
+ const ::Test::IntStringDict&,
+ const ::Ice::Current&);
+
+ virtual void opVarDict_async(const ::Test::AMD_TestIntf_opVarDictPtr&,
+ const ::Test::CustomMap<std::string, Ice::Int>&,
+ const ::Ice::Current&);
+
+
+
virtual void shutdown_async(const Test::AMD_TestIntf_shutdownPtr&,
const Ice::Current&);
diff --git a/cpp/test/Ice/custom/TestI.cpp b/cpp/test/Ice/custom/TestI.cpp
index 7fe8a0f1b9e..2e148c6f2cd 100644
--- a/cpp/test/Ice/custom/TestI.cpp
+++ b/cpp/test/Ice/custom/TestI.cpp
@@ -337,6 +337,27 @@ TestIntfI::opOutRangeByteSeq(const Test::ByteSeq& data, Test::ByteSeq& copy, con
copy = data;
}
+Test::IntStringDict
+TestIntfI::opIntStringDict(const Test::IntStringDict& data, Test::IntStringDict& copy, const Ice::Current&)
+{
+ copy = data;
+ return data;
+}
+
+Test::CustomMap<Ice::Long, Ice::Long>
+TestIntfI::opVarDict(const Test::CustomMap<std::string, Ice::Int>& data,
+ Test::CustomMap<std::string, Ice::Int>& copy, const Ice::Current&)
+{
+ copy = data;
+
+ Test::CustomMap<Ice::Long, Ice::Long> result;
+ for(Ice::Long i = 0; i < 1000; ++i)
+ {
+ result[i] = i*i;
+ }
+ return result;
+}
+
void
TestIntfI::shutdown(const Ice::Current& current)
{
diff --git a/cpp/test/Ice/custom/TestI.h b/cpp/test/Ice/custom/TestI.h
index 474ad7c51b5..4afbd43d613 100644
--- a/cpp/test/Ice/custom/TestI.h
+++ b/cpp/test/Ice/custom/TestI.h
@@ -163,6 +163,15 @@ public:
virtual void opOutRangeByteSeq(const Test::ByteSeq&, Test::ByteSeq&, const Ice::Current&);
+
+ virtual Test::IntStringDict opIntStringDict(const Test::IntStringDict&, Test::IntStringDict&,
+ const Ice::Current&);
+
+ virtual Test::CustomMap<Ice::Long, Ice::Long> opVarDict(const Test::CustomMap<std::string, Ice::Int>&,
+ Test::CustomMap<std::string, Ice::Int>&,
+ const Ice::Current&);
+
+
virtual void shutdown(const Ice::Current&);
private:
diff --git a/cpp/test/Ice/optional/AllTests.cpp b/cpp/test/Ice/optional/AllTests.cpp
index 994bab81bc9..fb075f19ec1 100644
--- a/cpp/test/Ice/optional/AllTests.cpp
+++ b/cpp/test/Ice/optional/AllTests.cpp
@@ -849,7 +849,12 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated)
vector<Ice::Byte> bs(100);
fill(bs.begin(), bs.end(), 56);
+#if defined(__SUNPRO_CC) && defined(_RWSTD_NO_MEMBER_TEMPLATES)
+ std::pair<const Ice::Byte*, const Ice::Byte*> cpair(&bs[0], &bs[0] + bs.size());
+ p1 = cpair;
+#else
p1 = make_pair(&bs[0], &bs[0] + bs.size());
+#endif
p2 = initial->opByteSeq(p1, p3);
test(p2 && p3);
test(p2 == bs && p3 == bs);
@@ -880,7 +885,12 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated)
vector<Ice::Short> bs(100);
fill(bs.begin(), bs.end(), 56);
+#if defined(__SUNPRO_CC) && defined(_RWSTD_NO_MEMBER_TEMPLATES)
+ std::pair<const Ice::Short*, const Ice::Short*> cpair(&bs[0], &bs[0] + bs.size());
+ p1 = cpair;
+#else
p1 = make_pair(&bs[0], &bs[0] + bs.size());
+#endif
p2 = initial->opShortSeq(p1, p3);
test(p2 && p3);
test(p2 == bs && p3 == bs);
@@ -911,7 +921,12 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated)
bool bs[100];
vector<bool> bsv(&bs[0], &bs[0] + 100);
+#if defined(__SUNPRO_CC) && defined(_RWSTD_NO_MEMBER_TEMPLATES)
+ std::pair<const bool*, const bool*> cpair(&bs[0], &bs[0] + 100);
+ p1 = cpair;
+#else
p1 = make_pair(&bs[0], &bs[0] + 100);
+#endif
p2 = initial->opBoolSeq(p1, p3);
test(p2 && p3);
test(p2 == bsv && p3 == bsv);
@@ -942,7 +957,12 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated)
StringSeq ss(10);
fill(ss.begin(), ss.end(), "test1");
+#if defined(__SUNPRO_CC) && defined(_RWSTD_NO_MEMBER_TEMPLATES)
+ std::pair<StringSeq::const_iterator, StringSeq::const_iterator> cpair(ss.begin(), ss.end());
+ p1 = cpair;
+#else
p1 = make_pair(ss.begin(), ss.end());
+#endif
p2 = initial->opStringSeq(p1, p3);
test(p2 && p3);
test(p2 == ss && p3 == ss);
@@ -973,7 +993,12 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated)
FixedStruct fss[10];
vector<FixedStruct> fssv(&fss[0], &fss[0] + 10);
+#if defined(__SUNPRO_CC) && defined(_RWSTD_NO_MEMBER_TEMPLATES)
+ std::pair<const FixedStruct*, const FixedStruct*> cpair(&fss[0], &fss[0] + 10);
+ p1 = cpair;
+#else
p1 = make_pair(&fss[0], &fss[0] + 10);
+#endif
p2 = initial->opFixedStructSeq(p1, p3);
test(p2 && p3);
test(p2 == fssv && p3 == fssv);
@@ -1003,7 +1028,12 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated)
test(!p2 && !p3);
VarStructSeq ss(10);
+#if defined(__SUNPRO_CC) && defined(_RWSTD_NO_MEMBER_TEMPLATES)
+ std::pair<VarStructSeq::const_iterator, VarStructSeq::const_iterator> cpair(ss.begin(), ss.end());
+ p1 = cpair;
+#else
p1 = make_pair(ss.begin(), ss.end());
+#endif
p2 = initial->opVarStructSeq(p1, p3);
test(p2 && p3);
test(p2 == ss && p3 == ss);