From 1125ec3437502ee4450c8d09488063dcd899a4bd Mon Sep 17 00:00:00 2001 From: Matej Sekoranja Date: Tue, 3 Dec 2013 13:43:22 +0100 Subject: [PATCH] testServer/testChannelAccess: channel array fix --- testApp/remote/channelAccessIFTest.cpp | 4 ++-- testApp/remote/testServer.cpp | 21 ++++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/testApp/remote/channelAccessIFTest.cpp b/testApp/remote/channelAccessIFTest.cpp index 2f1135d..157ae7d 100755 --- a/testApp/remote/channelAccessIFTest.cpp +++ b/testApp/remote/channelAccessIFTest.cpp @@ -28,7 +28,7 @@ std::string ChannelAccessIFTest::TEST_COUNTER_CHANNEL_NAME = "testCounter"; std::string ChannelAccessIFTest::TEST_CHANNEL_NAME = "testValue"; std::string ChannelAccessIFTest::TEST_VALUEONLY_CHANNEL_NAME = "testValueOnly"; std::string ChannelAccessIFTest::TEST_SUMRPC_CHANNEL_NAME = "testSum"; -std::string ChannelAccessIFTest::TEST_ARRAY_CHANNEL_NAME = "testArray"; +std::string ChannelAccessIFTest::TEST_ARRAY_CHANNEL_NAME = "testArray1"; int ChannelAccessIFTest::runAllTest() { @@ -1790,7 +1790,7 @@ void ChannelAccessIFTest::test_channelArray() { testOk(data1[2] == 2.2 , "%s: check 2: %f", CURRENT_FUNCTION, data1[2]); - succStatus = arrayReq->syncSetLength(false, 4, 3, -1); + succStatus = arrayReq->syncSetLength(false, 3, -1, getTimeoutSec()); if (!succStatus) { testFail("%s: an array setLength failed ", CURRENT_FUNCTION); return; diff --git a/testApp/remote/testServer.cpp b/testApp/remote/testServer.cpp index 0880822..cb1b53d 100644 --- a/testApp/remote/testServer.cpp +++ b/testApp/remote/testServer.cpp @@ -1393,12 +1393,17 @@ public: { typename APVF::shared_pointer from = std::tr1::static_pointer_cast(pvfrom); typename APVF::shared_pointer to = std::tr1::static_pointer_cast(pvto); - - typename APVF::svector temp(to->reuse()); + typename APVF::const_svector ref(from->view()); - - // TODO range check - + if (offset > ref.size()) + offset = ref.size(); + if (count + offset > ref.size()) + count = ref.size() - offset; + + typename APVF::svector temp(to->reuse()); + if (offset + count > temp.size()) + temp.resize(offset + count); + std::copy(ref.begin(), ref.begin() + count, temp.begin() + offset); to->replace(freeze(temp)); @@ -1495,16 +1500,14 @@ public: virtual void setLength(bool lastRequest, int length, int capacity) { if (capacity > 0) { - m_pvArray->setCapacity(capacity); + m_pvStructureArray->setCapacity(capacity); } if (length > 0) { - m_pvArray->setLength(length); + m_pvStructureArray->setLength(length); } m_channelArrayRequester->setLengthDone(Status::Ok); - - cout << "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD" << endl; if (lastRequest) destroy(); }