From 35f139ff64d696c2ce8b2056fd328dd5bd884bda Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Thu, 5 Aug 1999 15:30:27 +0000 Subject: [PATCH] upgraded tests --- src/cxxTemplates/test/Makefile.Host | 5 +- src/cxxTemplates/test/resourceLibTest.cc | 141 +++++++++--------- src/cxxTemplates/test/tsBTreeBench.cc | 1 + src/cxxTemplates/test/tsBTreeTest.cc | 1 + .../cxxTemplates/test/resourceLibTest.cc | 141 +++++++++--------- src/libCom/cxxTemplates/test/tsBTreeBench.cc | 1 + src/libCom/cxxTemplates/test/tsBTreeTest.cc | 1 + 7 files changed, 148 insertions(+), 143 deletions(-) diff --git a/src/cxxTemplates/test/Makefile.Host b/src/cxxTemplates/test/Makefile.Host index ee74ebf15..fc9894d55 100644 --- a/src/cxxTemplates/test/Makefile.Host +++ b/src/cxxTemplates/test/Makefile.Host @@ -5,10 +5,9 @@ include $(TOP)/config/CONFIG_BASE CXXCMPLR = STRICT PROD_LIBS = Com -SYS_PROD_LIBS_WIN32 := ws2_32 advapi32 -TESTPROD := resourceLibTest tsDLListBench tsDLListTest tsDLListTest \ - tsSLListBench tsSLListTest minmaxTest tsBTreeBench tsBTreeTest +TESTPROD := tsSLListTest tsDLListTest resourceLibTest tsDLListBench tsDLListBench \ + tsSLListBench minmaxTest tsBTreeBench tsBTreeTest include $(TOP)/config/RULES.Host diff --git a/src/cxxTemplates/test/resourceLibTest.cc b/src/cxxTemplates/test/resourceLibTest.cc index 9d83b3e28..b503fb6f8 100644 --- a/src/cxxTemplates/test/resourceLibTest.cc +++ b/src/cxxTemplates/test/resourceLibTest.cc @@ -5,7 +5,8 @@ #include #include -#define INSTANCIATE_RES_LIB_STATIC +#define epicsExportSharedSymbols +#define instantiateRecourceLib #include "resourceLib.h" #ifdef SUNOS4 @@ -16,10 +17,10 @@ void empty(); -class albert : public uintId, public tsSLNode { +class albert : public intId, public tsSLNode { public: - albert (resTable &atIn, unsigned idIn) : - at(atIn), uintId(idIn) {} + albert (resTable< albert, intId > &atIn, unsigned idIn) : + at(atIn), intId(idIn) {} void show (unsigned level) { } @@ -29,13 +30,13 @@ public: delete this; } private: - resTable &at; + resTable< albert, intId > &at; }; -class fred : public uintId, public tsSLNode { +class fred : public intId, public tsSLNode { public: fred (const char *pNameIn, unsigned idIn) : - pName(pNameIn), uintId(idIn) {} + pName(pNameIn), intId(idIn) {} void show (unsigned) { printf("fred %s\n", pName); @@ -80,7 +81,7 @@ void jane::testTraverse() // This explicitly instantiates the template class's member // functions into "templInst.o" // - template class resTable; + template class resTable>; template class resTable; #endif @@ -90,52 +91,69 @@ main() clock_t start, finish; double duration; const int LOOPS = 50000; - resTable intTbl; - resTable strTbl; + resTable > intTbl (8); + resTable strTbl (8); + fred fred0("fred0",0); fred fred1("fred1",0x1000a432); fred fred2("fred2",0x0000a432); + fred fred3("fred3",1); + fred fred4("fred4",2); + fred fred5("fred5",3); + fred fred6("fred6",4); + fred fred7("fred7",5); + fred fred8("fred8",6); + fred fred9("fred9",7); jane jane1("rrrrrrrrrrrrrrrrrrrrrrrrrr1"); jane jane2("rrrrrrrrrrrrrrrrrrrrrrrrrr2"); fred *pFred; jane *pJane; - uintId uintId1(0x1000a432); - uintId uintId2(0x0000a432); + intId intId0 (0); + intId intId1 (0x1000a432); + intId intId2 (0x0000a432); + intId intId3 (1); + intId intId4 (2); + intId intId5 (3); + intId intId6 (4); + intId intId7 (5); + intId intId8 (6); + intId intId9 (7); + stringId strId1("rrrrrrrrrrrrrrrrrrrrrrrrrr1"); stringId strId2("rrrrrrrrrrrrrrrrrrrrrrrrrr2"); - int status; - - status = intTbl.init(8); - if (status) { - return -1; - } - - status = intTbl.add(fred1); - assert (!status); - status = intTbl.add(fred2); - assert (!status); + + assert (intTbl.add(fred0)==0); + assert (intTbl.add(fred1)==0); + assert (intTbl.add(fred2)==0); + assert (intTbl.add(fred3)==0); + assert (intTbl.add(fred4)==0); + assert (intTbl.add(fred5)==0); + assert (intTbl.add(fred6)==0); + assert (intTbl.add(fred7)==0); + assert (intTbl.add(fred8)==0); + assert (intTbl.add(fred9)==0); start = clock(); for (i=0; i alTbl; - status = alTbl.init(10000); - assert(!status); + static const unsigned tableSize = 0x1000; + resTable< albert, intId > alTbl (tableSize); - for(i=0; i<100000; i++) { - unsigned id = (unsigned) rand(); - albert *pa = new albert(alTbl, id); - assert(pa); - status = alTbl.add(*pa); - if (status) { - // - // duplicate ids are possible - // and ignored - // - delete pa; - } + for (i=0; i #include #include +#include #include "tsBTree.h" #include "tsSLList.h" diff --git a/src/cxxTemplates/test/tsBTreeTest.cc b/src/cxxTemplates/test/tsBTreeTest.cc index 845575f8f..7d0d2a3e6 100644 --- a/src/cxxTemplates/test/tsBTreeTest.cc +++ b/src/cxxTemplates/test/tsBTreeTest.cc @@ -1,6 +1,7 @@ #include #include +#include #include "tsBTree.h" diff --git a/src/libCom/cxxTemplates/test/resourceLibTest.cc b/src/libCom/cxxTemplates/test/resourceLibTest.cc index 9d83b3e28..b503fb6f8 100644 --- a/src/libCom/cxxTemplates/test/resourceLibTest.cc +++ b/src/libCom/cxxTemplates/test/resourceLibTest.cc @@ -5,7 +5,8 @@ #include #include -#define INSTANCIATE_RES_LIB_STATIC +#define epicsExportSharedSymbols +#define instantiateRecourceLib #include "resourceLib.h" #ifdef SUNOS4 @@ -16,10 +17,10 @@ void empty(); -class albert : public uintId, public tsSLNode { +class albert : public intId, public tsSLNode { public: - albert (resTable &atIn, unsigned idIn) : - at(atIn), uintId(idIn) {} + albert (resTable< albert, intId > &atIn, unsigned idIn) : + at(atIn), intId(idIn) {} void show (unsigned level) { } @@ -29,13 +30,13 @@ public: delete this; } private: - resTable &at; + resTable< albert, intId > &at; }; -class fred : public uintId, public tsSLNode { +class fred : public intId, public tsSLNode { public: fred (const char *pNameIn, unsigned idIn) : - pName(pNameIn), uintId(idIn) {} + pName(pNameIn), intId(idIn) {} void show (unsigned) { printf("fred %s\n", pName); @@ -80,7 +81,7 @@ void jane::testTraverse() // This explicitly instantiates the template class's member // functions into "templInst.o" // - template class resTable; + template class resTable>; template class resTable; #endif @@ -90,52 +91,69 @@ main() clock_t start, finish; double duration; const int LOOPS = 50000; - resTable intTbl; - resTable strTbl; + resTable > intTbl (8); + resTable strTbl (8); + fred fred0("fred0",0); fred fred1("fred1",0x1000a432); fred fred2("fred2",0x0000a432); + fred fred3("fred3",1); + fred fred4("fred4",2); + fred fred5("fred5",3); + fred fred6("fred6",4); + fred fred7("fred7",5); + fred fred8("fred8",6); + fred fred9("fred9",7); jane jane1("rrrrrrrrrrrrrrrrrrrrrrrrrr1"); jane jane2("rrrrrrrrrrrrrrrrrrrrrrrrrr2"); fred *pFred; jane *pJane; - uintId uintId1(0x1000a432); - uintId uintId2(0x0000a432); + intId intId0 (0); + intId intId1 (0x1000a432); + intId intId2 (0x0000a432); + intId intId3 (1); + intId intId4 (2); + intId intId5 (3); + intId intId6 (4); + intId intId7 (5); + intId intId8 (6); + intId intId9 (7); + stringId strId1("rrrrrrrrrrrrrrrrrrrrrrrrrr1"); stringId strId2("rrrrrrrrrrrrrrrrrrrrrrrrrr2"); - int status; - - status = intTbl.init(8); - if (status) { - return -1; - } - - status = intTbl.add(fred1); - assert (!status); - status = intTbl.add(fred2); - assert (!status); + + assert (intTbl.add(fred0)==0); + assert (intTbl.add(fred1)==0); + assert (intTbl.add(fred2)==0); + assert (intTbl.add(fred3)==0); + assert (intTbl.add(fred4)==0); + assert (intTbl.add(fred5)==0); + assert (intTbl.add(fred6)==0); + assert (intTbl.add(fred7)==0); + assert (intTbl.add(fred8)==0); + assert (intTbl.add(fred9)==0); start = clock(); for (i=0; i alTbl; - status = alTbl.init(10000); - assert(!status); + static const unsigned tableSize = 0x1000; + resTable< albert, intId > alTbl (tableSize); - for(i=0; i<100000; i++) { - unsigned id = (unsigned) rand(); - albert *pa = new albert(alTbl, id); - assert(pa); - status = alTbl.add(*pa); - if (status) { - // - // duplicate ids are possible - // and ignored - // - delete pa; - } + for (i=0; i #include #include +#include #include "tsBTree.h" #include "tsSLList.h" diff --git a/src/libCom/cxxTemplates/test/tsBTreeTest.cc b/src/libCom/cxxTemplates/test/tsBTreeTest.cc index 845575f8f..7d0d2a3e6 100644 --- a/src/libCom/cxxTemplates/test/tsBTreeTest.cc +++ b/src/libCom/cxxTemplates/test/tsBTreeTest.cc @@ -1,6 +1,7 @@ #include #include +#include #include "tsBTree.h"