diff --git a/src/cxxTemplates/test/Makefile.Host b/src/cxxTemplates/test/Makefile.Host index dc5cbbbab..6c01f9232 100644 --- a/src/cxxTemplates/test/Makefile.Host +++ b/src/cxxTemplates/test/Makefile.Host @@ -7,7 +7,7 @@ CXXCMPLR = STRICT PROD_LIBS = Com TESTPROD := resourceLibTest tsDLListBench tsDLListTest tsDLListTest \ - tsSLListBench tsSLListTest minmaxTest tsBTreeBench tsBTreeTest + tsSLListBench tsSLListTest minmaxTest include $(TOP)/config/RULES.Host diff --git a/src/cxxTemplates/test/minmaxTest.cc b/src/cxxTemplates/test/minmaxTest.cc index 828c0e117..aa9d4b342 100644 --- a/src/cxxTemplates/test/minmaxTest.cc +++ b/src/cxxTemplates/test/minmaxTest.cc @@ -3,10 +3,10 @@ #include "tsMinMax.h" -main () +int main () { - float f1 = 3.3; - float f2 = 3.4; + float f1 = 3.3f; + float f2 = 3.4f; float f3; f3 = tsMin(f1,f2); @@ -24,5 +24,7 @@ main () i3 = tsMax(i1,i2); assert(i3==i2); + + return 0; } diff --git a/src/cxxTemplates/test/resourceLibTest.cc b/src/cxxTemplates/test/resourceLibTest.cc index e590bcfd6..9d83b3e28 100644 --- a/src/cxxTemplates/test/resourceLibTest.cc +++ b/src/cxxTemplates/test/resourceLibTest.cc @@ -3,6 +3,7 @@ #include #include #include +#include #define INSTANCIATE_RES_LIB_STATIC #include "resourceLib.h" @@ -13,6 +14,24 @@ #endif #endif +void empty(); + +class albert : public uintId, public tsSLNode { +public: + albert (resTable &atIn, unsigned idIn) : + at(atIn), uintId(idIn) {} + void show (unsigned level) + { + } + void destroy() + { + at.remove(*this); + delete this; + } +private: + resTable &at; +}; + class fred : public uintId, public tsSLNode { public: fred (const char *pNameIn, unsigned idIn) : @@ -67,36 +86,36 @@ void jane::testTraverse() main() { - unsigned i; - clock_t start, finish; - double duration; - const int LOOPS = 50000; - resTable intTbl; + unsigned i; + clock_t start, finish; + double duration; + const int LOOPS = 50000; + resTable intTbl; resTable strTbl; - fred fred1("fred1",0x1000a432); - fred fred2("fred2",0x0000a432); - jane jane1("rrrrrrrrrrrrrrrrrrrrrrrrrr1"); - jane jane2("rrrrrrrrrrrrrrrrrrrrrrrrrr2"); - fred *pFred; - jane *pJane; - uintId uintId1(0x1000a432); - uintId uintId2(0x0000a432); - stringId strId1("rrrrrrrrrrrrrrrrrrrrrrrrrr1"); - stringId strId2("rrrrrrrrrrrrrrrrrrrrrrrrrr2"); - int status; + fred fred1("fred1",0x1000a432); + fred fred2("fred2",0x0000a432); + jane jane1("rrrrrrrrrrrrrrrrrrrrrrrrrr1"); + jane jane2("rrrrrrrrrrrrrrrrrrrrrrrrrr2"); + fred *pFred; + jane *pJane; + uintId uintId1(0x1000a432); + uintId uintId2(0x0000a432); + 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); - - start = clock(); - for(i=0; i alTbl; + status = alTbl.init(10000); + assert(!status); + + 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; + } + } + alTbl.show(1u); + alTbl.destroyAllEntries(); + + return 0; } +void empty() +{ +} \ No newline at end of file diff --git a/src/cxxTemplates/test/tsDLListBench.cc b/src/cxxTemplates/test/tsDLListBench.cc index 45ddf878a..235d01cd1 100644 --- a/src/cxxTemplates/test/tsDLListBench.cc +++ b/src/cxxTemplates/test/tsDLListBench.cc @@ -1,8 +1,4 @@ -#ifndef CLOCKS_PER_SEC -#define CLOCKS_PER_SEC 1000000 -#endif - #include #include #include @@ -24,7 +20,7 @@ private: #define LOOPCOUNT 100000 -main () +int main () { tsDLList list; tsDLFwdIter iter(list); @@ -59,5 +55,7 @@ main () delay = delay/CLOCKS_PER_SEC; delay = delay/LOOPCOUNT; printf("delay = %15.10f\n", delay); + + return 0; } diff --git a/src/cxxTemplates/test/tsDLListTest.cc b/src/cxxTemplates/test/tsDLListTest.cc index 30d630c28..10bacd8e5 100644 --- a/src/cxxTemplates/test/tsDLListTest.cc +++ b/src/cxxTemplates/test/tsDLListTest.cc @@ -19,7 +19,7 @@ public: private: }; -main () +int main () { tsDLList list; tsDLFwdIter iter(list); @@ -96,5 +96,7 @@ main () janeBwdIter.remove(); } assert(janeList.count()==0); + + return 0; } diff --git a/src/cxxTemplates/test/tsSLListBench.cc b/src/cxxTemplates/test/tsSLListBench.cc index eacf340c0..1cf9fad07 100644 --- a/src/cxxTemplates/test/tsSLListBench.cc +++ b/src/cxxTemplates/test/tsSLListBench.cc @@ -29,7 +29,7 @@ private: #define LOOPCOUNT 100000 -main () +int main () { tsSLList list; fred *pFred; @@ -69,5 +69,7 @@ main () delay = delay/CLOCKS_PER_SEC; delay = delay/LOOPCOUNT; printf("delay = %15.10f\n", delay); + + return 0; } diff --git a/src/cxxTemplates/test/tsSLListTest.cc b/src/cxxTemplates/test/tsSLListTest.cc index f7ea11d03..80186681c 100644 --- a/src/cxxTemplates/test/tsSLListTest.cc +++ b/src/cxxTemplates/test/tsSLListTest.cc @@ -19,7 +19,7 @@ public: private: }; -main () +int main () { tsSLList list; fred *pFred; @@ -97,5 +97,7 @@ main () pFredBack = iter(); assert(pFredBack==NULL); } + + return 0; } diff --git a/src/libCom/cxxTemplates/test/minmaxTest.cc b/src/libCom/cxxTemplates/test/minmaxTest.cc index 828c0e117..aa9d4b342 100644 --- a/src/libCom/cxxTemplates/test/minmaxTest.cc +++ b/src/libCom/cxxTemplates/test/minmaxTest.cc @@ -3,10 +3,10 @@ #include "tsMinMax.h" -main () +int main () { - float f1 = 3.3; - float f2 = 3.4; + float f1 = 3.3f; + float f2 = 3.4f; float f3; f3 = tsMin(f1,f2); @@ -24,5 +24,7 @@ main () i3 = tsMax(i1,i2); assert(i3==i2); + + return 0; } diff --git a/src/libCom/cxxTemplates/test/resourceLibTest.cc b/src/libCom/cxxTemplates/test/resourceLibTest.cc index e590bcfd6..9d83b3e28 100644 --- a/src/libCom/cxxTemplates/test/resourceLibTest.cc +++ b/src/libCom/cxxTemplates/test/resourceLibTest.cc @@ -3,6 +3,7 @@ #include #include #include +#include #define INSTANCIATE_RES_LIB_STATIC #include "resourceLib.h" @@ -13,6 +14,24 @@ #endif #endif +void empty(); + +class albert : public uintId, public tsSLNode { +public: + albert (resTable &atIn, unsigned idIn) : + at(atIn), uintId(idIn) {} + void show (unsigned level) + { + } + void destroy() + { + at.remove(*this); + delete this; + } +private: + resTable &at; +}; + class fred : public uintId, public tsSLNode { public: fred (const char *pNameIn, unsigned idIn) : @@ -67,36 +86,36 @@ void jane::testTraverse() main() { - unsigned i; - clock_t start, finish; - double duration; - const int LOOPS = 50000; - resTable intTbl; + unsigned i; + clock_t start, finish; + double duration; + const int LOOPS = 50000; + resTable intTbl; resTable strTbl; - fred fred1("fred1",0x1000a432); - fred fred2("fred2",0x0000a432); - jane jane1("rrrrrrrrrrrrrrrrrrrrrrrrrr1"); - jane jane2("rrrrrrrrrrrrrrrrrrrrrrrrrr2"); - fred *pFred; - jane *pJane; - uintId uintId1(0x1000a432); - uintId uintId2(0x0000a432); - stringId strId1("rrrrrrrrrrrrrrrrrrrrrrrrrr1"); - stringId strId2("rrrrrrrrrrrrrrrrrrrrrrrrrr2"); - int status; + fred fred1("fred1",0x1000a432); + fred fred2("fred2",0x0000a432); + jane jane1("rrrrrrrrrrrrrrrrrrrrrrrrrr1"); + jane jane2("rrrrrrrrrrrrrrrrrrrrrrrrrr2"); + fred *pFred; + jane *pJane; + uintId uintId1(0x1000a432); + uintId uintId2(0x0000a432); + 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); - - start = clock(); - for(i=0; i alTbl; + status = alTbl.init(10000); + assert(!status); + + 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; + } + } + alTbl.show(1u); + alTbl.destroyAllEntries(); + + return 0; } +void empty() +{ +} \ No newline at end of file diff --git a/src/libCom/cxxTemplates/test/tsDLListBench.cc b/src/libCom/cxxTemplates/test/tsDLListBench.cc index 45ddf878a..235d01cd1 100644 --- a/src/libCom/cxxTemplates/test/tsDLListBench.cc +++ b/src/libCom/cxxTemplates/test/tsDLListBench.cc @@ -1,8 +1,4 @@ -#ifndef CLOCKS_PER_SEC -#define CLOCKS_PER_SEC 1000000 -#endif - #include #include #include @@ -24,7 +20,7 @@ private: #define LOOPCOUNT 100000 -main () +int main () { tsDLList list; tsDLFwdIter iter(list); @@ -59,5 +55,7 @@ main () delay = delay/CLOCKS_PER_SEC; delay = delay/LOOPCOUNT; printf("delay = %15.10f\n", delay); + + return 0; } diff --git a/src/libCom/cxxTemplates/test/tsDLListTest.cc b/src/libCom/cxxTemplates/test/tsDLListTest.cc index 30d630c28..10bacd8e5 100644 --- a/src/libCom/cxxTemplates/test/tsDLListTest.cc +++ b/src/libCom/cxxTemplates/test/tsDLListTest.cc @@ -19,7 +19,7 @@ public: private: }; -main () +int main () { tsDLList list; tsDLFwdIter iter(list); @@ -96,5 +96,7 @@ main () janeBwdIter.remove(); } assert(janeList.count()==0); + + return 0; } diff --git a/src/libCom/cxxTemplates/test/tsSLListBench.cc b/src/libCom/cxxTemplates/test/tsSLListBench.cc index eacf340c0..1cf9fad07 100644 --- a/src/libCom/cxxTemplates/test/tsSLListBench.cc +++ b/src/libCom/cxxTemplates/test/tsSLListBench.cc @@ -29,7 +29,7 @@ private: #define LOOPCOUNT 100000 -main () +int main () { tsSLList list; fred *pFred; @@ -69,5 +69,7 @@ main () delay = delay/CLOCKS_PER_SEC; delay = delay/LOOPCOUNT; printf("delay = %15.10f\n", delay); + + return 0; } diff --git a/src/libCom/cxxTemplates/test/tsSLListTest.cc b/src/libCom/cxxTemplates/test/tsSLListTest.cc index f7ea11d03..80186681c 100644 --- a/src/libCom/cxxTemplates/test/tsSLListTest.cc +++ b/src/libCom/cxxTemplates/test/tsSLListTest.cc @@ -19,7 +19,7 @@ public: private: }; -main () +int main () { tsSLList list; fred *pFred; @@ -97,5 +97,7 @@ main () pFredBack = iter(); assert(pFredBack==NULL); } + + return 0; }