Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6da871fa64 | ||
|
|
d53cb0cbc9 | ||
|
|
8f0111e482 | ||
|
|
5525119778 | ||
|
|
6410600205 | ||
|
|
a5d44745d1 |
@@ -1,4 +1,4 @@
|
|||||||
EPICS_PVD_MAJOR_VERSION = 7
|
EPICS_PVD_MAJOR_VERSION = 7
|
||||||
EPICS_PVD_MINOR_VERSION = 1
|
EPICS_PVD_MINOR_VERSION = 1
|
||||||
EPICS_PVD_MAINTENANCE_VERSION = 2
|
EPICS_PVD_MAINTENANCE_VERSION = 3
|
||||||
EPICS_PVD_DEVELOPMENT_FLAG = 0
|
EPICS_PVD_DEVELOPMENT_FLAG = 0
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ PROJECT_NAME = "PVData C++"
|
|||||||
# could be handy for archiving the generated documentation or if some version
|
# could be handy for archiving the generated documentation or if some version
|
||||||
# control system is used.
|
# control system is used.
|
||||||
|
|
||||||
PROJECT_NUMBER = 7.1.2
|
PROJECT_NUMBER = 7.1.3
|
||||||
|
|
||||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||||
# for a project that appears at the top of each page and should give viewer a
|
# for a project that appears at the top of each page and should give viewer a
|
||||||
@@ -319,7 +319,7 @@ AUTOLINK_SUPPORT = YES
|
|||||||
# diagrams that involve STL classes more complete and accurate.
|
# diagrams that involve STL classes more complete and accurate.
|
||||||
# The default value is: NO.
|
# The default value is: NO.
|
||||||
|
|
||||||
BUILTIN_STL_SUPPORT = YES
|
BUILTIN_STL_SUPPORT = NO
|
||||||
|
|
||||||
# If you use Microsoft's C++/CLI language, you should set this option to YES to
|
# If you use Microsoft's C++/CLI language, you should set this option to YES to
|
||||||
# enable parsing support.
|
# enable parsing support.
|
||||||
@@ -1970,7 +1970,7 @@ SEARCH_INCLUDES = YES
|
|||||||
# preprocessor.
|
# preprocessor.
|
||||||
# This tag requires that the tag SEARCH_INCLUDES is set to YES.
|
# This tag requires that the tag SEARCH_INCLUDES is set to YES.
|
||||||
|
|
||||||
INCLUDE_PATH = ../src/misc ../src
|
INCLUDE_PATH = ../src/misc ../src ../../../include/
|
||||||
|
|
||||||
# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
|
# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
|
||||||
# patterns (like *.h and *.hpp) to filter out the header-files in the
|
# patterns (like *.h and *.hpp) to filter out the header-files in the
|
||||||
@@ -2026,7 +2026,7 @@ SKIP_FUNCTION_MACROS = NO
|
|||||||
# the path). If a tag file is not located in the directory in which doxygen is
|
# the path). If a tag file is not located in the directory in which doxygen is
|
||||||
# run, you must also specify the path to the tagfile here.
|
# run, you must also specify the path to the tagfile here.
|
||||||
|
|
||||||
TAGFILES = ../../../base-git/documentation/epics-base.tag
|
TAGFILES = "libstdc++.tag = http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen"
|
||||||
|
|
||||||
# When a file name is specified after GENERATE_TAGFILE, doxygen will create a
|
# When a file name is specified after GENERATE_TAGFILE, doxygen will create a
|
||||||
# tag file that is based on the input files it reads. See section "Linking to
|
# tag file that is based on the input files it reads. See section "Linking to
|
||||||
@@ -2045,14 +2045,14 @@ ALLEXTERNALS = NO
|
|||||||
# listed.
|
# listed.
|
||||||
# The default value is: YES.
|
# The default value is: YES.
|
||||||
|
|
||||||
EXTERNAL_GROUPS = YES
|
EXTERNAL_GROUPS = NO
|
||||||
|
|
||||||
# If the EXTERNAL_PAGES tag is set to YES all external pages will be listed in
|
# If the EXTERNAL_PAGES tag is set to YES all external pages will be listed in
|
||||||
# the related pages index. If set to NO, only the current project's pages will
|
# the related pages index. If set to NO, only the current project's pages will
|
||||||
# be listed.
|
# be listed.
|
||||||
# The default value is: YES.
|
# The default value is: YES.
|
||||||
|
|
||||||
EXTERNAL_PAGES = YES
|
EXTERNAL_PAGES = NO
|
||||||
|
|
||||||
# The PERL_PATH should be the absolute path and name of the perl script
|
# The PERL_PATH should be the absolute path and name of the perl script
|
||||||
# interpreter (i.e. the result of 'which perl').
|
# interpreter (i.e. the result of 'which perl').
|
||||||
|
|||||||
@@ -3,11 +3,14 @@ all: gen
|
|||||||
clean:
|
clean:
|
||||||
rm -rf doxygen_sqlite3.db html
|
rm -rf doxygen_sqlite3.db html
|
||||||
|
|
||||||
gen:
|
gen: libstdc++.tag
|
||||||
doxygen
|
doxygen
|
||||||
|
|
||||||
commit: gen
|
commit: gen
|
||||||
touch html/.nojekyll
|
touch html/.nojekyll
|
||||||
./commit-gh.sh documentation/html/ html/.nojekyll html/*.* html/search/*.*
|
./commit-gh.sh documentation/html/ html/.nojekyll html/*.* html/search/*.*
|
||||||
|
|
||||||
|
libstdc++.tag:
|
||||||
|
wget -O $@ https://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/libstdc++.tag
|
||||||
|
|
||||||
.PHONY: all clean gen commit
|
.PHONY: all clean gen commit
|
||||||
|
|||||||
@@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
@page release_notes Release Notes
|
@page release_notes Release Notes
|
||||||
|
|
||||||
|
Release 7.1.3 (Apr 2019)
|
||||||
|
========================
|
||||||
|
|
||||||
|
- Fix for array serialization error to/from big endian.
|
||||||
|
https://github.com/epics-base/pvDataCPP/issues/65
|
||||||
|
|
||||||
Release 7.1.2 (Mar 2019)
|
Release 7.1.2 (Mar 2019)
|
||||||
========================
|
========================
|
||||||
|
|
||||||
|
|||||||
@@ -803,8 +803,8 @@ private:
|
|||||||
assert(n<=getRemaining());
|
assert(n<=getRemaining());
|
||||||
|
|
||||||
if (reverse<T>()) {
|
if (reverse<T>()) {
|
||||||
for(std::size_t i=0; i<n; i+=sizeof(T)) {
|
for(std::size_t i=0; i<count; i++) {
|
||||||
detail::store_unaligned(_position+i, swap<T>(values[i]));
|
detail::store_unaligned(_position+i*sizeof(T), swap<T>(values[i]));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
memcpy(_position, values, n);
|
memcpy(_position, values, n);
|
||||||
@@ -819,8 +819,8 @@ private:
|
|||||||
assert(n<=getRemaining());
|
assert(n<=getRemaining());
|
||||||
|
|
||||||
if (reverse<T>()) {
|
if (reverse<T>()) {
|
||||||
for(std::size_t i=0; i<n; i+=sizeof(T)) {
|
for(std::size_t i=0; i<count; i++) {
|
||||||
values[i] = swap<T>(detail::load_unaligned<T>(_position+i));
|
values[i] = swap<T>(detail::load_unaligned<T>(_position+i*sizeof(T)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
memcpy(values, _position, n);
|
memcpy(values, _position, n);
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
public:
|
public:
|
||||||
...
|
...
|
||||||
};
|
};
|
||||||
@code
|
@endcode
|
||||||
*
|
*
|
||||||
* @note This macro contains 'private:'.
|
* @note This macro contains 'private:'.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -14,15 +14,13 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include <epicsUnitTest.h>
|
|
||||||
#include <testMain.h>
|
#include <testMain.h>
|
||||||
|
|
||||||
|
#include <pv/pvUnitTest.h>
|
||||||
#include <pv/byteBuffer.h>
|
#include <pv/byteBuffer.h>
|
||||||
#include <pv/pvIntrospect.h>
|
#include <pv/pvIntrospect.h>
|
||||||
|
|
||||||
using namespace epics::pvData;
|
using namespace epics::pvData;
|
||||||
using std::string;
|
|
||||||
using std::cout;
|
|
||||||
|
|
||||||
static
|
static
|
||||||
void testBasicOperations() {
|
void testBasicOperations() {
|
||||||
@@ -175,7 +173,7 @@ void testBasicOperations() {
|
|||||||
testOk1(buff->getPosition()==6);
|
testOk1(buff->getPosition()==6);
|
||||||
testOk1(strncmp(&src[2],&dst[2],6)==0);
|
testOk1(strncmp(&src[2],&dst[2],6)==0);
|
||||||
|
|
||||||
cout<<"# First 10 characters of destination: >>"<<string(dst, 10)<<"<<\n";
|
testShow()<<"First 10 characters of destination: >>"<<std::string(dst, 10)<<"<<\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char expect_be[] = "abcdef";
|
static const char expect_be[] = "abcdef";
|
||||||
@@ -253,14 +251,68 @@ void testUnaligned()
|
|||||||
testOk1(memcmp(buf.getBuffer(), "\x42\x12\x34\x56\x78\x90\xab\xcd\xef\x41\x41\x41", 8)==0);
|
testOk1(memcmp(buf.getBuffer(), "\x42\x12\x34\x56\x78\x90\xab\xcd\xef\x41\x41\x41", 8)==0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
void testArrayLE()
|
||||||
|
{
|
||||||
|
testDiag("testArray() LE");
|
||||||
|
|
||||||
|
ByteBuffer buf(8, EPICS_ENDIAN_LITTLE);
|
||||||
|
|
||||||
|
std::vector<uint32> vals;
|
||||||
|
vals.push_back(0x12345678);
|
||||||
|
vals.push_back(0x01020304);
|
||||||
|
|
||||||
|
buf.putArray(&vals[0], vals.size());
|
||||||
|
testEqual(buf.getPosition(), 8);
|
||||||
|
|
||||||
|
testOk1(memcmp(buf.getBuffer(), "\x78\x56\x34\x12\x04\x03\x02\x01", 8)==0);
|
||||||
|
|
||||||
|
buf.clear();
|
||||||
|
buf.put("\x40\x30\x20\x10\xa4\xa3\xa2\xa1", 0, 8);
|
||||||
|
buf.flip();
|
||||||
|
|
||||||
|
buf.getArray(&vals[0], 2);
|
||||||
|
|
||||||
|
testEqual(vals[0], 0x10203040);
|
||||||
|
testEqual(vals[1], 0xa1a2a3a4);
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
void testArrayBE()
|
||||||
|
{
|
||||||
|
testDiag("testArray() BE");
|
||||||
|
|
||||||
|
ByteBuffer buf(8, EPICS_ENDIAN_BIG);
|
||||||
|
|
||||||
|
std::vector<uint32> vals;
|
||||||
|
vals.push_back(0x12345678);
|
||||||
|
vals.push_back(0x01020304);
|
||||||
|
|
||||||
|
buf.putArray(&vals[0], vals.size());
|
||||||
|
testEqual(buf.getPosition(), 8);
|
||||||
|
|
||||||
|
testOk1(memcmp(buf.getBuffer(), "\x12\x34\x56\x78\x01\x02\x03\x04", 8)==0);
|
||||||
|
|
||||||
|
buf.clear();
|
||||||
|
buf.put("\x10\x20\x30\x40\xa1\xa2\xa3\xa4", 0, 8);
|
||||||
|
buf.flip();
|
||||||
|
|
||||||
|
buf.getArray(&vals[0], 2);
|
||||||
|
|
||||||
|
testEqual(vals[0], 0x10203040);
|
||||||
|
testEqual(vals[1], 0xa1a2a3a4);
|
||||||
|
}
|
||||||
|
|
||||||
MAIN(testByteBuffer)
|
MAIN(testByteBuffer)
|
||||||
{
|
{
|
||||||
testPlan(96);
|
testPlan(104);
|
||||||
testDiag("Tests byteBuffer");
|
testDiag("Tests byteBuffer");
|
||||||
testBasicOperations();
|
testBasicOperations();
|
||||||
testInverseEndianness(EPICS_ENDIAN_BIG, expect_be);
|
testInverseEndianness(EPICS_ENDIAN_BIG, expect_be);
|
||||||
testInverseEndianness(EPICS_ENDIAN_LITTLE, expect_le);
|
testInverseEndianness(EPICS_ENDIAN_LITTLE, expect_le);
|
||||||
testSwap();
|
testSwap();
|
||||||
testUnaligned();
|
testUnaligned();
|
||||||
|
testArrayLE();
|
||||||
|
testArrayBE();
|
||||||
return testDone();
|
return testDone();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,15 +17,14 @@
|
|||||||
|
|
||||||
#include "pv/sharedVector.h"
|
#include "pv/sharedVector.h"
|
||||||
|
|
||||||
using std::string;
|
|
||||||
using namespace epics::pvData;
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
namespace pvd = epics::pvData;
|
||||||
|
|
||||||
void testEmpty()
|
void testEmpty()
|
||||||
{
|
{
|
||||||
testDiag("Test empty vector");
|
testDiag("Test empty vector");
|
||||||
epics::pvData::shared_vector<int32> empty, empty2, empty3(0u);
|
pvd::shared_vector<pvd::int32> empty, empty2, empty3(0u);
|
||||||
|
|
||||||
testOk1(empty.size()==0);
|
testOk1(empty.size()==0);
|
||||||
testOk1(empty.empty());
|
testOk1(empty.empty());
|
||||||
@@ -47,7 +46,7 @@ void testInternalAlloc()
|
|||||||
{
|
{
|
||||||
testDiag("Test vector alloc w/ new[]");
|
testDiag("Test vector alloc w/ new[]");
|
||||||
|
|
||||||
epics::pvData::shared_vector<int32> internal(5);
|
pvd::shared_vector<pvd::int32> internal(5);
|
||||||
|
|
||||||
testOk1(internal.size()==5);
|
testOk1(internal.size()==5);
|
||||||
testOk1(!internal.empty());
|
testOk1(!internal.empty());
|
||||||
@@ -62,7 +61,7 @@ void testInternalAlloc()
|
|||||||
internal[2] = 42;
|
internal[2] = 42;
|
||||||
testOk1(internal[2]==42);
|
testOk1(internal[2]==42);
|
||||||
|
|
||||||
epics::pvData::shared_vector<int32> internal2(15, 500);
|
pvd::shared_vector<pvd::int32> internal2(15, 500);
|
||||||
|
|
||||||
testOk1(internal2.size()==15);
|
testOk1(internal2.size()==15);
|
||||||
testOk1(internal2[1]==500);
|
testOk1(internal2[1]==500);
|
||||||
@@ -83,8 +82,8 @@ void testInternalAlloc()
|
|||||||
//Note: STL shared_ptr requires that deletors be copy constructable
|
//Note: STL shared_ptr requires that deletors be copy constructable
|
||||||
template<typename E>
|
template<typename E>
|
||||||
struct callCounter {
|
struct callCounter {
|
||||||
std::tr1::shared_ptr<int32> count;
|
std::tr1::shared_ptr<pvd::int32> count;
|
||||||
callCounter():count(new int32){*count=0;}
|
callCounter():count(new pvd::int32){*count=0;}
|
||||||
callCounter(const callCounter& o):count(o.count) {}
|
callCounter(const callCounter& o):count(o.count) {}
|
||||||
callCounter& operator=(const callCounter& o){count=o.count;}
|
callCounter& operator=(const callCounter& o){count=o.count;}
|
||||||
void operator()(E){(*count)++;}
|
void operator()(E){(*count)++;}
|
||||||
@@ -95,8 +94,8 @@ void testExternalAlloc()
|
|||||||
testDiag("Test vector external alloc");
|
testDiag("Test vector external alloc");
|
||||||
|
|
||||||
// Simulate a failed malloc() or similar
|
// Simulate a failed malloc() or similar
|
||||||
int32 *oops=0;
|
pvd::int32 *oops=0;
|
||||||
epics::pvData::shared_vector<int32> nullPtr(oops, 42, 100);
|
pvd::shared_vector<pvd::int32> nullPtr(oops, 42, 100);
|
||||||
|
|
||||||
testOk1(nullPtr.size()==0);
|
testOk1(nullPtr.size()==0);
|
||||||
testOk1(nullPtr.empty());
|
testOk1(nullPtr.empty());
|
||||||
@@ -105,8 +104,8 @@ void testExternalAlloc()
|
|||||||
|
|
||||||
testOk1(nullPtr.data()==NULL);
|
testOk1(nullPtr.data()==NULL);
|
||||||
|
|
||||||
int32 *raw=new int32[5];
|
pvd::int32 *raw=new pvd::int32[5];
|
||||||
epics::pvData::shared_vector<int32> newData(raw, 1, 4);
|
pvd::shared_vector<pvd::int32> newData(raw, 1, 4);
|
||||||
|
|
||||||
testOk1(newData.size()==4);
|
testOk1(newData.size()==4);
|
||||||
testOk1(!newData.empty());
|
testOk1(!newData.empty());
|
||||||
@@ -116,11 +115,11 @@ void testExternalAlloc()
|
|||||||
testOk1(newData[0]==14);
|
testOk1(newData[0]==14);
|
||||||
|
|
||||||
// Check use of custom deleter
|
// Check use of custom deleter
|
||||||
int32 localVar[4] = {1,2,3,4};
|
pvd::int32 localVar[4] = {1,2,3,4};
|
||||||
callCounter<int32*> tracker;
|
callCounter<pvd::int32*> tracker;
|
||||||
testOk1(*tracker.count==0);
|
testOk1(*tracker.count==0);
|
||||||
|
|
||||||
epics::pvData::shared_vector<int32> locvar(localVar,
|
pvd::shared_vector<pvd::int32> locvar(localVar,
|
||||||
tracker,
|
tracker,
|
||||||
0, 4);
|
0, 4);
|
||||||
|
|
||||||
@@ -140,8 +139,8 @@ void testShare()
|
|||||||
{
|
{
|
||||||
testDiag("Test vector Sharing");
|
testDiag("Test vector Sharing");
|
||||||
|
|
||||||
epics::pvData::shared_vector<int32> one, two(15);
|
pvd::shared_vector<pvd::int32> one, two(15);
|
||||||
epics::pvData::shared_vector<int32> three(two);
|
pvd::shared_vector<pvd::int32> three(two);
|
||||||
|
|
||||||
testOk1(one.unique());
|
testOk1(one.unique());
|
||||||
testOk1(!two.unique());
|
testOk1(!two.unique());
|
||||||
@@ -202,22 +201,22 @@ void testConst()
|
|||||||
{
|
{
|
||||||
testDiag("Test constant vector");
|
testDiag("Test constant vector");
|
||||||
|
|
||||||
epics::pvData::shared_vector<int32> writable(15, 100);
|
pvd::shared_vector<pvd::int32> writable(15, 100);
|
||||||
|
|
||||||
epics::pvData::shared_vector<int32>::reference wr = writable[0];
|
pvd::shared_vector<pvd::int32>::reference wr = writable[0];
|
||||||
epics::pvData::shared_vector<int32>::const_reference ror = writable[0];
|
pvd::shared_vector<pvd::int32>::const_reference ror = writable[0];
|
||||||
|
|
||||||
testOk1(wr==ror);
|
testOk1(wr==ror);
|
||||||
|
|
||||||
int32 *compare = writable.data();
|
pvd::int32 *compare = writable.data();
|
||||||
|
|
||||||
testOk1(writable.unique());
|
testOk1(writable.unique());
|
||||||
|
|
||||||
// can re-target container, but data is R/O
|
// can re-target container, but data is R/O
|
||||||
epics::pvData::shared_vector<const int32> rodata(freeze(writable));
|
pvd::shared_vector<const pvd::int32> rodata(freeze(writable));
|
||||||
|
|
||||||
epics::pvData::shared_vector<const int32>::reference wcr = rodata[0];
|
pvd::shared_vector<const pvd::int32>::reference wcr = rodata[0];
|
||||||
epics::pvData::shared_vector<const int32>::const_reference rocr = rodata[0];
|
pvd::shared_vector<const pvd::int32>::const_reference rocr = rodata[0];
|
||||||
|
|
||||||
testOk1(wcr==rocr);
|
testOk1(wcr==rocr);
|
||||||
|
|
||||||
@@ -230,7 +229,7 @@ void testConst()
|
|||||||
|
|
||||||
testOk1(rodata.data()==compare);
|
testOk1(rodata.data()==compare);
|
||||||
|
|
||||||
epics::pvData::shared_vector<const int32> rodata2(rodata);
|
pvd::shared_vector<const pvd::int32> rodata2(rodata);
|
||||||
|
|
||||||
testOk1(rodata.data()==rodata2.data());
|
testOk1(rodata.data()==rodata2.data());
|
||||||
|
|
||||||
@@ -243,9 +242,9 @@ void testSlice()
|
|||||||
{
|
{
|
||||||
testDiag("Test vector slicing");
|
testDiag("Test vector slicing");
|
||||||
|
|
||||||
epics::pvData::shared_vector<int32> original(10, 100);
|
pvd::shared_vector<pvd::int32> original(10, 100);
|
||||||
|
|
||||||
epics::pvData::shared_vector<int32> half1(original), half2(original), half2a(original);
|
pvd::shared_vector<pvd::int32> half1(original), half2(original), half2a(original);
|
||||||
|
|
||||||
half1.slice(0, 5);
|
half1.slice(0, 5);
|
||||||
half2.slice(5, 5);
|
half2.slice(5, 5);
|
||||||
@@ -293,9 +292,9 @@ void testCapacity()
|
|||||||
{
|
{
|
||||||
testDiag("Test vector capacity");
|
testDiag("Test vector capacity");
|
||||||
|
|
||||||
epics::pvData::shared_vector<int32> vect(10, 100);
|
pvd::shared_vector<pvd::int32> vect(10, 100);
|
||||||
|
|
||||||
int32 *peek = vect.dataPtr().get();
|
pvd::int32 *peek = vect.dataPtr().get();
|
||||||
|
|
||||||
vect.slice(0, 5);
|
vect.slice(0, 5);
|
||||||
|
|
||||||
@@ -333,7 +332,7 @@ void testCapacity()
|
|||||||
|
|
||||||
void testPush()
|
void testPush()
|
||||||
{
|
{
|
||||||
epics::pvData::shared_vector<int32> vect;
|
pvd::shared_vector<pvd::int32> vect;
|
||||||
|
|
||||||
testDiag("Test push_back optimizations");
|
testDiag("Test push_back optimizations");
|
||||||
|
|
||||||
@@ -360,16 +359,16 @@ void testVoid()
|
|||||||
{
|
{
|
||||||
testDiag("Test vector cast to/from void");
|
testDiag("Test vector cast to/from void");
|
||||||
|
|
||||||
epics::pvData::shared_vector<int32> IV(4);
|
pvd::shared_vector<pvd::int32> IV(4);
|
||||||
|
|
||||||
epics::pvData::shared_vector<void> VV(epics::pvData::static_shared_vector_cast<void>(IV));
|
pvd::shared_vector<void> VV(pvd::static_shared_vector_cast<void>(IV));
|
||||||
|
|
||||||
testOk1(IV.dataPtr().get()==VV.dataPtr().get());
|
testOk1(IV.dataPtr().get()==VV.dataPtr().get());
|
||||||
testOk1(IV.size()*sizeof(int)==VV.size());
|
testOk1(IV.size()*sizeof(pvd::int32)==VV.size());
|
||||||
|
|
||||||
VV.slice(sizeof(int), 2*sizeof(int));
|
VV.slice(sizeof(pvd::int32), 2*sizeof(pvd::int32));
|
||||||
|
|
||||||
IV = epics::pvData::static_shared_vector_cast<int32>(VV);
|
IV = pvd::static_shared_vector_cast<pvd::int32>(VV);
|
||||||
|
|
||||||
testOk1(IV.dataOffset()==1);
|
testOk1(IV.dataOffset()==1);
|
||||||
testOk1(IV.size()==2);
|
testOk1(IV.size()==2);
|
||||||
@@ -380,23 +379,23 @@ void testConstVoid()
|
|||||||
{
|
{
|
||||||
testDiag("Test vector cast to/from const void");
|
testDiag("Test vector cast to/from const void");
|
||||||
|
|
||||||
epics::pvData::shared_vector<const int32> CIV(4);
|
pvd::shared_vector<const pvd::int32> CIV(4);
|
||||||
|
|
||||||
epics::pvData::shared_vector<const void> CVV(epics::pvData::static_shared_vector_cast<const void>(CIV));
|
pvd::shared_vector<const void> CVV(pvd::static_shared_vector_cast<const void>(CIV));
|
||||||
// case const void to const void
|
// case const void to const void
|
||||||
epics::pvData::shared_vector<const void> CVV2(epics::pvData::static_shared_vector_cast<const void>(CVV));
|
pvd::shared_vector<const void> CVV2(pvd::static_shared_vector_cast<const void>(CVV));
|
||||||
|
|
||||||
testOk1(CIV.dataPtr().get()==CVV2.dataPtr().get());
|
testOk1(CIV.dataPtr().get()==CVV2.dataPtr().get());
|
||||||
testOk1(CIV.size()*sizeof(int)==CVV2.size());
|
testOk1(CIV.size()*sizeof(int)==CVV2.size());
|
||||||
|
|
||||||
CVV2.slice(sizeof(int), 2*sizeof(int));
|
CVV2.slice(sizeof(int), 2*sizeof(int));
|
||||||
|
|
||||||
CIV = epics::pvData::static_shared_vector_cast<const int32>(CVV2);
|
CIV = pvd::static_shared_vector_cast<const pvd::int32>(CVV2);
|
||||||
|
|
||||||
testOk1(CIV.dataOffset()==1);
|
testOk1(CIV.dataOffset()==1);
|
||||||
testOk1(CIV.size()==2);
|
testOk1(CIV.size()==2);
|
||||||
|
|
||||||
epics::pvData::shared_vector<void> VV;
|
pvd::shared_vector<void> VV;
|
||||||
// not possible to thaw() void as shared_vector<void> has no make_unique()
|
// not possible to thaw() void as shared_vector<void> has no make_unique()
|
||||||
//VV = thaw(CVV);
|
//VV = thaw(CVV);
|
||||||
CVV = freeze(VV);
|
CVV = freeze(VV);
|
||||||
@@ -408,8 +407,8 @@ void testNonPOD()
|
|||||||
{
|
{
|
||||||
testDiag("Test vector of non-POD types");
|
testDiag("Test vector of non-POD types");
|
||||||
|
|
||||||
epics::pvData::shared_vector<string> strings(6);
|
pvd::shared_vector<std::string> strings(6);
|
||||||
epics::pvData::shared_vector<std::tr1::shared_ptr<dummyStruct> > structs(5);
|
pvd::shared_vector<std::tr1::shared_ptr<dummyStruct> > structs(5);
|
||||||
|
|
||||||
testOk1(strings[0].empty());
|
testOk1(strings[0].empty());
|
||||||
testOk1(structs[0].get()==NULL);
|
testOk1(structs[0].get()==NULL);
|
||||||
@@ -417,7 +416,7 @@ void testNonPOD()
|
|||||||
structs[1].reset(new dummyStruct);
|
structs[1].reset(new dummyStruct);
|
||||||
dummyStruct *temp = structs[1].get();
|
dummyStruct *temp = structs[1].get();
|
||||||
|
|
||||||
epics::pvData::shared_vector<std::tr1::shared_ptr<dummyStruct> > structs2(structs);
|
pvd::shared_vector<std::tr1::shared_ptr<dummyStruct> > structs2(structs);
|
||||||
|
|
||||||
testOk1(!structs.unique());
|
testOk1(!structs.unique());
|
||||||
testOk1(structs[1].unique());
|
testOk1(structs[1].unique());
|
||||||
@@ -436,22 +435,22 @@ void testVectorConvert()
|
|||||||
{
|
{
|
||||||
testDiag("Test shared_vector_convert");
|
testDiag("Test shared_vector_convert");
|
||||||
|
|
||||||
epics::pvData::shared_vector<int32> ints(6, 42), moreints;
|
pvd::shared_vector<pvd::int32> ints(6, 42), moreints;
|
||||||
epics::pvData::shared_vector<float> floats;
|
pvd::shared_vector<float> floats;
|
||||||
epics::pvData::shared_vector<string> strings;
|
pvd::shared_vector<std::string> strings;
|
||||||
epics::pvData::shared_vector<void> voids;
|
pvd::shared_vector<void> voids;
|
||||||
|
|
||||||
testOk1(ints.unique());
|
testOk1(ints.unique());
|
||||||
|
|
||||||
// no-op convert. Just returns another reference
|
// no-op convert. Just returns another reference
|
||||||
moreints = epics::pvData::shared_vector_convert<int32>(ints);
|
moreints = pvd::shared_vector_convert<pvd::int32>(ints);
|
||||||
|
|
||||||
testOk1(!ints.unique());
|
testOk1(!ints.unique());
|
||||||
moreints.clear();
|
moreints.clear();
|
||||||
|
|
||||||
// conversion when both types are known.
|
// conversion when both types are known.
|
||||||
// returns a new vector
|
// returns a new vector
|
||||||
floats = epics::pvData::shared_vector_convert<float>(ints);
|
floats = pvd::shared_vector_convert<float>(ints);
|
||||||
|
|
||||||
testOk1(ints.unique());
|
testOk1(ints.unique());
|
||||||
testOk1(floats.size()==ints.size());
|
testOk1(floats.size()==ints.size());
|
||||||
@@ -459,16 +458,16 @@ void testVectorConvert()
|
|||||||
|
|
||||||
// convert to void is static_shared_vector_cast<void>()
|
// convert to void is static_shared_vector_cast<void>()
|
||||||
// returns a reference
|
// returns a reference
|
||||||
voids = epics::pvData::shared_vector_convert<void>(ints);
|
voids = pvd::shared_vector_convert<void>(ints);
|
||||||
|
|
||||||
testOk1(!ints.unique());
|
testOk1(!ints.unique());
|
||||||
testOk1(voids.size()==ints.size()*sizeof(int32));
|
testOk1(voids.size()==ints.size()*sizeof(pvd::int32));
|
||||||
|
|
||||||
// convert from void uses shared_vector<void>::original_type()
|
// convert from void uses shared_vector<void>::original_type()
|
||||||
// to find that the actual type is 'int32'.
|
// to find that the actual type is 'int32'.
|
||||||
// returns a new vector
|
// returns a new vector
|
||||||
testOk1(voids.original_type()==epics::pvData::pvInt);
|
testOk1(voids.original_type()==pvd::pvInt);
|
||||||
strings = epics::pvData::shared_vector_convert<string>(voids);
|
strings = pvd::shared_vector_convert<std::string>(voids);
|
||||||
|
|
||||||
voids.clear();
|
voids.clear();
|
||||||
|
|
||||||
@@ -481,11 +480,11 @@ void testWeak()
|
|||||||
{
|
{
|
||||||
testDiag("Test weak_ptr counting");
|
testDiag("Test weak_ptr counting");
|
||||||
|
|
||||||
epics::pvData::shared_vector<int32> data(6);
|
pvd::shared_vector<pvd::int32> data(6);
|
||||||
|
|
||||||
testOk1(data.unique());
|
testOk1(data.unique());
|
||||||
|
|
||||||
std::tr1::shared_ptr<int32> pdata(data.dataPtr());
|
std::tr1::shared_ptr<pvd::int32> pdata(data.dataPtr());
|
||||||
|
|
||||||
testOk1(!data.unique());
|
testOk1(!data.unique());
|
||||||
|
|
||||||
@@ -493,7 +492,7 @@ void testWeak()
|
|||||||
|
|
||||||
testOk1(data.unique());
|
testOk1(data.unique());
|
||||||
|
|
||||||
std::tr1::weak_ptr<int32> wdata(data.dataPtr());
|
std::tr1::weak_ptr<pvd::int32> wdata(data.dataPtr());
|
||||||
|
|
||||||
testOk1(data.unique()); // True, but I wish it wasn't!!!
|
testOk1(data.unique()); // True, but I wish it wasn't!!!
|
||||||
|
|
||||||
@@ -506,16 +505,16 @@ void testICE()
|
|||||||
{
|
{
|
||||||
testDiag("Test freeze and thaw");
|
testDiag("Test freeze and thaw");
|
||||||
|
|
||||||
epics::pvData::shared_vector<int32> A(6, 42), C;
|
pvd::shared_vector<pvd::int32> A(6, 42), C;
|
||||||
epics::pvData::shared_vector<const int32> B, D;
|
pvd::shared_vector<const pvd::int32> B, D;
|
||||||
|
|
||||||
int32 *check = A.data();
|
pvd::int32 *check = A.data();
|
||||||
|
|
||||||
// check freeze w/ unique reference
|
// check freeze w/ unique reference
|
||||||
|
|
||||||
// clears A and moves reference to B
|
// clears A and moves reference to B
|
||||||
// no copy
|
// no copy
|
||||||
B = epics::pvData::freeze(A);
|
B = pvd::freeze(A);
|
||||||
|
|
||||||
testOk1(A.unique());
|
testOk1(A.unique());
|
||||||
testOk1(B.unique());
|
testOk1(B.unique());
|
||||||
@@ -528,7 +527,7 @@ void testICE()
|
|||||||
|
|
||||||
// clears D, but reference to B
|
// clears D, but reference to B
|
||||||
// remains, so a copy is made
|
// remains, so a copy is made
|
||||||
C = epics::pvData::thaw(D);
|
C = pvd::thaw(D);
|
||||||
|
|
||||||
testOk1(B.unique());
|
testOk1(B.unique());
|
||||||
testOk1(C.unique());
|
testOk1(C.unique());
|
||||||
@@ -542,7 +541,7 @@ void testICE()
|
|||||||
|
|
||||||
// clears B and moves reference to A
|
// clears B and moves reference to A
|
||||||
// no copy
|
// no copy
|
||||||
A = epics::pvData::thaw(B);
|
A = pvd::thaw(B);
|
||||||
|
|
||||||
testOk1(A.unique());
|
testOk1(A.unique());
|
||||||
testOk1(B.unique());
|
testOk1(B.unique());
|
||||||
@@ -559,7 +558,7 @@ void testICE()
|
|||||||
// would clear A, but remaining reference C
|
// would clear A, but remaining reference C
|
||||||
// fails operation. A not cleared
|
// fails operation. A not cleared
|
||||||
// and exception thrown
|
// and exception thrown
|
||||||
B = epics::pvData::freeze(A);
|
B = pvd::freeze(A);
|
||||||
testFail("Froze non-unique vector!");
|
testFail("Froze non-unique vector!");
|
||||||
} catch(std::runtime_error& e) {
|
} catch(std::runtime_error& e) {
|
||||||
testPass("freeze of non-unique throws runtime_error as expected");
|
testPass("freeze of non-unique throws runtime_error as expected");
|
||||||
@@ -568,12 +567,12 @@ void testICE()
|
|||||||
|
|
||||||
void testBad()
|
void testBad()
|
||||||
{
|
{
|
||||||
epics::pvData::shared_vector<int> I;
|
pvd::shared_vector<int> I;
|
||||||
epics::pvData::shared_vector<const int> CI;
|
pvd::shared_vector<const int> CI;
|
||||||
epics::pvData::shared_vector<float> F;
|
pvd::shared_vector<float> F;
|
||||||
epics::pvData::shared_vector<const float> CF;
|
pvd::shared_vector<const float> CF;
|
||||||
epics::pvData::shared_vector<void> V;
|
pvd::shared_vector<void> V;
|
||||||
epics::pvData::shared_vector<const void> CV;
|
pvd::shared_vector<const void> CV;
|
||||||
(void)I;
|
(void)I;
|
||||||
(void)CI;
|
(void)CI;
|
||||||
(void)F;
|
(void)F;
|
||||||
@@ -588,38 +587,38 @@ void testBad()
|
|||||||
// No copy from const to non-const
|
// No copy from const to non-const
|
||||||
//CI = I;
|
//CI = I;
|
||||||
//I = CI;
|
//I = CI;
|
||||||
//epics::pvData::shared_vector<const int> CI2(I);
|
//pvd::shared_vector<const int> CI2(I);
|
||||||
//epics::pvData::shared_vector<int> I2(CI);
|
//pvd::shared_vector<int> I2(CI);
|
||||||
|
|
||||||
// shared_vector_convert can't thaw()
|
// shared_vector_convert can't thaw()
|
||||||
//I = epics::pvData::shared_vector_convert<int>(CI);
|
//I = pvd::shared_vector_convert<int>(CI);
|
||||||
//V = epics::pvData::shared_vector_convert<void>(CV);
|
//V = pvd::shared_vector_convert<void>(CV);
|
||||||
|
|
||||||
// shared_vector_convert can't freeze()
|
// shared_vector_convert can't freeze()
|
||||||
//CI = epics::pvData::shared_vector_convert<const int>(I);
|
//CI = pvd::shared_vector_convert<const int>(I);
|
||||||
//CV = epics::pvData::shared_vector_convert<const void>(V);
|
//CV = pvd::shared_vector_convert<const void>(V);
|
||||||
|
|
||||||
// static_shared_vector_cast can't thaw()
|
// static_shared_vector_cast can't thaw()
|
||||||
//I = epics::pvData::static_shared_vector_cast<int>(CI);
|
//I = pvd::static_shared_vector_cast<int>(CI);
|
||||||
//V = epics::pvData::static_shared_vector_cast<void>(CV);
|
//V = pvd::static_shared_vector_cast<void>(CV);
|
||||||
|
|
||||||
// static_shared_vector_cast can't freeze()
|
// static_shared_vector_cast can't freeze()
|
||||||
//CI = epics::pvData::static_shared_vector_cast<const int>(I);
|
//CI = pvd::static_shared_vector_cast<const int>(I);
|
||||||
//CV = epics::pvData::static_shared_vector_cast<const void>(V);
|
//CV = pvd::static_shared_vector_cast<const void>(V);
|
||||||
|
|
||||||
// freeze() can't change type.
|
// freeze() can't change type.
|
||||||
// the error here will be with the assignment
|
// the error here will be with the assignment
|
||||||
//I = epics::pvData::freeze(CV);
|
//I = pvd::freeze(CV);
|
||||||
//I = epics::pvData::freeze(CF);
|
//I = pvd::freeze(CF);
|
||||||
//CI = epics::pvData::freeze(V);
|
//CI = pvd::freeze(V);
|
||||||
//CI = epics::pvData::freeze(F);
|
//CI = pvd::freeze(F);
|
||||||
|
|
||||||
// that() can't change type.
|
// that() can't change type.
|
||||||
// the error here will be with the assignment
|
// the error here will be with the assignment
|
||||||
//CI = epics::pvData::thaw(V);
|
//CI = pvd::thaw(V);
|
||||||
//CI = epics::pvData::thaw(F);
|
//CI = pvd::thaw(F);
|
||||||
//I = epics::pvData::thaw(CV);
|
//I = pvd::thaw(CV);
|
||||||
//I = epics::pvData::that(CF);
|
//I = pvd::that(CF);
|
||||||
}
|
}
|
||||||
|
|
||||||
void testAutoSwap()
|
void testAutoSwap()
|
||||||
@@ -636,8 +635,8 @@ void testCXX11Move()
|
|||||||
{
|
{
|
||||||
#if __cplusplus>=201103L
|
#if __cplusplus>=201103L
|
||||||
testDiag("Check std::move()");
|
testDiag("Check std::move()");
|
||||||
shared_vector<int32> A(4, 42),
|
pvd::shared_vector<pvd::int32> A(4, 42),
|
||||||
B(std::move(A));
|
B(std::move(A));
|
||||||
|
|
||||||
testOk1(A.unique());
|
testOk1(A.unique());
|
||||||
testOk1(B.unique());
|
testOk1(B.unique());
|
||||||
@@ -653,8 +652,8 @@ void testCXX11Move()
|
|||||||
testOk1(A.size()==4);
|
testOk1(A.size()==4);
|
||||||
testOk1(!A.empty() && A[0]==42);
|
testOk1(!A.empty() && A[0]==42);
|
||||||
|
|
||||||
shared_vector<void> C(shared_vector_convert<void>(A)),
|
pvd::shared_vector<void> C(pvd::shared_vector_convert<void>(A)),
|
||||||
D(std::move(C));
|
D(std::move(C));
|
||||||
A.clear();
|
A.clear();
|
||||||
|
|
||||||
testOk1(C.unique());
|
testOk1(C.unique());
|
||||||
@@ -678,11 +677,11 @@ void testCXX11Init()
|
|||||||
#if __cplusplus>=201103L
|
#if __cplusplus>=201103L
|
||||||
testDiag("Check c++11 style array initialization");
|
testDiag("Check c++11 style array initialization");
|
||||||
|
|
||||||
shared_vector<const int32> A = {1.0, 2.0, 3.0};
|
pvd::shared_vector<const pvd::int32> A = {1.0, 2.0, 3.0};
|
||||||
|
|
||||||
testOk1(A.size()==3);
|
testOk1(A.size()==3);
|
||||||
|
|
||||||
int32 sum = 0;
|
pvd::int32 sum = 0;
|
||||||
for (auto V: A) {
|
for (auto V: A) {
|
||||||
sum += V;
|
sum += V;
|
||||||
}
|
}
|
||||||
@@ -699,8 +698,8 @@ MAIN(testSharedVector)
|
|||||||
testPlan(191);
|
testPlan(191);
|
||||||
testDiag("Tests for shared_vector");
|
testDiag("Tests for shared_vector");
|
||||||
|
|
||||||
testDiag("sizeof(shared_vector<int32>)=%lu",
|
testDiag("sizeof(shared_vector<pvd::int32>)=%lu",
|
||||||
(unsigned long)sizeof(epics::pvData::shared_vector<int32>));
|
(unsigned long)sizeof(pvd::shared_vector<pvd::int32>));
|
||||||
|
|
||||||
testEmpty();
|
testEmpty();
|
||||||
testInternalAlloc();
|
testInternalAlloc();
|
||||||
|
|||||||
Reference in New Issue
Block a user