⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 twoways.cpp

📁 ICE-3.2 一个开源的中间件
💻 CPP
📖 第 1 页 / 共 2 页
字号:
        dsi[0].push_back(Ice::Double(1.1E10));        dsi[0].push_back(Ice::Double(1.2E10));        dsi[0].push_back(Ice::Double(1.3E10));        Test::FloatSS fso;        Test::DoubleSS dso;        Test::DoubleSS rso;        rso = p->opFloatDoubleSS(fsi, dsi, fso, dso);        test(fso.size() == 3);        test(fso[0].size() == 1);        test(fso[0][0] == ::Ice::Float(3.14));        test(fso[1].size() == 1);        test(fso[1][0] == ::Ice::Float(1.11));        test(fso[2].size() == 0);        test(dso.size() == 1);        test(dso[0].size() == 3);        test(dso[0][0] == ::Ice::Double(1.1E10));        test(dso[0][1] == ::Ice::Double(1.2E10));        test(dso[0][2] == ::Ice::Double(1.3E10));        test(rso.size() == 2);        test(rso[0].size() == 3);        test(rso[0][0] == ::Ice::Double(1.1E10));        test(rso[0][1] == ::Ice::Double(1.2E10));        test(rso[0][2] == ::Ice::Double(1.3E10));        test(rso[1].size() == 3);        test(rso[1][0] == ::Ice::Double(1.1E10));        test(rso[1][1] == ::Ice::Double(1.2E10));        test(rso[1][2] == ::Ice::Double(1.3E10));    }    {        Test::StringSS ssi1;        ssi1.resize(2);        Test::StringSS ssi2;        ssi2.resize(3);        ssi1[0].push_back("abc");        ssi1[1].push_back("de");        ssi1[1].push_back("fghi");        ssi2[2].push_back("xyz");        Test::StringSS sso;        Test::StringSS rso;        rso = p->opStringSS(ssi1, ssi2, sso);        test(sso.size() == 5);        test(sso[0].size() == 1);        test(sso[0][0] == "abc");        test(sso[1].size() == 2);        test(sso[1][0] == "de");        test(sso[1][1] == "fghi");        test(sso[2].size() == 0);        test(sso[3].size() == 0);        test(sso[4].size() == 1);        test(sso[4][0] == "xyz");        test(rso.size() == 3);        test(rso[0].size() == 1);        test(rso[0][0] == "xyz");        test(rso[1].size() == 0);        test(rso[2].size() == 0);    }    {        Test::StringSSS sssi1;        sssi1.resize(2);        sssi1[0].resize(2);        sssi1[0][0].push_back("abc");        sssi1[0][0].push_back("de");        sssi1[0][1].push_back("xyz");        sssi1[1].resize(1);        sssi1[1][0].push_back("hello");        Test::StringSSS sssi2;        sssi2.resize(3);        sssi2[0].resize(2);        sssi2[0][0].push_back("");        sssi2[0][0].push_back("");        sssi2[0][1].push_back("abcd");        sssi2[1].resize(1);        sssi2[1][0].push_back("");        Test::StringSSS ssso;        Test::StringSSS rsso;        rsso = p->opStringSSS(sssi1, sssi2, ssso);        test(ssso.size() == 5);        test(ssso[0].size() == 2);        test(ssso[0][0].size() == 2);        test(ssso[0][1].size() == 1);        test(ssso[1].size() == 1);        test(ssso[1][0].size() == 1);        test(ssso[2].size() == 2);        test(ssso[2][0].size() == 2);        test(ssso[2][1].size() == 1);        test(ssso[3].size() == 1);        test(ssso[3][0].size() == 1);        test(ssso[4].size() == 0);        test(ssso[0][0][0] == "abc");        test(ssso[0][0][1] == "de");        test(ssso[0][1][0] == "xyz");        test(ssso[1][0][0] == "hello");        test(ssso[2][0][0] == "");        test(ssso[2][0][1] == "");        test(ssso[2][1][0] == "abcd");        test(ssso[3][0][0] == "");        test(rsso.size() == 3);        test(rsso[0].size() == 0);        test(rsso[1].size() == 1);        test(rsso[1][0].size() == 1);        test(rsso[2].size() == 2);        test(rsso[2][0].size() == 2);        test(rsso[2][1].size() == 1);        test(rsso[1][0][0] == "");        test(rsso[2][0][0] == "");        test(rsso[2][0][1] == "");        test(rsso[2][1][0] == "abcd");    }    {        Test::ByteBoolD di1;        di1[10] = true;        di1[100] = false;        Test::ByteBoolD di2;        di2[10] = true;        di2[11] = false;        di2[101] = true;        Test::ByteBoolD _do;        Test::ByteBoolD ro = p->opByteBoolD(di1, di2, _do);        test(_do == di1);        test(ro.size() == 4);        test(ro[10] == true);        test(ro[11] == false);        test(ro[100] == false);        test(ro[101] == true);    }    {        Test::ShortIntD di1;        di1[110] = -1;        di1[1100] = 123123;        Test::ShortIntD di2;        di2[110] = -1;        di2[111] = -100;        di2[1101] = 0;        Test::ShortIntD _do;        Test::ShortIntD ro = p->opShortIntD(di1, di2, _do);        test(_do == di1);        test(ro.size() == 4);        test(ro[110] == -1);        test(ro[111] == -100);        test(ro[1100] == 123123);        test(ro[1101] == 0);    }    {        Test::LongFloatD di1;        di1[999999110] = Ice::Float(-1.1);        di1[999999111] = Ice::Float(123123.2);        Test::LongFloatD di2;        di2[999999110] = Ice::Float(-1.1);        di2[999999120] = Ice::Float(-100.4);        di2[999999130] = Ice::Float(0.5);        Test::LongFloatD _do;        Test::LongFloatD ro = p->opLongFloatD(di1, di2, _do);        test(_do == di1);        test(ro.size() == 4);        test(ro[999999110] == Ice::Float(-1.1));        test(ro[999999120] == Ice::Float(-100.4));        test(ro[999999111] == Ice::Float(123123.2));        test(ro[999999130] == Ice::Float(0.5));    }    {        Test::StringStringD di1;        di1["foo"] = "abc -1.1";        di1["bar"] = "abc 123123.2";        Test::StringStringD di2;        di2["foo"] = "abc -1.1";        di2["FOO"] = "abc -100.4";        di2["BAR"] = "abc 0.5";        Test::StringStringD _do;        Test::StringStringD ro = p->opStringStringD(di1, di2, _do);        test(_do == di1);        test(ro.size() == 4);        test(ro["foo"] == "abc -1.1");        test(ro["FOO"] == "abc -100.4");        test(ro["bar"] == "abc 123123.2");        test(ro["BAR"] == "abc 0.5");    }    {        Test::StringMyEnumD di1;        di1["abc"] = Test::enum1;        di1[""] = Test::enum2;        Test::StringMyEnumD di2;        di2["abc"] = Test::enum1;        di2["qwerty"] = Test::enum3;        di2["Hello!!"] = Test::enum2;        Test::StringMyEnumD _do;        Test::StringMyEnumD ro = p->opStringMyEnumD(di1, di2, _do);        test(_do == di1);        test(ro.size() == 4);        test(ro["abc"] == Test::enum1);        test(ro["qwerty"] == Test::enum3);        test(ro[""] == Test::enum2);        test(ro["Hello!!"] == Test::enum2);    }    {        const int lengths[] = { 0, 1, 2, 126, 127, 128, 129, 253, 254, 255, 256, 257, 1000 };        for(int l = 0; l != sizeof(lengths) / sizeof(*lengths); ++l)        {            Test::IntS s;            for(int i = 0; i < lengths[l]; ++i)            {                s.push_back(i);            }            Test::IntS r = p->opIntS(s);            test(r.size() == static_cast<size_t>(lengths[l]));            for(int j = 0; j < static_cast<int>(r.size()); ++j)            {                test(r[j] == -j);            }        }    }    {        Ice::Context ctx;        ctx["one"] = "ONE";        ctx["two"] = "TWO";        ctx["three"] = "THREE";        {            Test::StringStringD r = p->opContext();            test(p->ice_getContext().empty());            test(r != ctx);        }        {            Test::StringStringD r = p->opContext(ctx);            test(p->ice_getContext().empty());            test(r == ctx);        }        {            Test::MyClassPrx p2 = Test::MyClassPrx::checkedCast(p->ice_context(ctx));            test(p2->ice_getContext() == ctx);            Test::StringStringD r = p2->opContext();            test(r == ctx);            r = p2->opContext(ctx);            test(r == ctx);        }        {            //            // Test that default context is obtained correctly from communicator.            ///* DEPRECATED            Ice::Context dflt;            dflt["a"] = "b";            communicator->setDefaultContext(dflt);            test(p->opContext() != dflt);            Test::MyClassPrx p2 = Test::MyClassPrx::uncheckedCast(p->ice_context(Ice::Context()));            test(p2->opContext().empty());            p2 = Test::MyClassPrx::uncheckedCast(p->ice_defaultContext());            test(p2->opContext() == dflt);            communicator->setDefaultContext(Ice::Context());            test(!p2->opContext().empty());            communicator->setDefaultContext(dflt);            Test::MyClassPrx c = Test::MyClassPrx::checkedCast(                                        communicator->stringToProxy("test:default -p 12010 -t 10000"));            test(c->opContext() == dflt);            dflt["a"] = "c";            Test::MyClassPrx c2 = Test::MyClassPrx::uncheckedCast(c->ice_context(dflt));            test(c2->opContext()["a"] == "c");            dflt.clear();            Test::MyClassPrx c3 = Test::MyClassPrx::uncheckedCast(c2->ice_context(dflt));            Ice::Context tmp = c3->opContext();            test(tmp.find("a") == tmp.end());            Test::MyClassPrx c4 = Test::MyClassPrx::uncheckedCast(c2->ice_defaultContext());            test(c4->opContext()["a"] == "b");            dflt["a"] = "d";            communicator->setDefaultContext(dflt);            Test::MyClassPrx c5 = Test::MyClassPrx::uncheckedCast(c->ice_defaultContext());            test(c5->opContext()["a"] == "d");            communicator->setDefaultContext(Ice::Context());*/        }                {            //            // Test implicit context propagation            //                        string impls[] = {"Shared", "PerThread"};            for(int i = 0; i < 2; i++)            {                Ice::InitializationData initData;                initData.properties = communicator->getProperties()->clone();                initData.properties->setProperty("Ice.ImplicitContext", impls[i]);                                Ice::CommunicatorPtr ic = Ice::initialize(initData);                Ice::Context ctx;                ctx["one"] = "ONE";                ctx["two"] = "TWO";                ctx["three"] = "THREE";                Test::MyClassPrx p = Test::MyClassPrx::uncheckedCast(                                        ic->stringToProxy("test:default -p 12010 -t 10000"));                                ic->getImplicitContext()->setContext(ctx);                test(ic->getImplicitContext()->getContext() == ctx);                test(p->opContext() == ctx);                                test(ic->getImplicitContext()->containsKey("zero") == false);                string r = ic->getImplicitContext()->put("zero", "ZERO");                test(r == "");                test(ic->getImplicitContext()->containsKey("zero") == true);                test(ic->getImplicitContext()->get("zero") == "ZERO");                ctx = ic->getImplicitContext()->getContext();                test(p->opContext() == ctx);                                Ice::Context prxContext;                prxContext["one"] = "UN";                prxContext["four"] = "QUATRE";                                Ice::Context combined = prxContext;                combined.insert(ctx.begin(), ctx.end());                test(combined["one"] == "UN");                                p = Test::MyClassPrx::uncheckedCast(p->ice_context(prxContext));                ic->getImplicitContext()->setContext(Ice::Context());                test(p->opContext() == prxContext);                ic->getImplicitContext()->setContext(ctx);                test(p->opContext() == combined);                test(ic->getImplicitContext()->remove("one") == "ONE");                                ic->destroy();            }        }            }    {        Ice::Double d = 1278312346.0 / 13.0;        Test::DoubleS ds(5, d);        p->opDoubleMarshaling(d, ds);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -