summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@colm.net>2018-03-14 15:56:49 -0400
committerAdrian Thurston <thurston@colm.net>2018-03-14 15:56:49 -0400
commited86d007172a3d9faa57236fad83bbbf494ca714 (patch)
treee1a8d232076bbe9e33f2a09f529f763b3d2d0ee7 /test
parent4ea8e7846f3220d0a0ecca529bc2857de93d998f (diff)
downloadcolm-ed86d007172a3d9faa57236fad83bbbf494ca714.tar.gz
moved aapl test cases to 'aapl' subdir after merging in
Diffstat (limited to 'test')
-rw-r--r--test/.gitignore3
-rw-r--r--test/Makefile72
-rw-r--r--test/avlverify.h213
-rw-r--r--test/stress_allsort.cpp89
-rw-r--r--test/stress_avlimap.cpp149
-rw-r--r--test/stress_avlimel.cpp202
-rw-r--r--test/stress_avlimelkey.cpp232
-rw-r--r--test/stress_avliset.cpp145
-rw-r--r--test/stress_avliter.cpp304
-rw-r--r--test/stress_avlitree.cpp183
-rw-r--r--test/stress_avlmap.cpp167
-rw-r--r--test/stress_avlmel.cpp203
-rw-r--r--test/stress_avlmelkey.cpp213
-rw-r--r--test/stress_avlset.cpp164
-rw-r--r--test/stress_avltree.cpp182
-rw-r--r--test/stress_stblsort.cpp133
-rw-r--r--test/stress_svector.cpp263
-rw-r--r--test/stress_svectsimp.cpp205
-rw-r--r--test/test_allavl.cpp209
-rw-r--r--test/test_allsort.cpp93
-rw-r--r--test/test_avlikeyless.cpp41
-rw-r--r--test/test_avliter.cpp474
-rw-r--r--test/test_avlkeyless.cpp41
-rw-r--r--test/test_bstmap.cpp60
-rw-r--r--test/test_bstset.cpp64
-rw-r--r--test/test_bsttable.cpp215
-rw-r--r--test/test_bubblesort.cpp100
-rw-r--r--test/test_compare.cpp57
-rw-r--r--test/test_dlistval.cpp174
-rw-r--r--test/test_doublelist.cpp109
-rw-r--r--test/test_insertsort.cpp99
-rw-r--r--test/test_mergesort.cpp99
-rw-r--r--test/test_quicksort.cpp97
-rw-r--r--test/test_rope.cpp41
-rw-r--r--test/test_sbstmap.cpp33
-rw-r--r--test/test_sbstset.cpp44
-rw-r--r--test/test_sbsttable.cpp207
-rw-r--r--test/test_string.cpp55
-rw-r--r--test/test_svector.cpp547
-rw-r--r--test/test_svectsimp.cpp103
-rw-r--r--test/test_tavltree.cpp262
-rw-r--r--test/test_tdlist.cpp156
-rw-r--r--test/test_tdlistall.cpp61
-rw-r--r--test/test_tdlistmel.cpp184
-rw-r--r--test/test_tdlistval.cpp138
-rw-r--r--test/test_tsvectsimp.cpp131
-rw-r--r--test/test_tvectsimp.cpp124
-rw-r--r--test/test_vector.cpp474
-rw-r--r--test/test_vectsimp.cpp52
-rw-r--r--test/util.cpp65
-rw-r--r--test/util.h9
51 files changed, 0 insertions, 7740 deletions
diff --git a/test/.gitignore b/test/.gitignore
deleted file mode 100644
index 2abd11eb..00000000
--- a/test/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-/*.tst
-/*.o
-/.deps
diff --git a/test/Makefile b/test/Makefile
deleted file mode 100644
index 87e0fd84..00000000
--- a/test/Makefile
+++ /dev/null
@@ -1,72 +0,0 @@
-#
-# Copyright 2001, 2002 Adrian Thurston <thurston@cs.queensu.ca>
-#
-
-# This file is part of Aapl.
-#
-# Aapl is free software; you can redistribute it and/or modify it under the
-# terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; either version 2.1 of the License, or (at your option)
-# any later version.
-#
-# Aapl is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
-# more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with Aapl; if not, write to the Free Software Foundation, Inc., 59
-# Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-LIBS =
-
-CFLAGS = -g -Wall -I../src
-
-STRESS = \
- stress_avltree.cpp stress_avliter.cpp stress_avlmel.cpp \
- stress_avlmelkey.cpp stress_avlitree.cpp stress_avlmap.cpp \
- stress_avlset.cpp stress_avlimel.cpp stress_avlimelkey.cpp \
- stress_avlimap.cpp stress_avliset.cpp stress_svector.cpp \
- stress_allsort.cpp stress_stblsort.cpp
-
-TEST = \
- test_vector.cpp test_bsttable.cpp test_bstmap.cpp \
- test_bstset.cpp test_doublelist.cpp test_dlistval.cpp \
- test_mergesort.cpp test_allavl.cpp test_avliter.cpp \
- test_quicksort.cpp test_insertsort.cpp test_bubblesort.cpp \
- test_allsort.cpp test_svector.cpp test_sbsttable.cpp \
- test_sbstmap.cpp test_sbstset.cpp test_avlkeyless.cpp \
- test_avlikeyless.cpp test_compare.cpp test_string.cpp \
- test_rope.cpp
-
-
-#*************************************
-
-# Programs.
-CXX = g++
-
-
-# Make targets from sources.
-STRESS_TARGS = $(STRESS:%.cpp=%.tst)
-TEST_TARGS = $(TEST:%.cpp=%.tst)
-TARGS = $(STRESS_TARGS) $(TEST_TARGS)
-DEPS = $(STRESS:%.cpp=.deps/%.d) $(TEST:%.cpp=.deps/%.d) .deps/util.d
-
-# Rules.
-main: $(STRESS_TARGS) $(TEST_TARGS)
-
-.deps:
- mkdir .deps
-
-$(TARGS): %.tst: %.cpp util.o .deps
- @$(CXX) -M $(CFLAGS) $< \
- | sed 's/^\([a-zA-Z0-9_-]*\)\.o:/\1.tst:/;' > .deps/$*.d
- $(CXX) $(CFLAGS) -o $@ $< util.o $(LIBS)
-
-distclean: clean
- rm -Rf .deps Makefile
-
-clean:
- rm -Rf .deps *.tst *.o
-
--include $(DEPS)
diff --git a/test/avlverify.h b/test/avlverify.h
deleted file mode 100644
index 5c6f8324..00000000
--- a/test/avlverify.h
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Copyright 2002 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifdef AAPL_NAMESPACE
-namespace Aapl {
-#endif
-
-#if defined( AVLTREE_MEL )
-# define BASE_EL(name) BaseEl::name
-# define BASEKEY(name) name
-# define AVL_CLASSDEF class Element, class Key, \
- class BaseEl, class Compare = CmpOrd<Key>
-# define AVL_TEMPDEF class Element, class Key, \
- class BaseEl, class Compare
-# define AVL_TEMPUSE Element, Key, BaseEl, Compare
-# if defined( WALKABLE )
-# define AvlTreeVer AvliMelVer
-# define AvlTree AvliMel
-# define BASELIST DListMel< Element, BaseEl >
-# else
-# define AvlTreeVer AvlMelVer
-# define AvlTree AvlMel
-# endif
-#elif defined( AVLTREE_MELKEY )
-# define BASE_EL(name) BaseEl::name
-# define BASEKEY(name) BaseKey::name
-# define AVL_CLASSDEF class Element, class Key, class BaseEl, \
- class BaseKey, class Compare = CmpOrd<Key>
-# define AVL_TEMPDEF class Element, class Key, class BaseEl, \
- class BaseKey, class Compare
-# define AVL_TEMPUSE Element, Key, BaseEl, BaseKey, Compare
-# if defined( WALKABLE )
-# define AvlTreeVer AvliMelKeyVer
-# define AvlTree AvliMelKey
-# define BASELIST DListMel< Element, BaseEl >
-# else
-# define AvlTreeVer AvlMelKeyVer
-# define AvlTree AvlMelKey
-# endif
-#elif defined( AVLTREE_SINGULAR )
-# define BASE_EL(name) name
-# define BASEKEY(name) name
-# define AVL_CLASSDEF class Element, class Key, class Compare = CmpOrd<Key>
-# define AVL_TEMPDEF class Element, class Key, class Compare
-# define AVL_TEMPUSE Element, Key, Compare
-# if defined( WALKABLE )
-# define AvlTreeVer AvliTreeVer
-# define AvlTree AvliTree
-# define BASELIST DListMel< Element, AvliTreeEl<Element> >
-# else
-# define AvlTreeVer AvlTreeVer
-# define AvlTree AvlTree
-# endif
-#elif defined( AVLTREE_MAP )
-# define BASE_EL(name) name
-# define BASEKEY(name) name
-# define AVL_CLASSDEF class Key, class Value, class Compare = CmpOrd<Key>
-# define AVL_TEMPDEF class Key, class Value, class Compare
-# define AVL_TEMPUSE Key, Value, Compare
-# if defined( WALKABLE )
-# define AvlTreeVer AvliMapVer
-# define AvlTree AvliMap
-# define Element AvliMapEl<Key,Value>
-# define BASELIST DList< AvliMapEl<Key,Value> >
-# else
-# define AvlTreeVer AvlMapVer
-# define AvlTree AvlMap
-# define Element AvlMapEl<Key,Value>
-# endif
-#elif defined( AVLTREE_SET )
-# define BASE_EL(name) name
-# define BASEKEY(name) name
-# define AVL_CLASSDEF class Key, class Compare = CmpOrd<Key>
-# define AVL_TEMPDEF class Key, class Compare
-# define AVL_TEMPUSE Key, Compare
-# if defined( WALKABLE )
-# define AvlTreeVer AvliSetVer
-# define AvlTree AvliSet
-# define Element AvliSetEl<Key>
-# define BASELIST DList< AvliSetEl<Key> >
-# else
-# define AvlTreeVer AvlSetVer
-# define AvlTree AvlSet
-# define Element AvlSetEl<Key>
-# endif
-#else
-# error "tree type not specified: this is not a user header"
-#endif
-
-
-/* AvlTree with verification routines. */
-template < AVL_CLASSDEF > class AvlTreeVer
- : public AvlTree<AVL_TEMPUSE>
-{
-public:
- typedef AvlTree<AVL_TEMPUSE> BaseTree;
-#ifdef WALKABLE
- typedef BASELIST BaseList;
-#else
- typedef AvlTree<AVL_TEMPUSE> BaseList;
-#endif
-
- /* For debugging/testing. Verify the tree properties. */
- void verifyIntegrity() const;
-
- /* For debugging/testing. Verify the tree properties. */
- void verifyIntegrity(Element *element, Element *parent) const;
-};
-
-/* For debugging/testing. Verify the tree properties. */
-template <AVL_TEMPDEF> void AvlTreeVer<AVL_TEMPUSE>::
- verifyIntegrity() const
-{
- Element *cur, *last;
-
- /* Verify the properties of the element. */
- verifyIntegrity(BaseTree::root, 0);
-
- /* Make sure the element are connected in proper order. */
-#ifdef WALKABLE
- assert( BaseList::listLen == BaseTree::treeSize );
- /* Walk the list of element, assert the ordering. */
- if ( BaseTree::treeSize > 0 ) {
- Element *prev = BaseList::head, *cur = BaseList::head->BASE_EL(next);
- while ( cur != 0 ) {
- assert( this->compare( prev->BASEKEY(getKey()),
- cur->BASEKEY(getKey()) ) < 0 );
-
- /* If there is no parent, then the element should be the root. */
- if ( cur->BASE_EL(parent) == 0 )
- assert( BaseTree::root == cur );
-
- prev = cur;
- cur = cur->BASE_EL(next);
- }
- }
-#endif
-
- /* Verify that the head is indeed the head. */
- last = 0, cur = BaseList::head;
- while ( cur != 0 ) {
- assert( cur->BASE_EL(left) == last );
- last = cur;
- cur = cur->BASE_EL(parent);
- }
-
- /* Verify that the tail is indeed the tail. */
- last = 0, cur = BaseList::tail;
- while ( cur != 0 ) {
- assert( cur->BASE_EL(right) == last );
- last = cur;
- cur = cur->BASE_EL(parent);
- }
-}
-
-/* Verify the balance property of the avl tree Verify binary tree propery as
- * well as parent/child pointers are correct. */
-template <AVL_TEMPDEF> void AvlTreeVer<AVL_TEMPUSE>::
- verifyIntegrity(Element *element, Element *parent) const
-{
- int lheight, rheight, balanceProp;
- if ( element == 0 )
- return;
-
- lheight = element->BASE_EL(left) ?
- element->BASE_EL(left)->BASE_EL(height) : 0;
- rheight = element->BASE_EL(right) ?
- element->BASE_EL(right)->BASE_EL(height) : 0;
-
- balanceProp = lheight - rheight;
-
- assert( -1 <= balanceProp && balanceProp <= 1 );
- assert( element->BASE_EL(parent) == parent);
-
- if ( element->BASE_EL(left) ) {
- assert( this->compare( element->BASEKEY(getKey()),
- element->BASE_EL(left)->BASEKEY(getKey()) ) > 0 );
- }
-
- if ( element->BASE_EL(right) ) {
- assert( this->compare( element->BASEKEY(getKey()),
- element->BASE_EL(right)->BASEKEY(getKey()) ) < 0 );
- }
-
- verifyIntegrity(element->BASE_EL(left), element);
- verifyIntegrity(element->BASE_EL(right), element);
- return;
-}
-
-/* namespace Aapl */
-#ifdef AAPL_NAMESPACE
-}
-#endif
-
diff --git a/test/stress_allsort.cpp b/test/stress_allsort.cpp
deleted file mode 100644
index aaf3c55e..00000000
--- a/test/stress_allsort.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright 2002, 2003 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <stdlib.h>
-#include <time.h>
-#include <iostream>
-#include <iomanip>
-#include <vector>
-#include "vector.h"
-#include "mergesort.h"
-#include "quicksort.h"
-#include "insertsort.h"
-#include "bubblesort.h"
-#include "compare.h"
-
-using namespace std;
-
-void processArgs( int argc, char** argv );
-
-#define TEST_SIZE 2000
-int main( int argc, char **argv )
-{
- processArgs( argc, argv );
- srandom( time(0) );
- srand48( time(0) );
-
- static int data1[TEST_SIZE];
- static int data2[TEST_SIZE];
- static int data3[TEST_SIZE];
- static int data4[TEST_SIZE];
- int round = 0;
-
- cout << "round 0";
- cout.flush();
-
- while ( true ) {
- switch ( random() % 3 ) {
- case 0:
- for ( int i = 0; i < TEST_SIZE; i++ )
- data1[i] = data2[i] = data3[i] = data4[i] = random();
- break;
- case 1:
- for ( int i = 0; i < TEST_SIZE; i++ )
- data1[i] = data2[i] = data3[i] = data4[i] = i;
- break;
- case 2:
- for ( int i = 0; i < TEST_SIZE; i++ )
- data1[i] = data2[i] = data3[i] = data4[i] = TEST_SIZE-i;
- break;
- }
-
- InsertSort< int, CmpOrd<int> > is;
- BubbleSort< int, CmpOrd<int> > bs;
- QuickSort< int, CmpOrd<int> > qs;
- MergeSort< int, CmpOrd<int> > ms;
-
- qs.sort( data1, TEST_SIZE );
- ms.sort( data2, TEST_SIZE );
- is.sort( data3, TEST_SIZE );
- bs.sort( data4, TEST_SIZE );
-
- assert( memcmp( data1, data2, sizeof(int)*TEST_SIZE ) == 0 );
- assert( memcmp( data1, data3, sizeof(int)*TEST_SIZE) == 0 );
- assert( memcmp( data1, data4, sizeof(int)*TEST_SIZE) == 0 );
-
- cout << "\b\b\b\b\b\b\b\b" << setw(8) << round++;
- cout.flush();
- }
-}
-
diff --git a/test/stress_avlimap.cpp b/test/stress_avlimap.cpp
deleted file mode 100644
index e6477422..00000000
--- a/test/stress_avlimap.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright 2001, 2003 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <time.h>
-#include <string.h>
-#include <stdlib.h>
-#include <iostream>
-#include <stdio.h>
-#include "avlimap.h"
-
-#define AVLTREE_MAP
-#define WALKABLE
-#include "avlverify.h"
-#undef WALKABLE
-#undef AVLTREE_MAP
-
-#include "util.h"
-
-/* Having the action change perion larger than the number of initial entries
- * means that it will take longer to get to all the cases, but all the
- * cases will be more thoroughly tested. The tree will be more likely to
- * empty out completely and fill up with all of the entries. */
-#define INITIAL_ENTRIES 64831
-#define ACTION_CHANGE_PERIOD 120233
-#define VERIFY_PERIOD 1119
-#define COPY_PERIOD 1351
-#define INCREMENT_VARIATION 10
-#define STATS_PERIOD 211
-#define OUTBUFSIZE 100
-
-/* Instantiate the entire tree. */
-template class AvliMap< int, int >;
-template class AvliMapVer< int, int >;
-
-using namespace std;
-
-int increment = 0;
-int curIndex = 0;
-int action = 1;
-int curRound = 0;
-
-/* Replace the current stats line with new stats. For one tree. */
-void printStats( int treeSize, AvliMapEl<int,int> *head )
-{
- /* Print stats. */
- static char buf[OUTBUFSIZE] = { 0 };
- char tmpBuf[OUTBUFSIZE];
-
- if ( curRound % STATS_PERIOD == 0 ) {
- memset( buf, '\b', strlen(buf) );
- cout << buf;
- sprintf( tmpBuf, "%i\t%i\t%s\t%s\t%i\t%i\t%li\t", curRound, increment,
- action&0x1 ? "yes" : "no", action&0x2 ? "yes" : "no",
- curIndex, treeSize, head ? head->height : 0 );
- expandTab( buf, tmpBuf );
- cout << buf;
- cout.flush();
- }
-}
-
-/* Find a new curIndex to use. If the increment is 0 then get
- * a random curIndex. Otherwise use the increment. */
-void newIndex()
-{
- if ( increment == 0 )
- curIndex = random() % INITIAL_ENTRIES;
- else
- curIndex = (curIndex + increment) % INITIAL_ENTRIES;
-}
-
-/* Print the header to the stats. For one tree. */
-void printHeader()
-{
- char buf[OUTBUFSIZE];
- expandTab( buf, "round\tinc\tins\trem\tindex\tels\theight" );
- cout << buf << endl;
-}
-
-
-int main( int argc, char **argv )
-{
- processArgs( argc, argv );
- srandom( time(0) );
-
- typedef AvliMapEl< int, int > TreeEl;
- AvliMapVer< int, int > tree;
-
- printHeader();
-
- for ( curRound = 0; true; curRound++ ) {
- /* Do we change our action? */
- if ( curRound % ACTION_CHANGE_PERIOD == 0 ) {
- increment = random() % 2;
- if ( increment > 0 )
- increment = random() % INCREMENT_VARIATION;
-
- action = (random()%3) + 1;
- }
-
- /* Dump stats. */
- printStats( tree.treeSize, tree.root );
-
- /* Insert one? */
- if ( action&0x1 ) {
- newIndex();
- tree.insert( curIndex, curIndex );
- }
-
- /* Delete one? */
- if ( action&0x2 ) {
- newIndex();
- TreeEl *element = tree.detach( curIndex );
- if ( element != 0 )
- delete element;
- }
-
- /* Verify? */
- if ( curRound % VERIFY_PERIOD == 0 )
- tree.verifyIntegrity();
-
- /* Test the deep copy? */
- if ( curRound % COPY_PERIOD == 0 ) {
- AvliMapVer< int, int > copy(tree);
- copy.verifyIntegrity();
- copy.empty();
- }
-
- }
- return 0;
-}
diff --git a/test/stress_avlimel.cpp b/test/stress_avlimel.cpp
deleted file mode 100644
index 6e7c0d20..00000000
--- a/test/stress_avlimel.cpp
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Copyright 2001, 2003 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <time.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <iostream>
-#include "avlimel.h"
-
-#define AVLTREE_MEL
-#define WALKABLE
-#include "avlverify.h"
-#undef WALKABLE
-#undef AVLTREE_MEL
-
-#include "util.h"
-
-/* Having the action change perion larger than the number of initial entries
- * means that it will take longer to get to all the cases, but all the
- * cases will be more thoroughly tested. The tree will be more likely to
- * empty out completely and fill up with all of the entries. */
-#define INITIAL_ENTRIES 64831
-#define ACTION_CHANGE_PERIOD 120233
-#define VERIFY_PERIOD 1119
-#define COPY_PERIOD 1351
-#define INCREMENT_VARIATION 10
-#define STATS_PERIOD 211
-#define OUTBUFSIZE 100
-
-using namespace std;
-
-struct TreeEl;
-struct BaseEl1 : public AvliTreeEl< TreeEl > { };
-struct BaseEl2 : public AvliTreeEl< TreeEl > { };
-
-struct TreeEl :
- public BaseEl1,
- public BaseEl2
-{
- TreeEl() : inTree1(false), inTree2(false) { }
- TreeEl(const int key) : key(key), inTree1(false), inTree2(false) { }
-
- const int &getKey() { return key; }
-
- int key;
- bool inTree1;
- bool inTree2;
-};
-
-template class AvliMel< TreeEl, int, BaseEl1 >;
-template class AvliMel< TreeEl, int, BaseEl2 >;
-template class AvliMelVer< TreeEl, int, BaseEl1 >;
-template class AvliMelVer< TreeEl, int, BaseEl2 >;
-
-int increment = 0;
-int curIndex = 0;
-int action = 1;
-int curRound = 0;
-
-/* Replace the current stats line with new stats. For two trees. */
-void printStats( int treeSize1, int treeSize2 )
-{
- /* Print stats. */
- static char buf[OUTBUFSIZE] = { 0 };
- char tmpBuf[OUTBUFSIZE];
-
- if ( curRound % STATS_PERIOD == 0 ) {
- memset( buf, '\b', strlen(buf) );
- cout << buf;
- sprintf( tmpBuf, "%i\t%i\t%s\t%s\t%i\t%i\t%i\t", curRound, increment,
- action&0x1 ? "yes" : "no", action&0x2 ? "yes" : "no",
- curIndex, treeSize1, treeSize2 );
- expandTab( buf, tmpBuf );
- cout << buf;
- cout.flush();
- }
-}
-
-/* Find a new curIndex to use. If the increment is 0 then get
- * a random curIndex. Otherwise use the increment. */
-void newIndex()
-{
- if ( increment == 0 )
- curIndex = random() % INITIAL_ENTRIES;
- else
- curIndex = (curIndex + increment) % INITIAL_ENTRIES;
-}
-
-/* Print the header to the stats. For two trees*/
-void printHeader()
-{
- char buf[OUTBUFSIZE];
- expandTab( buf, "round\tinc\tins\trem\tindex\tels1\tels2" );
- cout << buf << endl;
-}
-
-int main( int argc, char **argv )
-{
- processArgs( argc, argv );
- srandom( time(0) );
-
- /* Make the tree and element. */
- AvliMelVer< TreeEl, int, BaseEl1 > tree1;
- AvliMelVer< TreeEl, int, BaseEl2 > tree2;
- TreeEl *allElements = new TreeEl[INITIAL_ENTRIES];
- for ( int element = 0; element < INITIAL_ENTRIES; element++ )
- allElements[element].key = element;
-
- printHeader();
-
- for ( curRound = 0; true; curRound++ ) {
- /* Do we change our action? */
- if ( curRound % ACTION_CHANGE_PERIOD == 0 ) {
- increment = random() % 2;
- if ( increment > 0 )
- increment = random() % INCREMENT_VARIATION;
-
- action = (random()%3) + 1;
- }
-
- /* Dump stats. */
- printStats( tree1.treeSize, tree2.treeSize );
-
- /* Insert one to tree1? */
- if ( action&0x1 ) {
- newIndex();
- /* Insert from the pool of existing element. */
- if ( ! allElements[curIndex].inTree1 ) {
- tree1.insert( allElements+curIndex );
- allElements[curIndex].inTree1 = true;
- }
- }
-
- /* Insert one to tree2? */
- if ( action&0x1 ) {
- newIndex();
- /* Insert from the pool of existing element. */
- if ( ! allElements[curIndex].inTree2 ) {
- tree2.insert( allElements+curIndex );
- allElements[curIndex].inTree2 = true;
- }
- }
-
- /* Delete one from tree1? */
- if ( action&0x2 ) {
- newIndex();
- /* Delete from the pool of existing entries. */
- if ( allElements[curIndex].inTree1 ) {
- tree1.detach( allElements+curIndex );
- allElements[curIndex].inTree1 = false;
- }
- }
-
- /* Delete one from tree2? */
- if ( action&0x2 ) {
- newIndex();
- /* Delete from the pool of existing entries. */
- if ( allElements[curIndex].inTree2 ) {
- tree2.detach( allElements+curIndex );
- allElements[curIndex].inTree2 = false;
- }
- }
-
- /* Verify? */
- if ( curRound % VERIFY_PERIOD == 0 ) {
- tree1.verifyIntegrity();
- tree2.verifyIntegrity();
- }
-
- /* Test the copy constructor? */
- if ( curRound % COPY_PERIOD == 0 ) {
- AvliMelVer< TreeEl, int, BaseEl1 > copy1( tree1 );
- AvliMelVer< TreeEl, int, BaseEl2 > copy2( tree2 );
- copy1.verifyIntegrity();
- copy2.verifyIntegrity();
- copy1.empty();
- copy2.empty();
- }
-
- }
- return 0;
-}
diff --git a/test/stress_avlimelkey.cpp b/test/stress_avlimelkey.cpp
deleted file mode 100644
index c0e3bcfa..00000000
--- a/test/stress_avlimelkey.cpp
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Copyright 2001, 2003 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <time.h>
-#include <string.h>
-#include <stdlib.h>
-#include <iostream>
-#include <stdio.h>
-#include "avlimelkey.h"
-
-#define AVLTREE_MELKEY
-#define WALKABLE
-#include "avlverify.h"
-#undef WALKABLE
-#undef AVLTREE_MELKEY
-
-#include "util.h"
-
-/* Having the action change perion larger than the number of initial entries
- * means that it will take longer to get to all the cases, but all the
- * cases will be more thoroughly tested. The tree will be more likely to
- * empty out completely and fill up with all of the entries. */
-#define INITIAL_ENTRIES 64831
-#define ACTION_CHANGE_PERIOD 120233
-#define VERIFY_PERIOD 1119
-#define COPY_PERIOD 1351
-#define INCREMENT_VARIATION 10
-#define STATS_PERIOD 211
-#define OUTBUFSIZE 100
-
-using namespace std;
-
-struct TreeEl;
-struct BaseEl1 : public AvliTreeEl< TreeEl >
-{
- int getKey() { return key; }
- int key;
-};
-struct BaseEl2 : public AvliTreeEl< TreeEl >
-{
- char strKey[20];
- char *getKey() { return strKey; }
-};
-
-struct TreeEl :
- public BaseEl1,
- public BaseEl2
-{
- TreeEl() : inTree1(false), inTree2(false) { }
- /* One for each tree. */
- TreeEl(const int key) : inTree1(false), inTree2(false) { }
- TreeEl(const char* key) : inTree1(false), inTree2(false) { }
-
- bool inTree1;
- bool inTree2;
-};
-
-template class AvliMelKey< TreeEl, int, BaseEl1, BaseEl1 >;
-template class AvliMelKey< TreeEl, char*, BaseEl2, BaseEl2, CmpStr >;
-template class AvliMelKeyVer< TreeEl, int, BaseEl1, BaseEl1 >;
-template class AvliMelKeyVer< TreeEl, char*, BaseEl2, BaseEl2, CmpStr >;
-
-
-int increment = 0;
-int curIndex = 0;
-int action = 1;
-int curRound = 0;
-
-void ExpandTab(char *buf, char *dstBuf)
-{
- int pos = 10;
- char *src = buf;
- char *dst = dstBuf;
-
- while ( *src != 0 ) {
- if ( *src == '\t' ) {
- *dst++ = ' ';
- while ( dst - dstBuf < pos )
- *dst++ = ' ';
- pos += 10;
- }
- else
- *dst++ = *src;
- src++;
- }
- *dst = 0;
-}
-
-/* Replace the current stats line with new stats. For two trees. */
-void printStats( int treeSize1, int treeSize2 )
-{
- /* Print stats. */
- static char buf[OUTBUFSIZE] = { 0 };
- char tmpBuf[OUTBUFSIZE];
-
- if ( curRound % STATS_PERIOD == 0 ) {
- memset( buf, '\b', strlen(buf) );
- cout << buf;
- sprintf( tmpBuf, "%i\t%i\t%s\t%s\t%i\t%i\t%i\t", curRound, increment,
- action&0x1 ? "yes" : "no", action&0x2 ? "yes" : "no",
- curIndex, treeSize1, treeSize2 );
- expandTab( buf, tmpBuf );
- cout << buf;
- cout.flush();
- }
-}
-
-/* Find a new curIndex to use. If the increment is 0 then get
- * a random curIndex. Otherwise use the increment. */
-void newIndex()
-{
- if ( increment == 0 )
- curIndex = random() % INITIAL_ENTRIES;
- else
- curIndex = (curIndex + increment) % INITIAL_ENTRIES;
-}
-
-/* Print the header to the stats. For two trees*/
-void printHeader()
-{
- char buf[OUTBUFSIZE];
- expandTab( buf, "round\tinc\tins\trem\tindex\tels1\tels2" );
- cout << buf << endl;
-}
-
-int main( int argc, char **argv )
-{
- processArgs( argc, argv );
- srandom( time(0) );
-
- /* Make the tree and element. */
- AvliMelKeyVer< TreeEl, int, BaseEl1, BaseEl1 > tree1;
- AvliMelKeyVer< TreeEl, int, BaseEl2, BaseEl2, CmpStr > tree2;
- TreeEl *allElements = new TreeEl[INITIAL_ENTRIES];
- for ( int element = 0; element < INITIAL_ENTRIES; element++ ) {
- allElements[element].key = element;
- sprintf( allElements[element].strKey, "%i", element );
- }
-
- printHeader();
-
- for ( curRound = 0; true; curRound++ ) {
- /* Do we change our action? */
- if ( curRound % ACTION_CHANGE_PERIOD == 0 ) {
- increment = random() % 2;
- if ( increment > 0 )
- increment = random() % INCREMENT_VARIATION;
-
- action = (random()%3) + 1;
- }
-
- /* Dump stats. */
- printStats( tree1.treeSize, tree2.treeSize );
-
- /* Insert one to tree1? */
- if ( action&0x1 ) {
- newIndex();
- /* Insert from the pool of existing element. */
- if ( ! allElements[curIndex].inTree1 ) {
- tree1.insert( allElements+curIndex );
- allElements[curIndex].inTree1 = true;
- }
- }
-
- /* Insert one to tree2? */
- if ( action&0x1 ) {
- newIndex();
- /* Insert from the pool of existing element. */
- if ( ! allElements[curIndex].inTree2 ) {
- tree2.insert( allElements+curIndex );
- allElements[curIndex].inTree2 = true;
- }
- }
-
- /* Delete one from tree1? */
- if ( action&0x2 ) {
- newIndex();
- /* Delete from the pool of existing entries. */
- if ( allElements[curIndex].inTree1 ) {
- tree1.detach( allElements+curIndex );
- allElements[curIndex].inTree1 = false;
- }
- }
-
- /* Delete one from tree2? */
- if ( action&0x2 ) {
- newIndex();
- /* Delete from the pool of existing entries. */
- if ( allElements[curIndex].inTree2 ) {
- tree2.detach( allElements+curIndex );
- allElements[curIndex].inTree2 = false;
- }
- }
-
- /* Verify? */
- if ( curRound % VERIFY_PERIOD == 0 ) {
- tree1.verifyIntegrity();
- tree2.verifyIntegrity();
- }
-
-
- /* Test the deep copy? */
- if ( curRound % COPY_PERIOD == 0 ) {
- AvliMelKeyVer< TreeEl, int, BaseEl1, BaseEl1 > copy1( tree1 );
- AvliMelKeyVer< TreeEl, int, BaseEl2, BaseEl2, CmpStr > copy2( tree2 );
- copy1.verifyIntegrity();
- copy2.verifyIntegrity();
- copy1.empty();
- copy2.empty();
- }
- }
- return 0;
-}
diff --git a/test/stress_avliset.cpp b/test/stress_avliset.cpp
deleted file mode 100644
index 0d19a7b2..00000000
--- a/test/stress_avliset.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright 2001, 2003 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <time.h>
-#include <string.h>
-#include <stdlib.h>
-#include <iostream>
-#include <stdio.h>
-#include "avliset.h"
-
-#define AVLTREE_SET
-#define WALKABLE
-#include "avlverify.h"
-#undef WALKABLE
-#undef AVLTREE_SET
-
-#include "util.h"
-
-/* Having the action change perion larger than the number of initial entries
- * means that it will take longer to get to all the cases, but all the
- * cases will be more thoroughly tested. The tree will be more likely to
- * empty out completely and fill up with all of the entries. */
-#define INITIAL_ENTRIES 64831
-#define ACTION_CHANGE_PERIOD 120233
-#define VERIFY_PERIOD 1119
-#define COPY_PERIOD 1351
-#define INCREMENT_VARIATION 10
-#define STATS_PERIOD 211
-#define OUTBUFSIZE 100
-
-/* Instantiate the entire tree. */
-template class AvliSet< int >;
-template class AvliSetVer< int >;
-
-using namespace std;
-
-int increment = 0;
-int curIndex = 0;
-int action = 1;
-int curRound = 0;
-
-/* Replace the current stats line with new stats. For one tree. */
-void printStats( int treeSize, AvliSetEl<int> *root )
-{
- /* Print stats. */
- static char buf[OUTBUFSIZE] = { 0 };
- char tmpBuf[OUTBUFSIZE];
-
- if ( curRound % STATS_PERIOD == 0 ) {
- memset( buf, '\b', strlen(buf) );
- cout << buf;
- sprintf( tmpBuf, "%i\t%i\t%s\t%s\t%i\t%i\t%li\t", curRound, increment,
- action&0x1 ? "yes" : "no", action&0x2 ? "yes" : "no",
- curIndex, treeSize, root ? root->height : 0 );
- expandTab( buf, tmpBuf );
- cout << buf;
- cout.flush();
- }
-}
-
-/* Find a new curIndex to use. If the increment is 0 then get
- * a random curIndex. Otherwise use the increment. */
-void newIndex()
-{
- if ( increment == 0 )
- curIndex = random() % INITIAL_ENTRIES;
- else
- curIndex = (curIndex + increment) % INITIAL_ENTRIES;
-}
-
-/* Print the header to the stats. For one tree. */
-void printHeader()
-{
- char buf[OUTBUFSIZE];
- expandTab( buf, "round\tinc\tins\trem\tindex\tels\theight" );
- cout << buf << endl;
-}
-
-
-int main( int argc, char **argv )
-{
- processArgs( argc, argv );
- srandom( time(0) );
-
- AvliSetVer< int > tree;
-
- printHeader();
-
- for ( curRound = 0; true; curRound++ ) {
- /* Do we change our action? */
- if ( curRound % ACTION_CHANGE_PERIOD == 0 ) {
- increment = random() % 2;
- if ( increment > 0 )
- increment = random() % INCREMENT_VARIATION;
-
- action = (random()%3) + 1;
- }
-
- /* Dump stats. */
- printStats( tree.treeSize, tree.root );
-
- /* Insert one? */
- if ( action&0x1 ) {
- newIndex();
- tree.insert( curIndex );
- }
-
- /* Delete one? */
- if ( action&0x2 ) {
- newIndex();
- tree.remove( curIndex );
- }
-
- /* Verify? */
- if ( curRound % VERIFY_PERIOD == 0 )
- tree.verifyIntegrity();
-
- /* Test the copy constructor? */
- if ( curRound % COPY_PERIOD == 0 ) {
- AvliSetVer< int > copy(tree);
- copy.verifyIntegrity();
- copy.empty();
- }
- }
- return 0;
-}
diff --git a/test/stress_avliter.cpp b/test/stress_avliter.cpp
deleted file mode 100644
index e3368490..00000000
--- a/test/stress_avliter.cpp
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * Copyright 2002, 2003 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <time.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <iostream>
-
-#include "avltree.h"
-#include "avlitree.h"
-#include "avlset.h"
-#include "avliset.h"
-
-#define AVLTREE_SINGULAR
-#include "avlverify.h"
-#undef AVLTREE_SINGULAR
-
-#include "util.h"
-
-using namespace std;
-
-/* Having the action change perion larger than the number of initial entries
- * means that it will take longer to get to all the cases, but all the
- * cases will be more thoroughly tested. The tree will be more likely to
- * empty out completely and fill up with all of the entries. */
-#define INITIAL_ENTRIES 64831
-#define ACTION_CHANGE_PERIOD 120233
-#define VERIFY_PERIOD 1119
-#define COPY_PERIOD 1351
-#define WALK_PERIOD 113
-#define INCREMENT_VARIATION 10
-#define STATS_PERIOD 211
-#define OUTBUFSIZE 100
-#define TAB_WIDTH 10
-
-/* Test element. */
-struct TreeEl : public AvlTreeEl<TreeEl>
-{
- TreeEl() : inTree(false) { }
- TreeEl(const int key) : key(key), inTree(false) { }
-
- int getKey() { return key; }
- int key;
- bool inTree;
-};
-
-/* Test element. */
-struct ShadowTreeEl : public AvliTreeEl<ShadowTreeEl>
-{
- ShadowTreeEl() : inTree(false) { }
- ShadowTreeEl(const int key) : key(key), inTree(false) { }
-
- int getKey() { return key; }
- int key;
- bool inTree;
-};
-
-/* Instantiate the entire tree. */
-template class AvlTree< TreeEl, int >;
-template class AvlTreeVer< TreeEl, int >;
-
-/* This is the shadow tree that we will use to test the iterator against. It
- * maintains the next/prev pointers and so we assume it to be correct. */
-template class AvliTree< ShadowTreeEl, int >;
-
-int increment = 0;
-int curIndex = 0;
-int action = 1;
-int curRound = 0;
-
-
-/* Replace the current stats line with new stats. For one tree. */
-void printStats( int treeSize, TreeEl *root )
-{
- /* Print stats. */
- static char buf[OUTBUFSIZE] = { 0 };
- char tmpBuf[OUTBUFSIZE];
-
- if ( curRound % STATS_PERIOD == 0 ) {
- memset( buf, '\b', strlen(buf) );
- cout << buf;
-
- sprintf( tmpBuf, "%i\t%i\t%s\t%s\t%i\t%i\t%li\t", curRound, increment,
- action&0x1 ? "yes" : "no", action&0x2 ? "yes" : "no",
- curIndex, treeSize, root ? root->height : 0 );
- expandTab( buf, tmpBuf );
- cout << buf;
- cout.flush();
- }
-}
-
-/* Find a new curIndex to use. If the increment is 0 then get
- * a random curIndex. Otherwise use the increment. */
-void newIndex()
-{
- if ( increment == 0 )
- curIndex = random() % INITIAL_ENTRIES;
- else
- curIndex = (curIndex + increment) % INITIAL_ENTRIES;
-}
-
-/* Print the header to the stats. For one tree. */
-void printHeader()
-{
- char buf[OUTBUFSIZE];
- expandTab( buf, "round\tinc\tins\trem\tindex\tels\theight" );
- cout << buf << endl;
-}
-
-std::ostream &operator <<(std::ostream &out, TreeEl &element)
-{
- out << element.key;
- return out;
-}
-
-void randomWalkTest( AvlTreeVer<TreeEl, int> &tree,
- AvliTree< ShadowTreeEl, int > &shadowTree )
-{
- /* Randomly choose a walk type. */
- int wt = random() % 4;
- if ( wt == 0 ) {
- /* Walk forward. */
- ShadowTreeEl *st_el = shadowTree.head;
- AvlTree<TreeEl, int>::Iter it = tree.first();
- for ( ; it.lte(); it++, st_el = st_el->next )
- assert ( it->key == st_el->key );
-
- /* If one is done, the other should be too. */
- assert ( st_el == 0 );
- }
- else if ( wt == 1 ) {
- /* Walk backwards. */
- ShadowTreeEl *st_el = shadowTree.tail;
- AvlTree<TreeEl, int>::Iter it = tree.last();
- for ( ; it.gtb(); it--, st_el = st_el->prev )
- assert ( it->key == st_el->key );
-
- /* If one is done, the other should be too. */
- assert ( st_el == 0 );
- }
- else if ( wt >= 2 ) {
- /* Walk to the middle then wiggle around some. */
- ShadowTreeEl *st_el = shadowTree.head;
- AvlTree<TreeEl, int>::Iter it = tree.first();
- for ( int i = 0; i < tree.treeSize/2; i++ ) {
- assert ( it->key == st_el->key );
- it.increment();
- st_el = st_el->next;
- }
-
- /* Wiggle around the size of the tree times. */
- for ( int i = 0; i < tree.treeSize; i++ ) {
- /* How far to go with this wiggle? */
- int dist = random() % 10;
-
- if ( wt == 2 ) {
- /* Go forward some. */
- for ( int j = 0; j < dist && it.gtb() && it.lte(); j++ )
- {
- assert ( it->key == st_el->key );
- it.increment();
- st_el = st_el->next;
- }
- }
- else {
- /* Go backwards some. */
- for ( int j = 0; j < dist && it.gtb() && it.lte(); j++ )
- {
- assert ( it->key == st_el->key );
- it.decrement();
- st_el = st_el->prev;
- }
- }
-
- if ( it.beg() || it.end() ) {
- /* If one is done, the other should be too. */
- assert ( st_el == 0 );
- break;
- }
- }
- }
-}
-
-int main( int argc, char **argv )
-{
- processArgs( argc, argv );
- srandom( time(0) );
-
- /* Make the tree and element. */
- AvlTreeVer< TreeEl, int > tree;
- TreeEl *allElements = new TreeEl[INITIAL_ENTRIES/2];
- for ( int element = 0; element < (INITIAL_ENTRIES/2); element++ )
- allElements[element].key = element;
-
- /* Make the shadow tree and element. */
- AvliTree< ShadowTreeEl, int > shadowTree;
- ShadowTreeEl *allShadowEls = new ShadowTreeEl[INITIAL_ENTRIES/2];
- for ( int element = 0; element < (INITIAL_ENTRIES/2); element++ )
- allShadowEls[element].key = element;
-
- printHeader();
-
- for ( curRound = 0; true; curRound++ ) {
- /* Do we change our action? */
- if ( curRound % ACTION_CHANGE_PERIOD == 0 ) {
- increment = random() % 2;
- if ( increment > 0 )
- increment = random() % INCREMENT_VARIATION;
-
- action = (random()%3) + 1;
- }
-
- /* Dump stats. */
- printStats( tree.treeSize, tree.root );
-
- /* Insert one? */
- if ( action&0x1 ) {
- newIndex();
- if ( curIndex < (INITIAL_ENTRIES/2) ) {
- /* Insert from the pool of existing element. */
- if ( ! allElements[curIndex].inTree ) {
- /* Do the insert for the primary tree. */
- tree.insert( allElements+curIndex );
- allElements[curIndex].inTree = true;
-
- /* Now insert same data for shadow tree. */
- shadowTree.insert( allShadowEls+curIndex );
- allShadowEls[curIndex].inTree = true;
- }
- }
- else {
- /* Insert a new element in both main and shadow. */
- tree.insert( curIndex );
- shadowTree.insert( curIndex );
- }
- }
-
- /* Delete one? */
- if ( action&0x2 ) {
- newIndex();
- if ( curIndex < (INITIAL_ENTRIES/2) ) {
- /* Delete from the pool of existing entries. */
- if ( allElements[curIndex].inTree ) {
- /* Detach for primary element. */
- tree.detach( allElements+curIndex );
- allElements[curIndex].inTree = false;
-
- /* Detach for shadow tree. */
- shadowTree.detach( allShadowEls+curIndex );
- allShadowEls[curIndex].inTree = false;
- }
- }
- else {
- /* Delete an element that was newed. */
- TreeEl *element = tree.detach( curIndex );
- if ( element != 0 )
- delete element;
-
- /* Delete for the shadow tree. */
- ShadowTreeEl *st_el = shadowTree.detach( curIndex );
- if ( st_el != 0 )
- delete st_el;
- }
- }
-
- /* Verify? */
- if ( curRound % VERIFY_PERIOD == 0 )
- tree.verifyIntegrity();
-
- /* Test the deep copy? */
- if ( curRound % COPY_PERIOD == 0 ) {
- AvlTreeVer< TreeEl, int > copy( tree );
- copy.verifyIntegrity();
- randomWalkTest(copy, shadowTree);
- copy.empty();
- }
-
- /* Walk both trees concurrently and verify matching contents. */
- if ( curRound % WALK_PERIOD == 0 ) {
- randomWalkTest(tree, shadowTree);
- }
- }
-
- return 0;
-}
diff --git a/test/stress_avlitree.cpp b/test/stress_avlitree.cpp
deleted file mode 100644
index 4f92a366..00000000
--- a/test/stress_avlitree.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright 2001, 2003 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <time.h>
-#include <stdlib.h>
-#include <iostream>
-#include <stdio.h>
-#include "avlitree.h"
-
-#define AVLTREE_SINGULAR
-#define WALKABLE
-#include "avlverify.h"
-#undef WALKABLE
-#undef AVLTREE_SINGULAR
-
-#include "util.h"
-
-using namespace std;
-
-/* Having the action change perion larger than the number of initial entries
- * means that it will take longer to get to all the cases, but all the
- * cases will be more thoroughly tested. The tree will be more likely to
- * empty out completely and fill up with all of the entries. */
-#define INITIAL_ENTRIES 64831
-#define ACTION_CHANGE_PERIOD 120233
-#define VERIFY_PERIOD 1119
-#define COPY_PERIOD 1351
-#define INCREMENT_VARIATION 10
-#define STATS_PERIOD 211
-#define OUTBUFSIZE 100
-#define TAB_WIDTH 10
-
-/* Test element. */
-struct TreeEl : public AvliTreeEl<TreeEl>
-{
- TreeEl() : inTree(false) { }
- TreeEl(const int key) : key(key), inTree(false) { }
-
- int getKey() { return key; }
- int key;
- bool inTree;
-};
-
-/* Instantiate the entire tree. */
-template class AvliTree< TreeEl, int >;
-template class AvliTreeVer< TreeEl, int >;
-
-int increment = 0;
-int curIndex = 0;
-int action = 1;
-int curRound = 0;
-
-/* Replace the current stats line with new stats. For one tree. */
-void printStats( int treeSize, TreeEl *root )
-{
- /* Print stats. */
- static char buf[OUTBUFSIZE] = { 0 };
- char tmpBuf[OUTBUFSIZE];
-
- if ( curRound % STATS_PERIOD == 0 ) {
- memset( buf, '\b', strlen(buf) );
- cout << buf;
-
- sprintf( tmpBuf, "%i\t%i\t%s\t%s\t%i\t%i\t%li\t", curRound, increment,
- action&0x1 ? "yes" : "no", action&0x2 ? "yes" : "no",
- curIndex, treeSize, root ? root->height : 0 );
-
- expandTab( buf, tmpBuf );
- cout << buf;
- cout.flush();
- }
-}
-
-/* Find a new curIndex to use. If the increment is 0 then get
- * a random curIndex. Otherwise use the increment. */
-void newIndex()
-{
- if ( increment == 0 )
- curIndex = random() % INITIAL_ENTRIES;
- else
- curIndex = (curIndex + increment) % INITIAL_ENTRIES;
-}
-
-/* Print the header to the stats. For one tree. */
-void printHeader()
-{
- char buf[OUTBUFSIZE];
- expandTab( buf, "round\tinc\tins\trem\tindex\tels\theight" );
- cout << buf << endl;
-}
-
-int main( int argc, char **argv )
-{
- processArgs( argc, argv );
- srandom( time(0) );
-
- /* Make the tree and element. */
- AvliTreeVer< TreeEl, int > tree;
- TreeEl *allElements = new TreeEl[INITIAL_ENTRIES/2];
- for ( int element = 0; element < (INITIAL_ENTRIES/2); element++ )
- allElements[element].key = element;
-
- printHeader();
-
- for ( curRound = 0; true; curRound++ ) {
- /* Do we change our action? */
- if ( curRound % ACTION_CHANGE_PERIOD == 0 ) {
- increment = random() % 2;
- if ( increment > 0 )
- increment = random() % INCREMENT_VARIATION;
-
- action = (random()%3) + 1;
- }
-
- /* Dump stats. */
- printStats( tree.treeSize, tree.root );
-
- /* Insert one? */
- if ( action&0x1 ) {
- newIndex();
- if ( curIndex < (INITIAL_ENTRIES/2) ) {
- /* Insert from the pool of existing element. */
- if ( ! allElements[curIndex].inTree ) {
- tree.insert( allElements+curIndex );
- allElements[curIndex].inTree = true;
- }
- }
- else {
- /* Insert a new element. */
- tree.insert( curIndex );
- }
- }
-
- /* Delete one? */
- if ( action&0x2 ) {
- newIndex();
- if ( curIndex < (INITIAL_ENTRIES/2) ) {
- /* Delete from the pool of existing entries. */
- if ( allElements[curIndex].inTree ) {
- tree.detach( allElements+curIndex );
- allElements[curIndex].inTree = false;
- }
- }
- else {
- /* Delete an element that was newed. */
- TreeEl *element = tree.detach( curIndex );
- if ( element != 0 )
- delete element;
- }
- }
-
- /* Verify? */
- if ( curRound % VERIFY_PERIOD == 0 )
- tree.verifyIntegrity();
-
- /* Test the deep copy? */
- if ( curRound % COPY_PERIOD == 0 ) {
- AvliTreeVer< TreeEl, int > copy( tree );
- copy.verifyIntegrity();
- copy.empty();
- }
- }
- return 0;
-}
diff --git a/test/stress_avlmap.cpp b/test/stress_avlmap.cpp
deleted file mode 100644
index 088b42f4..00000000
--- a/test/stress_avlmap.cpp
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright 2001, 2003 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <time.h>
-#include <string.h>
-#include <stdlib.h>
-#include <iostream>
-#include <stdio.h>
-#include "avlmap.h"
-
-#define AVLTREE_MAP
-#include "avlverify.h"
-#undef AVLTREE_MAP
-
-#include "util.h"
-
-/* Having the action change perion larger than the number of initial entries
- * means that it will take longer to get to all the cases, but all the
- * cases will be more thoroughly tested. The tree will be more likely to
- * empty out completely and fill up with all of the entries. */
-#define INITIAL_ENTRIES 64831
-#define ACTION_CHANGE_PERIOD 120233
-#define VERIFY_PERIOD 1119
-#define COPY_PERIOD 1351
-#define INCREMENT_VARIATION 10
-#define STATS_PERIOD 211
-#define OUTBUFSIZE 100
-
-using namespace std;
-
-/* Instantiate the entire tree. */
-template class AvlMap< int, int >;
-template class AvlMapVer< int, int >;
-
-int increment = 0;
-int curIndex = 0;
-int action = 1;
-int curRound = 0;
-
-void ExpandTab(char *buf, char *dstBuf)
-{
- int pos = 10;
- char *src = buf;
- char *dst = dstBuf;
-
- while ( *src != 0 ) {
- if ( *src == '\t' ) {
- *dst++ = ' ';
- while ( dst - dstBuf < pos )
- *dst++ = ' ';
- pos += 10;
- }
- else
- *dst++ = *src;
- src++;
- }
- *dst = 0;
-}
-
-/* Replace the current stats line with new stats. For one tree. */
-void printStats( int treeSize, AvlMapEl<int,int> *head )
-{
- /* Print stats. */
- static char buf[OUTBUFSIZE] = { 0 };
- char tmpBuf[OUTBUFSIZE];
-
- if ( curRound % STATS_PERIOD == 0 ) {
- memset( buf, '\b', strlen(buf) );
- cout << buf;
- sprintf( tmpBuf, "%i\t%i\t%s\t%s\t%i\t%i\t%li\t", curRound, increment,
- action&0x1 ? "yes" : "no", action&0x2 ? "yes" : "no",
- curIndex, treeSize, head ? head->height : 0 );
- expandTab( buf, tmpBuf );
- cout << buf;
- cout.flush();
- }
-}
-
-/* Find a new curIndex to use. If the increment is 0 then get
- * a random curIndex. Otherwise use the increment. */
-void newIndex()
-{
- if ( increment == 0 )
- curIndex = random() % INITIAL_ENTRIES;
- else
- curIndex = (curIndex + increment) % INITIAL_ENTRIES;
-}
-
-/* Print the header to the stats. For one tree. */
-void printHeader()
-{
- char buf[OUTBUFSIZE];
- expandTab( buf, "round\tinc\tins\trem\tindex\tels\theight" );
- cout << buf << endl;
-}
-
-
-int main( int argc, char **argv )
-{
- processArgs( argc, argv );
- srandom( time(0) );
-
- typedef AvlMapEl< int, int > TreeEl;
- AvlMapVer< int, int > tree;
-
- printHeader();
-
- for ( curRound = 0; true; curRound++ ) {
- /* Do we change our action? */
- if ( curRound % ACTION_CHANGE_PERIOD == 0 ) {
- increment = random() % 2;
- if ( increment > 0 )
- increment = random() % INCREMENT_VARIATION;
-
- action = (random()%3) + 1;
- }
-
- /* Dump stats. */
- printStats( tree.treeSize, tree.root );
-
- /* Insert one? */
- if ( action&0x1 ) {
- newIndex();
- tree.insert( curIndex, curIndex );
- }
-
- /* Delete one? */
- if ( action&0x2 ) {
- newIndex();
- TreeEl *element = tree.detach( curIndex );
- if ( element != 0 )
- delete element;
- }
-
- /* Verify? */
- if ( curRound % VERIFY_PERIOD == 0 )
- tree.verifyIntegrity();
-
- /* Test the deep copy? */
- if ( curRound % COPY_PERIOD == 0 ) {
- AvlMapVer< int, int > copy(tree);
- copy.verifyIntegrity();
- copy.empty();
- }
-
- }
- return 0;
-}
diff --git a/test/stress_avlmel.cpp b/test/stress_avlmel.cpp
deleted file mode 100644
index 6d16efb3..00000000
--- a/test/stress_avlmel.cpp
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright 2001-2003 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <time.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <iostream>
-#include "avlmel.h"
-
-#define AVLTREE_MEL
-#include "avlverify.h"
-#undef AVLTREE_MEL
-
-#include "util.h"
-
-/* Having the action change perion larger than the number of initial entries
- * means that it will take longer to get to all the cases, but all the
- * cases will be more thoroughly tested. The tree will be more likely to
- * empty out completely and fill up with all of the entries. */
-#define INITIAL_ENTRIES 64831
-#define ACTION_CHANGE_PERIOD 120233
-#define VERIFY_PERIOD 1119
-#define COPY_PERIOD 1351
-#define INCREMENT_VARIATION 10
-#define STATS_PERIOD 211
-#define OUTBUFSIZE 100
-#define TAB_WIDTH 10
-
-using namespace std;
-
-struct TreeEl;
-struct BaseEl1 : public AvlTreeEl< TreeEl > { };
-struct BaseEl2 : public AvlTreeEl< TreeEl > { };
-
-struct TreeEl :
- public BaseEl1,
- public BaseEl2
-{
- TreeEl() : inTree1(false), inTree2(false) { }
- TreeEl(const int key) : key(key), inTree1(false), inTree2(false) { }
-
- const int &getKey() { return key; }
-
- int key;
- bool inTree1;
- bool inTree2;
-};
-
-template class AvlMel< TreeEl, int, BaseEl1 >;
-template class AvlMel< TreeEl, int, BaseEl2 >;
-template class AvlMelVer< TreeEl, int, BaseEl1 >;
-template class AvlMelVer< TreeEl, int, BaseEl2 >;
-
-int increment = 0;
-int curIndex = 0;
-int action = 1;
-int curRound = 0;
-
-
-/* Replace the current stats line with new stats. For two trees. */
-void printStats( int treeSize1, int treeSize2 )
-{
- /* Print stats. */
- static char buf[OUTBUFSIZE] = { 0 };
- char tmpBuf[OUTBUFSIZE];
-
- if ( curRound % STATS_PERIOD == 0 ) {
- memset( buf, '\b', strlen(buf) );
- cout << buf;
-
- sprintf( tmpBuf, "%i\t%i\t%s\t%s\t%i\t%i\t%i\t", curRound, increment,
- action&0x1 ? "yes" : "no", action&0x2 ? "yes" : "no",
- curIndex, treeSize1, treeSize2 );
- expandTab( buf, tmpBuf );
- cout << buf;
- cout.flush();
- }
-}
-
-/* Find a new curIndex to use. If the increment is 0 then get
- * a random curIndex. Otherwise use the increment. */
-void newIndex()
-{
- if ( increment == 0 )
- curIndex = random() % INITIAL_ENTRIES;
- else
- curIndex = (curIndex + increment) % INITIAL_ENTRIES;
-}
-
-/* Print the header to the stats. For two trees*/
-void printHeader()
-{
- char buf[OUTBUFSIZE];
- expandTab( buf, "round\tinc\tins\trem\tindex\tels1\tels2" );
- cout << buf << endl;
-}
-
-int main( int argc, char **argv )
-{
- processArgs( argc, argv );
- srandom( time(0) );
-
- /* Make the tree and element. */
- AvlMelVer< TreeEl, int, BaseEl1 > tree1;
- AvlMelVer< TreeEl, int, BaseEl2 > tree2;
- TreeEl *allElements = new TreeEl[INITIAL_ENTRIES];
- for ( int element = 0; element < INITIAL_ENTRIES; element++ )
- allElements[element].key = element;
-
- printHeader();
-
- for ( curRound = 0; true; curRound++ ) {
- /* Do we change our action? */
- if ( curRound % ACTION_CHANGE_PERIOD == 0 ) {
- increment = random() % 2;
- if ( increment > 0 )
- increment = random() % INCREMENT_VARIATION;
-
- action = (random()%3) + 1;
- }
-
- /* Dump stats. */
- printStats( tree1.treeSize, tree2.treeSize );
-
- /* Insert one to tree1? */
- if ( action&0x1 ) {
- newIndex();
- /* Insert from the pool of existing element. */
- if ( ! allElements[curIndex].inTree1 ) {
- tree1.insert( allElements+curIndex );
- allElements[curIndex].inTree1 = true;
- }
- }
-
- /* Insert one to tree2? */
- if ( action&0x1 ) {
- newIndex();
- /* Insert from the pool of existing element. */
- if ( ! allElements[curIndex].inTree2 ) {
- tree2.insert( allElements+curIndex );
- allElements[curIndex].inTree2 = true;
- }
- }
-
- /* Delete one from tree1? */
- if ( action&0x2 ) {
- newIndex();
- /* Delete from the pool of existing entries. */
- if ( allElements[curIndex].inTree1 ) {
- tree1.detach( allElements+curIndex );
- allElements[curIndex].inTree1 = false;
- }
- }
-
- /* Delete one from tree2? */
- if ( action&0x2 ) {
- newIndex();
- /* Delete from the pool of existing entries. */
- if ( allElements[curIndex].inTree2 ) {
- tree2.detach( allElements+curIndex );
- allElements[curIndex].inTree2 = false;
- }
- }
-
- /* Verify? */
- if ( curRound % VERIFY_PERIOD == 0 ) {
- tree1.verifyIntegrity();
- tree2.verifyIntegrity();
- }
-
-
- /* Test the deep copy? */
- if ( curRound % COPY_PERIOD == 0 ) {
- AvlMelVer< TreeEl, int, BaseEl1 > copy1( tree1 );
- AvlMelVer< TreeEl, int, BaseEl2 > copy2( tree2 );
- copy1.verifyIntegrity();
- copy2.verifyIntegrity();
- copy1.empty();
- copy2.empty();
- }
- }
- return 0;
-}
diff --git a/test/stress_avlmelkey.cpp b/test/stress_avlmelkey.cpp
deleted file mode 100644
index adaef911..00000000
--- a/test/stress_avlmelkey.cpp
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Copyright 2001, 2003 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <time.h>
-#include <string.h>
-#include <stdlib.h>
-#include <iostream>
-#include <stdio.h>
-#include "avlmelkey.h"
-
-#define AVLTREE_MELKEY
-#include "avlverify.h"
-#undef AVLTREE_MELKEY
-
-#include "util.h"
-
-/* Having the action change perion larger than the number of initial entries
- * means that it will take longer to get to all the cases, but all the
- * cases will be more thoroughly tested. The tree will be more likely to
- * empty out completely and fill up with all of the entries. */
-#define INITIAL_ENTRIES 64831
-#define ACTION_CHANGE_PERIOD 120233
-#define VERIFY_PERIOD 1119
-#define COPY_PERIOD 1351
-#define INCREMENT_VARIATION 10
-#define STATS_PERIOD 211
-#define OUTBUFSIZE 100
-#define TAB_WIDTH 10
-
-using namespace std;
-
-struct TreeEl;
-struct BaseEl1 : public AvlTreeEl< TreeEl >
-{
- int getKey() { return key; }
- int key;
-};
-struct BaseEl2 : public AvlTreeEl< TreeEl >
-{
- char strKey[20];
- char *getKey() { return strKey; }
-};
-
-struct TreeEl :
- public BaseEl1,
- public BaseEl2
-{
- TreeEl() : inTree1(false), inTree2(false) { }
- /* One for each tree. */
- TreeEl(const int key) : inTree1(false), inTree2(false) { }
- TreeEl(const char* key) : inTree1(false), inTree2(false) { }
-
- bool inTree1;
- bool inTree2;
-};
-
-template class AvlMelKey< TreeEl, int, BaseEl1, BaseEl1 >;
-template class AvlMelKey< TreeEl, char*, BaseEl2, BaseEl2, CmpStr >;
-template class AvlMelKeyVer< TreeEl, int, BaseEl1, BaseEl1 >;
-template class AvlMelKeyVer< TreeEl, char*, BaseEl2, BaseEl2, CmpStr >;
-
-int increment = 0;
-int curIndex = 0;
-int action = 1;
-int curRound = 0;
-
-/* Replace the current stats line with new stats. For two trees. */
-void printStats( int treeSize1, int treeSize2 )
-{
- /* Print stats. */
- static char buf[OUTBUFSIZE] = { 0 };
- char tmpBuf[OUTBUFSIZE];
-
- if ( curRound % STATS_PERIOD == 0 ) {
- memset( buf, '\b', strlen(buf) );
- cout << buf;
-
- sprintf( tmpBuf, "%i\t%i\t%s\t%s\t%i\t%i\t%i\t", curRound, increment,
- action&0x1 ? "yes" : "no", action&0x2 ? "yes" : "no",
- curIndex, treeSize1, treeSize2 );
-
- expandTab( buf, tmpBuf );
- cout << buf;
- cout.flush();
- }
-}
-
-/* Find a new curIndex to use. If the increment is 0 then get
- * a random curIndex. Otherwise use the increment. */
-void newIndex()
-{
- if ( increment == 0 )
- curIndex = random() % INITIAL_ENTRIES;
- else
- curIndex = (curIndex + increment) % INITIAL_ENTRIES;
-}
-
-/* Print the header to the stats. For two trees*/
-void printHeader()
-{
- char buf[OUTBUFSIZE];
- expandTab( buf, "round\tinc\tins\trem\tindex\tels1\tels2" );
- cout << buf << endl;
-}
-
-int main( int argc, char **argv )
-{
- processArgs( argc, argv );
- srandom( time(0) );
-
- /* Make the tree and element. */
- AvlMelKeyVer< TreeEl, int, BaseEl1, BaseEl1 > tree1;
- AvlMelKeyVer< TreeEl, int, BaseEl2, BaseEl2, CmpStr > tree2;
- TreeEl *allElements = new TreeEl[INITIAL_ENTRIES];
- for ( int element = 0; element < INITIAL_ENTRIES; element++ ) {
- allElements[element].key = element;
- sprintf( allElements[element].strKey, "%i", element );
- }
-
- printHeader();
-
- for ( curRound = 0; true; curRound++ ) {
- /* Do we change our action? */
- if ( curRound % ACTION_CHANGE_PERIOD == 0 ) {
- increment = random() % 2;
- if ( increment > 0 )
- increment = random() % INCREMENT_VARIATION;
-
- action = (random()%3) + 1;
- }
-
- /* Dump stats. */
- printStats( tree1.treeSize, tree2.treeSize );
-
- /* Insert one to tree1? */
- if ( action&0x1 ) {
- newIndex();
- /* Insert from the pool of existing element. */
- if ( ! allElements[curIndex].inTree1 ) {
- tree1.insert( allElements+curIndex );
- allElements[curIndex].inTree1 = true;
- }
- }
-
- /* Insert one to tree2? */
- if ( action&0x1 ) {
- newIndex();
- /* Insert from the pool of existing element. */
- if ( ! allElements[curIndex].inTree2 ) {
- tree2.insert( allElements+curIndex );
- allElements[curIndex].inTree2 = true;
- }
- }
-
- /* Delete one from tree1? */
- if ( action&0x2 ) {
- newIndex();
- /* Delete from the pool of existing entries. */
- if ( allElements[curIndex].inTree1 ) {
- tree1.detach( allElements+curIndex );
- allElements[curIndex].inTree1 = false;
- }
- }
-
- /* Delete one from tree2? */
- if ( action&0x2 ) {
- newIndex();
- /* Delete from the pool of existing entries. */
- if ( allElements[curIndex].inTree2 ) {
- tree2.detach( allElements+curIndex );
- allElements[curIndex].inTree2 = false;
- }
- }
-
- /* Verify? */
- if ( curRound % VERIFY_PERIOD == 0 ) {
- tree1.verifyIntegrity();
- tree2.verifyIntegrity();
- }
-
-
- /* Test the copy constructor? */
- if ( curRound % COPY_PERIOD == 0 ) {
- AvlMelKeyVer< TreeEl, int, BaseEl1, BaseEl1 > copy1( tree1 );
- AvlMelKeyVer< TreeEl, int, BaseEl2, BaseEl2, CmpStr > copy2( tree2 );
- copy1.verifyIntegrity();
- copy2.verifyIntegrity();
- copy1.empty();
- copy2.empty();
- }
-
- }
- return 0;
-}
diff --git a/test/stress_avlset.cpp b/test/stress_avlset.cpp
deleted file mode 100644
index ec54660a..00000000
--- a/test/stress_avlset.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright 2001, 2003 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <time.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <iostream>
-#include "avlset.h"
-
-#define AVLTREE_SET
-#include "avlverify.h"
-#undef AVLTREE_SET
-
-#include "util.h"
-
-/* Having the action change perion larger than the number of initial entries
- * means that it will take longer to get to all the cases, but all the
- * cases will be more thoroughly tested. The tree will be more likely to
- * empty out completely and fill up with all of the entries. */
-#define INITIAL_ENTRIES 64831
-#define ACTION_CHANGE_PERIOD 120233
-#define VERIFY_PERIOD 1119
-#define COPY_PERIOD 1351
-#define INCREMENT_VARIATION 10
-#define STATS_PERIOD 211
-#define OUTBUFSIZE 100
-
-/* Instantiate the entire tree. */
-template class AvlSet< int >;
-template class AvlSetVer< int >;
-
-using namespace std;
-
-int increment = 0;
-int curIndex = 0;
-int action = 1;
-int curRound = 0;
-
-void ExpandTab(char *buf, char *dstBuf)
-{
- int pos = 10;
- char *src = buf;
- char *dst = dstBuf;
-
- while ( *src != 0 ) {
- if ( *src == '\t' ) {
- *dst++ = ' ';
- while ( dst - dstBuf < pos )
- *dst++ = ' ';
- pos += 10;
- }
- else
- *dst++ = *src;
- src++;
- }
- *dst = 0;
-}
-
-/* Replace the current stats line with new stats. For one tree. */
-void printStats( int treeSize, AvlSetEl<int> *root )
-{
- /* Print stats. */
- static char buf[OUTBUFSIZE] = { 0 };
- char tmpBuf[OUTBUFSIZE];
-
- if ( curRound % STATS_PERIOD == 0 ) {
- memset( buf, '\b', strlen(buf) );
- cout << buf;
- sprintf( tmpBuf, "%i\t%i\t%s\t%s\t%i\t%i\t%li\t", curRound, increment,
- action&0x1 ? "yes" : "no", action&0x2 ? "yes" : "no",
- curIndex, treeSize, root ? root->height : 0 );
- expandTab( buf, tmpBuf );
- cout << buf;
- cout.flush();
- }
-}
-
-/* Find a new curIndex to use. If the increment is 0 then get
- * a random curIndex. Otherwise use the increment. */
-void newIndex()
-{
- if ( increment == 0 )
- curIndex = random() % INITIAL_ENTRIES;
- else
- curIndex = (curIndex + increment) % INITIAL_ENTRIES;
-}
-
-/* Print the header to the stats. For one tree. */
-void printHeader()
-{
- char buf[OUTBUFSIZE];
- expandTab( buf, "round\tinc\tins\trem\tindex\tels\theight" );
- cout << buf << endl;
-}
-
-
-int main( int argc, char **argv )
-{
- processArgs( argc, argv );
- srandom( time(0) );
-
- AvlSetVer<int> tree;
-
- printHeader();
-
- for ( curRound = 0; true; curRound++ ) {
- /* Do we change our action? */
- if ( curRound % ACTION_CHANGE_PERIOD == 0 ) {
- increment = random() % 2;
- if ( increment > 0 )
- increment = random() % INCREMENT_VARIATION;
-
- action = (random()%3) + 1;
- }
-
- /* Dump stats. */
- printStats( tree.treeSize, tree.root );
-
- /* Insert one? */
- if ( action&0x1 ) {
- newIndex();
- tree.insert( curIndex );
- }
-
- /* Delete one? */
- if ( action&0x2 ) {
- newIndex();
- tree.remove( curIndex );
- }
-
- /* Verify? */
- if ( curRound % VERIFY_PERIOD == 0 )
- tree.verifyIntegrity();
-
- /* Test the deep copy? */
- if ( curRound % COPY_PERIOD == 0 ) {
- AvlSetVer<int> copy(tree);
- copy.verifyIntegrity();
- copy.empty();
- }
-
- }
- return 0;
-}
diff --git a/test/stress_avltree.cpp b/test/stress_avltree.cpp
deleted file mode 100644
index 9623b4dd..00000000
--- a/test/stress_avltree.cpp
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright 2002, 2003 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <time.h>
-#include <stdlib.h>
-#include <iostream>
-#include <stdio.h>
-
-#include "avltree.h"
-
-#define AVLTREE_SINGULAR
-#include "avlverify.h"
-#undef AVLTREE_SINGULAR
-
-#include "util.h"
-
-/* Having the action change period larger than the number of initial entries
- * means that it will take longer to get to all the cases, but all the
- * cases will be more thoroughly tested. The tree will be more likely to
- * empty out completely and fill up with all of the entries. */
-#define INITIAL_ENTRIES 64831
-#define ACTION_CHANGE_PERIOD 120233
-#define VERIFY_PERIOD 1119
-#define COPY_PERIOD 1351
-#define INCREMENT_VARIATION 10
-#define STATS_PERIOD 211
-#define OUTBUFSIZE 100
-
-using namespace std;
-
-/* Test element. */
-struct TreeEl : public AvlTreeEl<TreeEl>
-{
- TreeEl() : inTree(false) { }
- TreeEl(const int key) : key(key), inTree(false) { }
-
- int getKey() { return key; }
- int key;
- bool inTree;
-};
-
-/* Instantiate all the code. */
-template class AvlTree< TreeEl, int >;
-template class AvlTreeVer< TreeEl, int >;
-
-int increment = 0;
-int curIndex = 0;
-int action = 1;
-int curRound = 0;
-
-
-/* Write out stats. */
-void writeStats( int treeSize, TreeEl *root )
-{
- static char buf[OUTBUFSIZE] = { 0 };
- char tmpBuf[OUTBUFSIZE];
-
- if ( curRound % STATS_PERIOD == 0 ) {
- /* Replace the contents of the buffer with backspaces and clear the line. */
- memset( buf, '\b', strlen(buf) );
- cout << buf;
-
- /* Write the new stats line. */
- sprintf( tmpBuf, "%i\t%i\t%s\t%s\t%i\t%i\t%li\t", curRound, increment,
- action&0x1 ? "yes" : "no", action&0x2 ? "yes" : "no",
- curIndex, treeSize, root ? root->height : 0 );
- expandTab( buf, tmpBuf );
- cout << buf;
- cout.flush();
- }
-}
-
-/* Find a new curIndex to use. If the increment is 0 then get
- * a random curIndex. Otherwise use the increment. */
-void newIndex()
-{
- if ( increment == 0 )
- curIndex = random() % INITIAL_ENTRIES;
- else
- curIndex = (curIndex + increment) % INITIAL_ENTRIES;
-}
-
-int main( int argc, char **argv )
-{
- processArgs( argc, argv );
- srandom( time(0) );
-
- /* Make the tree and element. */
- AvlTreeVer< TreeEl, int > tree;
- TreeEl *allElements = new TreeEl[INITIAL_ENTRIES/2];
- for ( int element = 0; element < (INITIAL_ENTRIES/2); element++ )
- allElements[element].key = element;
-
- char buf[OUTBUFSIZE];
- expandTab( buf, "round\tinc\tins\trem\tindex\tels\theight" );
- cout << buf << endl;
-
- for ( curRound = 0; true; curRound++ ) {
- /* Do we change our action? */
- if ( curRound % ACTION_CHANGE_PERIOD == 0 ) {
- increment = random() % 2;
- if ( increment > 0 )
- increment = random() % INCREMENT_VARIATION;
-
- action = (random()%3) + 1;
- }
-
- /* Maybe show some stats. */
- writeStats( tree.treeSize, tree.root );
-
- /* Insert one? */
- if ( action&0x1 ) {
- newIndex();
- if ( curIndex < (INITIAL_ENTRIES/2) ) {
- /* Insert from the pool of existing element. */
- if ( ! allElements[curIndex].inTree ) {
- tree.insert( allElements+curIndex );
- allElements[curIndex].inTree = true;
- }
- }
- else {
- /* Insert a new element the version of insert that will create
- * the node for us. */
- tree.insert( curIndex );
- }
- }
-
- /* Delete one? */
- if ( action&0x2 ) {
- newIndex();
- if ( curIndex < (INITIAL_ENTRIES/2) ) {
- /* Delete from the pool of existing entries. */
- if ( allElements[curIndex].inTree ) {
- tree.detach( allElements+curIndex );
- allElements[curIndex].inTree = false;
- }
- }
- else {
- /* Delete an element that was newed. */
- TreeEl *element = tree.detach( curIndex );
- if ( element != 0 )
- delete element;
- }
- }
-
- /* Verify? */
- if ( curRound % VERIFY_PERIOD == 0 ) {
- tree.verifyIntegrity();
- for ( int element = 0; element < (INITIAL_ENTRIES/2); element++ ) {
- TreeEl *res = tree.find( allElements[element].key );
- assert( allElements[element].inTree == (res != 0) );
- }
- }
-
- /* Test the deep copy? */
- if ( curRound % COPY_PERIOD == 0 ) {
- AvlTreeVer< TreeEl, int > copy( tree );
- copy.verifyIntegrity();
- copy.empty();
- }
- }
- return 0;
-}
diff --git a/test/stress_stblsort.cpp b/test/stress_stblsort.cpp
deleted file mode 100644
index 8ba2ba19..00000000
--- a/test/stress_stblsort.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright 2002, 2003 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <stdlib.h>
-#include <time.h>
-#include <iostream>
-#include <iomanip>
-#include <vector>
-#include "vector.h"
-#include "mergesort.h"
-#include "quicksort.h"
-#include "insertsort.h"
-#include "bubblesort.h"
-#include "compare.h"
-
-using namespace std;
-
-#define TEST_SIZE 2000
-void processArgs( int argc, char** argv );
-
-struct TwoDouble
-{
- double d1;
- double d2;
-};
-
-struct TdCmp1
-{
- static inline int compare(TwoDouble &td1, TwoDouble &td2)
- { return CmpOrd<double>::compare(td1.d1, td2.d1); }
-};
-
-struct TdCmp2
-{
- static inline int compare(TwoDouble &td1, TwoDouble &td2)
- { return CmpOrd<double>::compare(td1.d2, td2.d2); }
-};
-
-int main( int argc, char **argv )
-{
- processArgs( argc, argv );
- srandom( time(0) );
- srand48( time(0) );
-
- static TwoDouble data1[TEST_SIZE];
- static TwoDouble data2[TEST_SIZE];
- int round = 0;
-
- cout << "round 0";
- cout.flush();
-
- while ( true ) {
- /* Choose the first double. It has a more restricted range than
- * the second double so that we get lots of structs with the same
- * first key. This help in testing the stable-sort. */
- switch ( random() % 3 ) {
- case 0:
- for ( int i = 0; i < TEST_SIZE; i++ )
- data1[i].d1 = data2[i].d1 = random() % 100;
- break;
- case 1:
- for ( int i = 0; i < TEST_SIZE; i++ )
- data1[i].d1 = data2[i].d1 = i % 100;
- break;
- case 2:
- for ( int i = 0; i < TEST_SIZE; i++ )
- data1[i].d1 = data2[i].d1 = (TEST_SIZE-i) % 100;
- break;
- }
-
- /* Choose the second double. */
- switch ( random() % 3 ) {
- case 0:
- for ( int i = 0; i < TEST_SIZE; i++ )
- data1[i].d2 = data2[i].d2 = random();
- break;
- case 1:
- for ( int i = 0; i < TEST_SIZE; i++ )
- data1[i].d2 = data2[i].d2 = i;
- break;
- case 2:
- for ( int i = 0; i < TEST_SIZE; i++ )
- data1[i].d2 = data2[i].d2 = TEST_SIZE-i;
- break;
- }
-
- MergeSort< TwoDouble, TdCmp2 > ms1;
- MergeSort< TwoDouble, TdCmp1 > ms2;
- BubbleSort< TwoDouble, TdCmp2 > bs1;
- BubbleSort< TwoDouble, TdCmp1 > bs2;
-
- ms1.sort( data1, TEST_SIZE );
- ms2.sort( data1, TEST_SIZE );
- bs1.sort( data2, TEST_SIZE );
- bs2.sort( data2, TEST_SIZE );
-
- assert( memcmp( data1, data2, sizeof(TwoDouble)*TEST_SIZE ) == 0 );
-
- /* Test the stable sort. */
- for ( int i = 1; i < TEST_SIZE; i++ ) {
- if ( data1[i-1].d1 == data1[i].d1 )
- assert( data1[i-1].d2 <= data1[i].d2 );
- }
-
- /* Test the stable sort. */
- for ( int i = 1; i < TEST_SIZE; i++ ) {
- if ( data2[i-1].d1 == data2[i].d1 )
- assert( data2[i-1].d2 <= data2[i].d2 );
- }
-
- cout << "\b\b\b\b\b\b\b\b" << setw(8) << round++;
- cout.flush();
- }
-}
diff --git a/test/stress_svector.cpp b/test/stress_svector.cpp
deleted file mode 100644
index e106150e..00000000
--- a/test/stress_svector.cpp
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Copyright 2001, 2003 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <iostream>
-#include <assert.h>
-#include <time.h>
-#include <stdio.h>
-
-#include "resize.h"
-#include "vector.h"
-#include "svector.h"
-#include "compare.h"
-#include "util.h"
-
-using namespace std;
-
-void processArgs( int argc, char** argv );
-
-template class SVector< int, ResizeExpn >;
-template class SVector< int, ResizeLin >;
-template class SVector< int, ResizeConst >;
-template class SVector< int, ResizeRunTime >;
-template class SVector< int, ResizeCtLin<0> >;
-
-template struct CmpSTable< int, CmpOrd<int> >;
-
-/* Globals that the constructors and destructor count with. */
-int defaultCount = 0;
-int nonDefCount = 0;
-int copyCount = 0;
-int destructorCount = 0;
-
-/* Reset the globals for the next test. */
-void reset()
-{
- defaultCount = 0;
- nonDefCount = 0;
- copyCount = 0;
- destructorCount = 0;
-}
-
-/* An assert that resets the globals and does an assert. */
-#define assert_reset(test) assert(test); reset();
-
-/* Data structure whos constructors and destructor count callings. */
-struct TheData
-{
- TheData() : i(0) { defaultCount++; }
- TheData(int i) : i(i) { nonDefCount++; }
- TheData(const TheData &d) : i(1) { copyCount++; }
- ~TheData() { destructorCount++; }
- int i;
-};
-
-bool operator==(const TheData &td1, const TheData &td2)
- { return td1.i == td2.i; }
-
-
-/* Data structure whos constructors and destructor count callings. */
-struct NoisyData
-{
- NoisyData() : i(0) { cout << __PRETTY_FUNCTION__ << endl; }
- NoisyData(int i) : i(i) { cout << __PRETTY_FUNCTION__ << endl; }
- NoisyData(const NoisyData &d) : i(d.i) { cout << __PRETTY_FUNCTION__ << endl; }
- ~NoisyData() { cout << __PRETTY_FUNCTION__ << endl; }
- int i;
-};
-
-template class SVector<NoisyData>;
-
-int testShared()
-{
- cout << sizeof(SVector<NoisyData>) << endl;
- SVector<NoisyData> v1;
- SVector<NoisyData> v2;
- SVector<NoisyData> v3;
-
- v2.insert( 0, NoisyData(1) );
- v2.insert( 0, NoisyData(2) );
- v2.insert( 0, NoisyData(3) );
-
- v3 = v2;
- v3.replaceDup( 1, NoisyData(4), 4 );
-
- for ( int i = 0; i < v3.length(); i++ )
- cout << v3.data[i].i << endl;
-
- return 0;
-}
-
-#define LEN_THRESH 1000
-#define STATS_PERIOD 211
-#define OUTBUFSIZE 1000
-#define NUM_ROUNDS 1e9
-int curRound = 0;
-
-
-/* Print a statistics header. */
-void printHeader()
-{
- char buf[OUTBUFSIZE];
- expandTab( buf, "round\tlength" );
- cout << buf << endl;
-}
-
-
-/* Replace the current stats line with new stats. For one vect. */
-void printStats( Vector<TheData> &v1 )
-{
- /* Print stats. */
- static char buf[OUTBUFSIZE] = { 0 };
- char tmpBuf[OUTBUFSIZE];
- memset( buf, '\b', strlen(buf) );
- cout << buf;
- sprintf( tmpBuf, "%i\t%li\t", curRound, v1.length() );
- expandTab( buf, tmpBuf );
- cout << buf;
- cout.flush();
-}
-
-Vector<TheData> v1;
-SVector<TheData> v2;
-
-Vector<TheData> v1Copy;
-SVector<TheData> v2Copy;
-
-int main( int argc, char **argv )
-{
- processArgs( argc, argv );
- srandom(time(0));
- printHeader();
-
- for ( curRound = 0; ; curRound++ ) {
- /* Choose an action. */
- int action = random() % 7;
- /* 0: remove
- * 1: setAs
- * 2: prepend
- * 3: append
- * 4: insert
- * 5: replace
- * 6: copy
- */
-
- /* Exclude remove when already empty. */
- if ( action == 0 && v1.length() == 0 )
- continue;
-
- /* Exclude growing when at max len. */
- if ( 3 <= action && v1.length() > LEN_THRESH )
- continue;
-
- switch ( action ) {
- /* remove. */
- case 0: {
- /* Get a position and length. */
- int pos = random() % (v1.length()+1);
- int len = random() % (v1.length() - pos + 1);
- v1.remove( pos, len );
- v2.remove( pos, len );
- break;
- }
- /* setAs. */
- case 1: {
- int len = random() % LEN_THRESH;
- TheData *tmpD = new TheData[len];
- for ( int i = 0; i < len; i++ )
- tmpD[i].i = random();
- v1.setAs( tmpD, len );
- v2.setAs( tmpD, len );
- delete[] tmpD;
- break;
- }
- /* prepend. */
- case 2: {
- int len = random() % LEN_THRESH;
- TheData *tmpD = new TheData[len];
- for ( int i = 0; i < len; i++ )
- tmpD[i].i = random();
- v1.prepend( tmpD, len );
- v2.prepend( tmpD, len );
- delete[] tmpD;
- break;
- }
- /* append. */
- case 3: {
- int len = random() % LEN_THRESH;
- TheData *tmpD = new TheData[len];
- for ( int i = 0; i < len; i++ )
- tmpD[i].i = random();
- v1.append( tmpD, len );
- v2.append( tmpD, len );
- delete[] tmpD;
- break;
- }
- /* insert. */
- case 4: {
- int pos = random() % (v1.length()+1);
- int len = random() % LEN_THRESH;
- TheData *tmpD = new TheData[len];
- for ( int i = 0; i < len; i++ )
- tmpD[i].i = random();
- v1.insert( pos, tmpD, len );
- v2.insert( pos, tmpD, len );
- delete[] tmpD;
- break;
- }
- /* replace. */
- case 5: {
- int pos = random() % (v1.length()+1);
- int len = random() % LEN_THRESH;
- TheData *tmpD = new TheData[len];
- for ( int i = 0; i < len; i++ )
- tmpD[i].i = random();
- v1.replace( pos, tmpD, len );
- v2.replace( pos, tmpD, len );
- delete[] tmpD;
- break;
- }
- /* copy. */
- case 6: {
- Vector<TheData> v1Loc(v1);
- v1Copy = v1;
-
- SVector<TheData> v2Loc(v2);
- v2Copy = v2;
- }
- }
-
- /* Assert that the vectors are equal. */
- Vector<TheData>::Iter v1It(v1);
- SVector<TheData>::Iter v2It(v2);
- assert( v1.length() == v2.length() );
- for ( int i = 0; i < v1.length(); i++, v1It++, v2It++ )
- assert( *v1It == *v2It );
-
- if ( curRound % STATS_PERIOD )
- printStats( v1 );
-
- curRound += 1;
- }
- cout << endl;
- return 0;
-}
diff --git a/test/stress_svectsimp.cpp b/test/stress_svectsimp.cpp
deleted file mode 100644
index febeb1c5..00000000
--- a/test/stress_svectsimp.cpp
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Copyright 2002, 2003 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <iostream>
-#include <stdio.h>
-#include <assert.h>
-#include <time.h>
-
-#include "vectsimp.h"
-#include "svectsimp.h"
-
-using namespace std;
-void processArgs( int argc, char** argv );
-
-template class SVectSimp<char>;
-
-/* Data structure whos constructors and destructor count callings. */
-struct TheData
-{
- TheData() : i(0) { }
- TheData(int i) : i(i) { }
- TheData(const TheData &d) : i(1) { }
- ~TheData() { }
-
- int i;
-};
-
-bool operator==(const TheData &td1, const TheData &td2)
- { return td1.i == td2.i; }
-
-#define LEN_THRESH 1000
-#define STATS_PERIOD 211
-#define OUTBUFSIZE 1000
-//#define NUM_ROUNDS 1e9
-#define NUM_ROUNDS 100000
-int curRound = 0;
-
-void expandTab( char *dst, char *src );
-
-/* Print a statistics header. */
-void printHeader()
-{
- char buf[OUTBUFSIZE];
- expandTab( buf, "round\tlength" );
- cout << buf << endl;
-}
-
-
-/* Replace the current stats line with new stats. For one tree. */
-void printStats( VectSimp<TheData> &v1 )
-{
- /* Print stats. */
- static char buf[OUTBUFSIZE] = { 0 };
- char tmpBuf[OUTBUFSIZE];
- memset( buf, '\b', strlen(buf) );
- cout << buf;
- sprintf( tmpBuf, "%i\t%li\t", curRound, v1.length() );
- expandTab( buf, tmpBuf );
- cout << buf;
- cout.flush();
-}
-
-VectSimp<TheData> v1;
-SVectSimp<TheData> v2;
-
-VectSimp<TheData> v1Copy;
-SVectSimp<TheData> v2Copy;
-
-int main( int argc, char **argv )
-{
- processArgs( argc, argv );
- srandom(time(0));
- printHeader();
-
- for ( curRound = 0; ; curRound++ ) {
- /* Choose an action. */
- int action = random() % 7;
- /* 0: remove
- * 1: setAs
- * 2: prepend
- * 3: append
- * 4: insert
- * 5: replace
- * 6: copy
- */
-
- /* Exclude remove when already empty. */
- if ( action == 0 && v1.length() == 0 )
- continue;
-
- /* Exclude growing when at max len. */
- if ( 3 <= action && v1.length() > LEN_THRESH )
- continue;
-
- switch ( action ) {
- /* remove. */
- case 0: {
- /* Get a position and length. */
- int pos = random() % (v1.length()+1);
- int len = random() % (v1.length() - pos + 1);
- v1.remove( pos, len );
- v2.remove( pos, len );
- break;
- }
- /* setAs. */
- case 1: {
- int len = random() % LEN_THRESH;
- TheData *tmpD = new TheData[len];
- for ( int i = 0; i < len; i++ )
- tmpD[i].i = random();
- v1.setAs( tmpD, len );
- v2.setAs( tmpD, len );
- delete[] tmpD;
- break;
- }
- /* prepend. */
- case 2: {
- int len = random() % LEN_THRESH;
- TheData *tmpD = new TheData[len];
- for ( int i = 0; i < len; i++ )
- tmpD[i].i = random();
- v1.prepend( tmpD, len );
- v2.prepend( tmpD, len );
- delete[] tmpD;
- break;
- }
- /* append. */
- case 3: {
- int len = random() % LEN_THRESH;
- TheData *tmpD = new TheData[len];
- for ( int i = 0; i < len; i++ )
- tmpD[i].i = random();
- v1.append( tmpD, len );
- v2.append( tmpD, len );
- delete[] tmpD;
- break;
- }
- /* insert. */
- case 4: {
- int pos = random() % (v1.length()+1);
- int len = random() % LEN_THRESH;
- TheData *tmpD = new TheData[len];
- for ( int i = 0; i < len; i++ )
- tmpD[i].i = random();
- v1.insert( pos, tmpD, len );
- v2.insert( pos, tmpD, len );
- delete[] tmpD;
- break;
- }
- /* replace. */
- case 5: {
- int pos = random() % (v1.length()+1);
- int len = random() % LEN_THRESH;
- TheData *tmpD = new TheData[len];
- for ( int i = 0; i < len; i++ )
- tmpD[i].i = random();
- v1.replace( pos, tmpD, len );
- v2.replace( pos, tmpD, len );
- delete[] tmpD;
- break;
- }
- /* copy. */
- case 6: {
- VectSimp<TheData> v1Loc(v1);
- v1Copy = v1;
-
- SVectSimp<TheData> v2Loc(v2);
- v2Copy = v2;
- }
- }
-
- /* Assert that the vectors are equal. */
- VectSimp<TheData>::Iter v1It = v1;
- SVectSimp<TheData>::Iter v2It = v2;
- assert( v1.size() == v2.size() );
- for ( int i = 0; i < v1.size(); i++, v1It++, v2It++ )
- assert( *v1It == *v2It );
-
- if ( curRound % STATS_PERIOD )
- printStats( v1 );
-
- curRound += 1;
- }
- cout << endl;
- return 0;
-}
diff --git a/test/test_allavl.cpp b/test/test_allavl.cpp
deleted file mode 100644
index 4d7b6278..00000000
--- a/test/test_allavl.cpp
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Copyright 2001 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <stdio.h>
-
-#include "avltree.h"
-#include "avlmel.h"
-#include "avlmelkey.h"
-#include "avlmap.h"
-#include "avlset.h"
-
-#include "avlitree.h"
-#include "avlimel.h"
-#include "avlimelkey.h"
-#include "avlimap.h"
-#include "avliset.h"
-
-/*
- * AvlTree
- */
-
-struct TreeEl1 : public AvlTreeEl<TreeEl1>
-{
- TreeEl1() : inTree(false) { }
- TreeEl1(const int key) : key(key), inTree(false) { }
-
- int getKey() { return key; }
- int key;
- bool inTree;
-};
-
-/* Instantiate the entire tree. */
-template class AvlTree< TreeEl1, int >;
-
-struct TreeEl2;
-struct BaseEl2a : public AvlTreeEl< TreeEl2 > { };
-struct BaseEl2b : public AvlTreeEl< TreeEl2 > { };
-
-/*
- * AvlMel
- */
-struct TreeEl2 : public BaseEl2a, public BaseEl2b
-{
- TreeEl2() : inTree1(false), inTree2(false) { }
- TreeEl2(const int key) : key(key), inTree1(false), inTree2(false) { }
-
- const int &getKey() { return key; }
-
- int key;
- bool inTree1;
- bool inTree2;
-};
-
-template class AvlMel< TreeEl2, int, BaseEl2a >;
-template class AvlMel< TreeEl2, int, BaseEl2b >;
-
-/*
- * AvlMelKey
- */
-struct TreeEl3;
-struct BaseEl3a :
- public AvlTreeEl< TreeEl3 >
-{
- int getKey() { return key; }
- int key;
-};
-struct BaseEl3b :
- public AvlTreeEl< TreeEl3 >
-{
- char strKey[20];
- char *getKey() { return strKey; }
-};
-
-struct TreeEl3 :
- public BaseEl3a,
- public BaseEl3b
-{
- TreeEl3() : inTree1(false), inTree2(false) { }
- /* One for each tree. */
- TreeEl3(const int key) : inTree1(false), inTree2(false) { }
- TreeEl3(const char* key) : inTree1(false), inTree2(false) { }
-
- bool inTree1;
- bool inTree2;
-};
-
-template class AvlMelKey< TreeEl3, int, BaseEl3a, BaseEl3a >;
-template class AvlMelKey< TreeEl3, char*, BaseEl3b, BaseEl3b, CmpStr >;
-
-/*
- * AvlMap
- */
-/* Instantiate the entire tree. */
-template class AvlMap< int, int >;
-
-/*
- * AvlSet
- */
-/* Instantiate the entire tree. */
-template class AvlSet< int >;
-
-/*
- * AvliTree
- */
-
-struct TreeEl6 : public AvliTreeEl<TreeEl6>
-{
- TreeEl6() : inTree(false) { }
- TreeEl6(const int key) : key(key), inTree(false) { }
-
- int getKey() { return key; }
- int key;
- bool inTree;
-};
-
-/* Instantiate the entire tree. */
-template class AvliTree< TreeEl6, int >;
-
-struct TreeEl7;
-struct BaseEl7a : public AvliTreeEl< TreeEl7 > { };
-struct BaseEl7b : public AvliTreeEl< TreeEl7 > { };
-
-/*
- * AvliMel
- */
-struct TreeEl7 : public BaseEl7a, public BaseEl7b
-{
- TreeEl7() : inTree1(false), inTree2(false) { }
- TreeEl7(const int key) : key(key), inTree1(false), inTree2(false) { }
-
- const int &getKey() { return key; }
-
- int key;
- bool inTree1;
- bool inTree2;
-};
-
-template class AvliMel< TreeEl7, int, BaseEl7a >;
-template class AvliMel< TreeEl7, int, BaseEl7b >;
-
-/*
- * AvliMelKey
- */
-struct TreeEl8;
-struct BaseEl8a :
- public AvliTreeEl< TreeEl8 >
-{
- int getKey() { return key; }
- int key;
-};
-struct BaseEl8b :
- public AvliTreeEl< TreeEl8 >
-{
- char strKey[20];
- char *getKey() { return strKey; }
-};
-
-struct TreeEl8 :
- public BaseEl8a,
- public BaseEl8b
-{
- TreeEl8() : inTree1(false), inTree2(false) { }
- /* One for each tree. */
- TreeEl8(const int key) : inTree1(false), inTree2(false) { }
- TreeEl8(const char* key) : inTree1(false), inTree2(false) { }
-
- bool inTree1;
- bool inTree2;
-};
-
-template class AvliMelKey< TreeEl8, int, BaseEl8a, BaseEl8a >;
-template class AvliMelKey< TreeEl8, char*, BaseEl8b, BaseEl8b, CmpStr >;
-
-/*
- * AvliMap
- */
-/* Instantiate the entire tree. */
-template class AvliMap< int, int >;
-
-/*
- * AvliSet
- */
-/* Instantiate the entire tree. */
-template class AvliSet< int >;
-
-
-int main()
-{
- return 0;
-}
diff --git a/test/test_allsort.cpp b/test/test_allsort.cpp
deleted file mode 100644
index 4f738614..00000000
--- a/test/test_allsort.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2002 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <stdlib.h>
-#include <time.h>
-#include <iostream>
-#include <iomanip>
-#include <vector>
-#include "vector.h"
-#include "mergesort.h"
-#include "quicksort.h"
-#include "insertsort.h"
-#include "bubblesort.h"
-#include "compare.h"
-
-using namespace std;
-
-struct TwoDouble
-{
- double d1;
- double d2;
-};
-
-struct TdCmpData
-{
- TdCmpData() : toInt(false) { }
-
- inline int compare( TwoDouble &td1, TwoDouble &td2 )
- {
- return toInt ?
- CmpOrd<double>::compare(td1.d1, td2.d1) :
- CmpOrd<double>::compare(td1.d1, td2.d1);
- }
- bool toInt;
-};
-
-
-int testNonStaticCompare()
-{
- static TwoDouble data[3];
- data[0].d1 = 2;
- data[1].d1 = 1.5;
- data[2].d1 = 1;
-
- BubbleSort< TwoDouble, TdCmpData > bs;
- MergeSort< TwoDouble, TdCmpData > ms;
- InsertSort< TwoDouble, TdCmpData > is;
- QuickSort< TwoDouble, TdCmpData > qs;
-
- bs.toInt = true;
- bs.sort( data, 3 );
- cout << data[0].d1 << " " << data[1].d1 << " " << data[2].d1 << endl;
-
- ms.toInt = true;
- ms.sort( data, 3 );
- cout << data[0].d1 << " " << data[1].d1 << " " << data[2].d1 << endl;
-
- is.toInt = true;
- is.sort( data, 3 );
- cout << data[0].d1 << " " << data[1].d1 << " " << data[2].d1 << endl;
-
- qs.toInt = false;
- qs.sort( data, 3 );
- cout << data[0].d1 << " " << data[1].d1 << " " << data[2].d1 << endl;
-
- return 0;
-}
-
-int main()
-{
- testNonStaticCompare();
- return 0;
-}
-
diff --git a/test/test_avlikeyless.cpp b/test/test_avlikeyless.cpp
deleted file mode 100644
index 7ea5e6a0..00000000
--- a/test/test_avlikeyless.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2001 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <iostream>
-#include "avlikeyless.h"
-
-using namespace std;
-
-/* Test element. */
-struct TreeEl : public AvliTreeEl<TreeEl>
-{
- TreeEl() : inTree(false) { }
- bool inTree;
-};
-
-/* Instantiate the entire tree. */
-template class AvliKeyless< TreeEl >;
-
-int main()
-{
- return 0;
-}
diff --git a/test/test_avliter.cpp b/test/test_avliter.cpp
deleted file mode 100644
index d09c0a3e..00000000
--- a/test/test_avliter.cpp
+++ /dev/null
@@ -1,474 +0,0 @@
-/*
- * Copyright 2002 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <time.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <iostream>
-
-#include "avltree.h"
-#include "avlitree.h"
-#include "avlset.h"
-#include "avliset.h"
-
-#define AVLTREE_SINGULAR
-#include "avlverify.h"
-#undef AVLTREE_SINGULAR
-
-#include "util.h"
-
-using namespace std;
-
-/* Having the action change perion larger than the number of initial entries
- * means that it will take longer to get to all the cases, but all the
- * cases will be more thoroughly tested. The tree will be more likely to
- * empty out completely and fill up with all of the entries. */
-#define INITIAL_ENTRIES 64831
-#define ACTION_CHANGE_PERIOD 120233
-#define VERIFY_PERIOD 1119
-#define COPY_PERIOD 1351
-#define WALK_PERIOD 113
-#define INCREMENT_VARIATION 10
-#define STATS_PERIOD 211
-#define OUTBUFSIZE 100
-
-/* Test element. */
-struct TreeEl : public AvlTreeEl<TreeEl>
-{
- TreeEl() : inTree(false) { }
- TreeEl(const int key) : key(key), inTree(false) { }
-
- int getKey() { return key; }
- int key;
- bool inTree;
-};
-
-/* Test element. */
-struct ShadowTreeEl : public AvliTreeEl<ShadowTreeEl>
-{
- ShadowTreeEl() : inTree(false) { }
- ShadowTreeEl(const int key) : key(key), inTree(false) { }
-
- int getKey() { return key; }
- int key;
- bool inTree;
-};
-
-/* Instantiate the entire tree. */
-template class AvlTree< TreeEl, int >;
-template class AvlTreeVer< TreeEl, int >;
-
-/* This is the shadow tree that we will use to test the iterator against. It
- * maintains the next/prev pointers and so we assume it to be correct. */
-template class AvliTree< ShadowTreeEl, int >;
-
-int increment = 0;
-int curIndex = 0;
-int action = 1;
-int curRound = 0;
-
-void ExpandTab(char *buf, char *dstBuf)
-{
- int pos = 10;
- char *src = buf;
- char *dst = dstBuf;
-
- while ( *src != 0 ) {
- if ( *src == '\t' ) {
- *dst++ = ' ';
- while ( dst - dstBuf < pos )
- *dst++ = ' ';
- pos += 10;
- }
- else
- *dst++ = *src;
- src++;
- }
- *dst = 0;
-}
-
-/* Replace the current stats line with new stats. For one tree. */
-void PrintStats( int treeSize, TreeEl *root )
-{
- /* Print stats. */
- char buf1[OUTBUFSIZE];
- char buf2[OUTBUFSIZE];
-
- if ( curRound % STATS_PERIOD == 0 ) {
- memset( buf1, '\b', OUTBUFSIZE );
- fwrite( buf1, 1, OUTBUFSIZE, stdout );
- sprintf(buf1, "%i\t%i\t%s\t%s\t%i\t%i\t%li\t", curRound, increment,
- action&0x1 ? "yes" : "no", action&0x2 ? "yes" : "no",
- curIndex, treeSize, root ? root->height : 0 );
- expandTab(buf2, buf1);
- fputs(buf2, stdout);
- fflush(stdout);
- }
-}
-
-/* Find a new curIndex to use. If the increment is 0 then get
- * a random curIndex. Otherwise use the increment. */
-void NewIndex()
-{
- if ( increment == 0 )
- curIndex = random() % INITIAL_ENTRIES;
- else
- curIndex = (curIndex + increment) % INITIAL_ENTRIES;
-}
-
-/* Print the header to the stats. For one tree. */
-void printHeader()
-{
- char buf[OUTBUFSIZE];
- expandTab( buf, "round\tinc\tins\trem\tindex\tels\theight\n" );
- fputs(buf, stdout);
-}
-
-std::ostream &operator <<(std::ostream &out, TreeEl &element)
-{
- out << element.key;
- return out;
-}
-
-void randomWalkTest( AvlTreeVer<TreeEl, int> &tree,
- AvliTree< ShadowTreeEl, int > &shadowTree )
-{
- /* Randomly choose a walk type. */
- int wt = random() % 4;
- if ( wt == 0 ) {
- /* Walk forward. */
- ShadowTreeEl *st_el = shadowTree.head;
- AvlTree<TreeEl, int>::Iter it = tree.first();
- for ( ; it.lte(); it++, st_el = st_el->next )
- assert ( it->key == st_el->key );
-
- /* If one is done, the other should be too. */
- assert ( st_el == 0 );
- }
- else if ( wt == 1 ) {
- /* Walk backwards. */
- ShadowTreeEl *st_el = shadowTree.tail;
- AvlTree<TreeEl, int>::Iter it = tree.last();
- for ( ; it.gtb(); it--, st_el = st_el->prev )
- assert ( it->key == st_el->key );
-
- /* If one is done, the other should be too. */
- assert ( st_el == 0 );
- }
- else if ( wt >= 2 ) {
- /* Walk to the middle then wiggle around some. */
- ShadowTreeEl *st_el = shadowTree.head;
- AvlTree<TreeEl, int>::Iter it = tree.first();
- for ( int i = 0; i < tree.treeSize/2; i++ ) {
- assert ( it->key == st_el->key );
- it.increment();
- st_el = st_el->next;
- }
-
- /* Wiggle around the size of the tree times. */
- for ( int i = 0; i < tree.treeSize; i++ ) {
- /* How far to go with this wiggle? */
- int dist = random() % 10;
-
- if ( wt == 2 ) {
- /* Go forward some. */
- for ( int j = 0; j < dist && it.gtb() && it.lte(); j++ )
- {
- assert ( it->key == st_el->key );
- it.increment();
- st_el = st_el->next;
- }
- }
- else {
- /* Go backwards some. */
- for ( int j = 0; j < dist && it.gtb() && it.lte(); j++ )
- {
- assert ( it->key == st_el->key );
- it.decrement();
- st_el = st_el->prev;
- }
- }
-
- if ( it.beg() || it.end() ) {
- /* If one is done, the other should be too. */
- assert ( st_el == 0 );
- break;
- }
- }
- }
-}
-
-typedef AvlSet< int > Tree;
-typedef AvliSet< int > TreeI;
-
-void testIterNotWalkable()
-{
- Tree tree;
-
- cout << "NOT WALKABLE" << endl;
- cout << "Iterator Default Constructor" << endl;
-
- /* Default constructed iterator. */
- Tree::Iter defIt;
- cout << defIt.lte() << " " << defIt.end() << " " << defIt.gtb() << " " <<
- defIt.beg() << " " << defIt.first() << " " << defIt.last() << endl;
-
- cout << "Zero Items" << endl;
-
- /* Iterator constructed from empty tree. */
- Tree::Iter i1(tree);
- cout << i1.lte() << " " << i1.end() << " " << i1.gtb() << " " <<
- i1.beg() << " " << i1.first() << " " << i1.last() << endl;
- Tree::Iter i2(tree.first());
- cout << i2.lte() << " " << i2.end() << " " << i2.gtb() << " " <<
- i2.beg() << " " << i2.first() << " " << i2.last() << endl;
- Tree::Iter i3(tree.last());
- cout << i3.lte() << " " << i3.end() << " " << i3.gtb() << " " <<
- i3.beg() << " " << i3.first() << " " << i3.last() << endl;
-
- /* Iterator assigned from an empty tree. */
- i1 = tree;
- cout << i1.lte() << " " << i1.end() << " " << i1.gtb() << " " <<
- i1.beg() << " " << i1.first() << " " << i1.last() << endl;
- i2 = tree.first();
- cout << i2.lte() << " " << i2.end() << " " << i2.gtb() << " " <<
- i2.beg() << " " << i2.first() << " " << i2.last() << endl;
- i3 = tree.last();
- cout << i3.lte() << " " << i3.end() << " " << i3.gtb() << " " <<
- i3.beg() << " " << i3.first() << " " << i3.last() << endl;
-
- cout << "One Item" << endl;
- tree.insert( 1 );
-
- /* Iterator constructed from an a tree with one item. */
- Tree::Iter i4(tree);
- cout << i4.lte() << " " << i4.end() << " " << i4.gtb() << " " <<
- i4.beg() << " " << i4.first() << " " << i4.last() << endl;
- Tree::Iter i5(tree.first());
- cout << i5.lte() << " " << i5.end() << " " << i5.gtb() << " " <<
- i5.beg() << " " << i5.first() << " " << i5.last() << endl;
- Tree::Iter i6(tree.last());
- cout << i6.lte() << " " << i6.end() << " " << i6.gtb() << " " <<
- i6.beg() << " " << i6.first() << " " << i6.last() << endl;
-
- /* Iterator assigned from an a tree with one item. */
- i4 = tree;
- cout << i4.lte() << " " << i4.end() << " " << i4.gtb() << " " <<
- i4.beg() << " " << i4.first() << " " << i4.last() << endl;
- i5 = tree.first();
- cout << i5.lte() << " " << i5.end() << " " << i5.gtb() << " " <<
- i5.beg() << " " << i5.first() << " " << i5.last() << endl;
- i6 = tree.last();
- cout << i6.lte() << " " << i6.end() << " " << i6.gtb() << " " <<
- i6.beg() << " " << i6.first() << " " << i6.last() << endl;
-
- cout << "Two Items" << endl;
- tree.insert( 2 );
-
- /* Iterator constructed from an a tree with two items. */
- Tree::Iter i7(tree);
- cout << i7.lte() << " " << i7.end() << " " << i7.gtb() << " " <<
- i7.beg() << " " << i7.first() << " " << i7.last() << endl;
- Tree::Iter i8(tree.first());
- cout << i8.lte() << " " << i8.end() << " " << i8.gtb() << " " <<
- i8.beg() << " " << i8.first() << " " << i8.last() << endl;
- Tree::Iter i9(tree.last());
- cout << i9.lte() << " " << i9.end() << " " << i9.gtb() << " " <<
- i9.beg() << " " << i9.first() << " " << i9.last() << endl;
-
- /* Iterator assigned from an a tree with two items. */
- i7 = tree;
- cout << i7.lte() << " " << i7.end() << " " << i7.gtb() << " " <<
- i7.beg() << " " << i7.first() << " " << i7.last() << endl;
- i8 = tree.first();
- cout << i8.lte() << " " << i8.end() << " " << i8.gtb() << " " <<
- i8.beg() << " " << i8.first() << " " << i8.last() << endl;
- i9 = tree.last();
- cout << i9.lte() << " " << i9.end() << " " << i9.gtb() << " " <<
- i9.beg() << " " << i9.first() << " " << i9.last() << endl;
-
- tree.empty();
- tree.insert( 1 );
- tree.insert( 2 );
- tree.insert( 3 );
- tree.insert( 4 );
-
- cout << "test1" << endl;
- Tree::Iter it1 = tree;
- for ( ; it1.lte(); it1++ )
- cout << it1->key << endl;
-
- cout << "test2" << endl;
- Tree::Iter it2 = tree.first();
- for ( ; it2.lte(); it2++ )
- cout << it2->key << endl;
-
- cout << "test3" << endl;
- Tree::Iter it3 = tree.last();
- for ( ; it3.gtb(); it3-- )
- cout << it3->key << endl;
-
- cout << "test4" << endl;
- it1 = tree;
- for ( ; !it1.end(); it1++ )
- cout << it1->key << endl;
-
- cout << "test5" << endl;
- it2 = tree.first();
- for ( ; !it2.end(); it2++ )
- cout << it2->key << endl;
-
- cout << "test6" << endl;
- it3 = tree.last();
- for ( ; !it3.beg(); it3-- )
- cout << it3->key << endl;
-}
-
-void testIterWalkable()
-{
- TreeI tree;
-
- cout << "WALKABLE" << endl;
- cout << "Iterator Default Constructor" << endl;
-
- /* Default constructed iterator. */
- TreeI::Iter defIt;
- cout << defIt.lte() << " " << defIt.end() << " " << defIt.gtb() << " " <<
- defIt.beg() << " " << defIt.first() << " " << defIt.last() << endl;
-
- cout << "Zero Items" << endl;
-
- /* Iterator constructed from empty tree. */
- TreeI::Iter i1(tree);
- cout << i1.lte() << " " << i1.end() << " " << i1.gtb() << " " <<
- i1.beg() << " " << i1.first() << " " << i1.last() << endl;
- TreeI::Iter i2(tree.first());
- cout << i2.lte() << " " << i2.end() << " " << i2.gtb() << " " <<
- i2.beg() << " " << i2.first() << " " << i2.last() << endl;
- TreeI::Iter i3(tree.last());
- cout << i3.lte() << " " << i3.end() << " " << i3.gtb() << " " <<
- i3.beg() << " " << i3.first() << " " << i3.last() << endl;
-
- /* Iterator assigned from an empty tree. */
- i1 = tree;
- cout << i1.lte() << " " << i1.end() << " " << i1.gtb() << " " <<
- i1.beg() << " " << i1.first() << " " << i1.last() << endl;
- i2 = tree.first();
- cout << i2.lte() << " " << i2.end() << " " << i2.gtb() << " " <<
- i2.beg() << " " << i2.first() << " " << i2.last() << endl;
- i3 = tree.last();
- cout << i3.lte() << " " << i3.end() << " " << i3.gtb() << " " <<
- i3.beg() << " " << i3.first() << " " << i3.last() << endl;
-
- cout << "One Item" << endl;
- tree.insert( 1 );
-
- /* Iterator constructed from an a tree with one item. */
- TreeI::Iter i4(tree);
- cout << i4.lte() << " " << i4.end() << " " << i4.gtb() << " " <<
- i4.beg() << " " << i4.first() << " " << i4.last() << endl;
- TreeI::Iter i5(tree.first());
- cout << i5.lte() << " " << i5.end() << " " << i5.gtb() << " " <<
- i5.beg() << " " << i5.first() << " " << i5.last() << endl;
- TreeI::Iter i6(tree.last());
- cout << i6.lte() << " " << i6.end() << " " << i6.gtb() << " " <<
- i6.beg() << " " << i6.first() << " " << i6.last() << endl;
-
- /* Iterator assigned from an a tree with one item. */
- i4 = tree;
- cout << i4.lte() << " " << i4.end() << " " << i4.gtb() << " " <<
- i4.beg() << " " << i4.first() << " " << i4.last() << endl;
- i5 = tree.first();
- cout << i5.lte() << " " << i5.end() << " " << i5.gtb() << " " <<
- i5.beg() << " " << i5.first() << " " << i5.last() << endl;
- i6 = tree.last();
- cout << i6.lte() << " " << i6.end() << " " << i6.gtb() << " " <<
- i6.beg() << " " << i6.first() << " " << i6.last() << endl;
-
- cout << "Two Items" << endl;
- tree.insert( 2 );
-
- /* Iterator constructed from an a tree with two items. */
- TreeI::Iter i7(tree);
- cout << i7.lte() << " " << i7.end() << " " << i7.gtb() << " " <<
- i7.beg() << " " << i7.first() << " " << i7.last() << endl;
- TreeI::Iter i8(tree.first());
- cout << i8.lte() << " " << i8.end() << " " << i8.gtb() << " " <<
- i8.beg() << " " << i8.first() << " " << i8.last() << endl;
- TreeI::Iter i9(tree.last());
- cout << i9.lte() << " " << i9.end() << " " << i9.gtb() << " " <<
- i9.beg() << " " << i9.first() << " " << i9.last() << endl;
-
- /* Iterator assigned from an a tree with two items. */
- i7 = tree;
- cout << i7.lte() << " " << i7.end() << " " << i7.gtb() << " " <<
- i7.beg() << " " << i7.first() << " " << i7.last() << endl;
- i8 = tree.first();
- cout << i8.lte() << " " << i8.end() << " " << i8.gtb() << " " <<
- i8.beg() << " " << i8.first() << " " << i8.last() << endl;
- i9 = tree.last();
- cout << i9.lte() << " " << i9.end() << " " << i9.gtb() << " " <<
- i9.beg() << " " << i9.first() << " " << i9.last() << endl;
-
- tree.insert( 4 );
- tree.insert( 3 );
- tree.insert( 2 );
- tree.insert( 1 );
-
- cout << "test1" << endl;
- TreeI::Iter it1 = tree;
- for ( ; it1.lte(); it1++ )
- cout << it1->key << endl;
-
- cout << "test2" << endl;
- TreeI::Iter it2 = tree.first();
- for ( ; it2.lte(); it2++ )
- cout << it2->key << endl;
-
- cout << "test3" << endl;
- TreeI::Iter it3 = tree.last();
- for ( ; it3.gtb(); it3-- )
- cout << it3->key << endl;
-
- cout << "test4" << endl;
- it1 = tree;
- for ( ; !it1.end(); it1++ )
- cout << it1->key << endl;
-
- cout << "test5" << endl;
- it2 = tree.first();
- for ( ; !it2.end(); it2++ )
- cout << it2->key << endl;
-
- cout << "test6" << endl;
- it3 = tree.last();
- for ( ; !it3.beg(); it3-- )
- cout << it3->key << endl;
-}
-
-
-int main()
-{
- testIterWalkable();
- testIterNotWalkable();
- return 0;
-}
diff --git a/test/test_avlkeyless.cpp b/test/test_avlkeyless.cpp
deleted file mode 100644
index 79f73f88..00000000
--- a/test/test_avlkeyless.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2001 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <iostream>
-#include "avlkeyless.h"
-
-using namespace std;
-
-/* Test element. */
-struct TreeEl : public AvlTreeEl<TreeEl>
-{
- TreeEl() : inTree(false) { }
- bool inTree;
-};
-
-/* Instantiate the entire tree. */
-template class AvlKeyless< TreeEl >;
-
-int main()
-{
- return 0;
-}
diff --git a/test/test_bstmap.cpp b/test/test_bstmap.cpp
deleted file mode 100644
index 855ff5c6..00000000
--- a/test/test_bstmap.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2001, 2002 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <iostream>
-#include <stdio.h>
-
-using std::cout;
-using std::endl;
-
-#include "bstmap.h"
-
-typedef BstMap< const char *, int, CmpStr > Map;
-
-void testBstMap1()
-{
- cout << "TEST 1" << endl;
- Map m1( "hi there", 1 );
- Map m2( "friend" );
-
- cout << m1.data[0].key << endl;
- cout << m2.data[0].key << endl;
-}
-
-void testBstMap2()
-{
- cout << "TEST 2" << endl;
- Map table1( "hi" );
- cout << table1[0].key << endl;
-
- Map table2( "there", 1 );
- cout << table2[0].key << endl;
- cout << table2[0].value << endl;
-}
-
-
-int main()
-{
- testBstMap1();
- testBstMap2();
- return 0;
-}
diff --git a/test/test_bstset.cpp b/test/test_bstset.cpp
deleted file mode 100644
index 20211c33..00000000
--- a/test/test_bstset.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2001, 2002 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <iostream>
-#include <stdio.h>
-
-#include "bstset.h"
-#include "avlset.h"
-using namespace std;
-
-template class BstSet< int, CmpOrd<int> >;
-template class AvlSet< int, CmpOrd<int> >;
-
-int main()
-{
- BstSet< int, CmpOrd<int> > set1;
- AvlSet< int, CmpOrd<int> > set2;
-
- set1.insert(0);
- set2.insert(0);
-
- set1.insert(0);
- set2.insert(0);
-
- set1.insert(2);
- set2.insert(2);
-
- BstSet< int, CmpOrd<int> >::Iter it1 = set1;
- AvlSet< int, CmpOrd<int> >::Iter it2 = set2;
- for ( ; it1.lte(); it1++, it2++ )
- cout << *it1 << " " << it2->key << endl;
-
- for ( int i = 0; i < 20000; i++ )
- set1.insert( i );
-
- int num = 0;
- for ( int i = 0; i < 20000; i++ ) {
- BstSet< int, CmpOrd<int> >::Iter iter = set1;
- for ( ; !iter.end(); iter++ )
- num += *iter;
- }
- cout << num << endl;
-
- return 0;
-}
diff --git a/test/test_bsttable.cpp b/test/test_bsttable.cpp
deleted file mode 100644
index 87de9222..00000000
--- a/test/test_bsttable.cpp
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright 2001 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <iostream>
-#include <stdio.h>
-
-#include "bsttable.h"
-#include "bstmap.h"
-#include "bstset.h"
-
-using namespace std;
-
-struct MyElement : public CmpOrd<int>
-{
- MyElement() {}
- MyElement(int key) : key(key) { }
- const int &getKey() const { return key; }
- int key;
-};
-
-template class BstTable<MyElement, int>;
-
-void testBstTable1()
-{
- BstMap<int, int, CmpOrd<int> > table;
-
- table.insert(1, 3);
- table.insert(3, 1);
- table.insert(5, 0);
- table.insert(7, 1);
- table.insert(4, 8);
- table.insert(2, 0);
- table.insert(6, 1);
-
- table.remove(2);
- table.remove(3);
- table.remove(6);
- table.remove(4);
- table.remove(5);
- table.remove(7);
-
- BstMapEl<int, int> *tab = table.data;
- int len = table.tabLen;
- for (int i = 0; i < len; i++, tab++)
- printf("(%i) maps to %i\n", tab->key, tab->value);
-}
-
-struct CompoundKey
-{
- int Key1;
- int Key2;
-};
-
-struct CompoundKeyCompare
-{
- inline static int compare(const CompoundKey &key1, const CompoundKey &key2)
- {
- if ( key1.Key1 < key2.Key1 )
- return -1;
- else if ( key1.Key1 > key2.Key1 )
- return 1;
- else
- {
- if ( key1.Key2 < key2.Key2 )
- return -1;
- else if ( key1.Key2 > key2.Key2 )
- return 1;
- else
- return 0;
- }
- }
-};
-
-void testBstTable2()
-{
- BstMap<CompoundKey, int, CompoundKeyCompare > table;
-
- CompoundKey k;
-
- k.Key1 = 1; k.Key2 = 2;
- table.insert(k, 10);
-
- k.Key1 = 1; k.Key2 = 3;
- table.insert(k, 10);
-
- k.Key1 = 2; k.Key2 = 2;
- table.insert(k, 10);
-
- k.Key1 = 0; k.Key2 = 2;
- table.insert(k, 10);
-
- k.Key1 = 2; k.Key2 = -10;
- table.insert(k, 10);
-
- BstMapEl<CompoundKey, int> *tab = table.data;
- int len = table.tabLen;
- for (int i = 0; i < len; i++, tab++)
- printf("(%i, %i) maps to %i\n", tab->key.Key1, tab->key.Key2, tab->value);
-}
-
-struct KeyStruct
-{
- /* Constructors. */
- KeyStruct() : key(0) { }
- KeyStruct(int i) : key(i)
- { cout << "KeyStruct(" << key << ")" << endl; }
- KeyStruct(const KeyStruct &o) : key(o.key)
- { cout << "KeyStruct(KeyStruct &)" << endl; }
-
- /* Destructors. */
- ~KeyStruct() { cout << "~KeyStruct = {" << key << "}" << endl; }
-
- int key;
-};
-
-struct KeyStructCompare
-{
- static inline int compare(const KeyStruct &k1, const KeyStruct &k2)
- { return CmpOrd<int>::compare(k1.key, k2.key); }
-};
-
-int testBstTable3()
-{
- BstMap<KeyStruct, int, KeyStructCompare > tbl;
-
- cout << "ins res = " << tbl.insert(KeyStruct(0), 1) << endl;
- cout << "ins res = " << tbl.insert(KeyStruct(1), 1) << endl;
- return 0;
-}
-
-int testBstTable4()
-{
- BstMap<int, int, CmpOrd<int> > tbl;
-
- tbl.insertMulti(1, 1);
- tbl.insertMulti(4, 1);
- tbl.insertMulti(2, 1);
- tbl.insertMulti(1, 1);
- tbl.insertMulti(1, 1);
- tbl.insertMulti(1, 3);
- tbl.insertMulti(3, 1);
- tbl.insertMulti(1, 0);
- tbl.insertMulti(7, 1);
- tbl.insertMulti(4, 8);
- tbl.insertMulti(1, 0);
- tbl.insertMulti(6, 1);
-
- BstMapEl<int, int> *low, *high;
-
- tbl.findMulti( 1, low, high );
- cout << high - low + 1 << endl;
-
- cout << tbl.removeMulti( 1 ) << endl;
- cout << tbl.findMulti( 1, low, high ) << endl;
- return 0;
-}
-
-int testBstTable5()
-{
- cout << "TEST 5" << endl;
-
- BstTable<MyElement, int> table1, table2;
- table1.insert( 1 );
- table1.insert( 2 );
- table1.insert( 3 );
- table1.insertMulti( 2 );
-
- table2.insert( 3 );
- table2.insert( table1 );
-
- for ( int i = 0; i < table2.tabLen; i++ )
- cout << table2.data[i].key << endl;
-
- table2.insertMulti( table1 );
- for ( int i = 0; i < table2.tabLen; i++ )
- cout << table2.data[i].key << endl;
- return 0;
-}
-
-void testBstTable6()
-{
- cout << "TEST 6" << endl;
- BstTable<MyElement, int> table1( MyElement(1) );
- cout << table1[0].key << endl;
-}
-
-int main()
-{
- testBstTable1();
- testBstTable2();
- testBstTable3();
- testBstTable4();
- testBstTable5();
- testBstTable6();
- return 0;
-}
diff --git a/test/test_bubblesort.cpp b/test/test_bubblesort.cpp
deleted file mode 100644
index 4edd33fa..00000000
--- a/test/test_bubblesort.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2002 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <stdlib.h>
-#include <time.h>
-#include <iostream>
-#include <vector>
-#include "vector.h"
-#include "bubblesort.h"
-#include "compare.h"
-
-using namespace std;
-
-void testBubbleSort1()
-{
- Vector<int> v;
- BubbleSort< int, CmpOrd<int> > bubbleSort;
-
- int numItems = 1 + (random() % 100);
- for ( int i = 0; i < numItems; i++ )
- v.append(random() % 100);
-
-
- bubbleSort.sort( v.data, v.tabLen );
- int *tel = v.data;
- int tlen = v.tabLen;
- for ( int i = 0; i < tlen; i++, tel++ )
- cout << *tel << endl;
-}
-
-struct Data
-{
- Data() { }
- Data(const Data&) { cout << __PRETTY_FUNCTION__ << endl; }
- ~Data() { }
- Data &operator=(const Data&) { cout << __PRETTY_FUNCTION__ << endl; return *this; }
-
- double data[4];
-
- static inline int compare( const Data &d1, const Data &d2 )
- {
- return memcmp( d1.data, d2.data, sizeof(d1.data) );
- }
-};
-
-#define TEST2_SIZE 1000
-void testBubbleSort2()
-{
- Data data[TEST2_SIZE];
- BubbleSort<Data, Data> bubbleSort;
-
- for ( int i = 0; i < TEST2_SIZE; i++ ) {
- data[i].data[0] = drand48();
- data[i].data[1] = drand48();
- data[i].data[2] = drand48();
- data[i].data[3] = drand48();
- }
-
- bubbleSort.sort( data, TEST2_SIZE );
-}
-
-#define TEST3_SIZE 20000
-void testBubbleSort3()
-{
- static int data[TEST3_SIZE];
- BubbleSort< int, CmpOrd<int> > bubbleSort;
-
- for ( int i = 0; i < TEST3_SIZE; i++ )
- data[i] = random();
-
- bubbleSort.sort( data, TEST3_SIZE );
-}
-
-int main()
-{
- srandom( time(0) );
- srand48( time(0) );
- testBubbleSort1();
- return 0;
-}
-
diff --git a/test/test_compare.cpp b/test/test_compare.cpp
deleted file mode 100644
index f7673879..00000000
--- a/test/test_compare.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2005 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <stdio.h>
-#include <iostream>
-#include <assert.h>
-
-#include "vector.h"
-#include "compare.h"
-#include "bstset.h"
-
-using namespace std;
-
-struct Item
-{
- int i;
-};
-
-struct CmpItem
-{
- int compareData;
- int compare( const Item &k1, const Item &k2 )
- {
- if ( k1.i < k2.i )
- return -1;
- else if ( k1.i > k2.i )
- return 1;
- else
- return 0;
- }
-};
-
-int main()
-{
- Vector<Item> v;
- BstSet< Vector<Item>, CmpTableNs<Item, CmpItem> > bst;
- bst.insert(Vector<Item>());
-}
diff --git a/test/test_dlistval.cpp b/test/test_dlistval.cpp
deleted file mode 100644
index dfcedf08..00000000
--- a/test/test_dlistval.cpp
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright 2002 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <iostream>
-#include "dlistval.h"
-using namespace std;
-
-template class DListVal<int>;
-typedef DListVal<int> List;
-
-void testDoubleList()
-{
- List list, list2;
- list.append( 1 );
- list.append( 2 );
- list.append( 3 );
- list.append( 4 );
-
- List::Iter it = list;
- while ( !it.end() && it->value != 3 )
- it++;
-
- list2 = list;
- cout << it->value << endl;
-}
-
-void testDLIter()
-{
- List list;
-
- cout << "Iterator Default Constructor" << endl;
-
- /* Default constructed iterator. */
- List::Iter defIt;
- cout << defIt.lte() << " " << defIt.end() << " " << defIt.gtb() << " " <<
- defIt.beg() << " " << defIt.first() << " " << defIt.last() << endl;
-
- cout << "Zero Items" << endl;
-
- /* Iterator constructed from empty list. */
- List::Iter i1(list);
- cout << i1.lte() << " " << i1.end() << " " << i1.gtb() << " " <<
- i1.beg() << " " << i1.first() << " " << i1.last() << endl;
- List::Iter i2(list.first());
- cout << i2.lte() << " " << i2.end() << " " << i2.gtb() << " " <<
- i2.beg() << " " << i2.first() << " " << i2.last() << endl;
- List::Iter i3(list.last());
- cout << i3.lte() << " " << i3.end() << " " << i3.gtb() << " " <<
- i3.beg() << " " << i3.first() << " " << i3.last() << endl;
-
- /* Iterator assigned from an empty list. */
- i1 = list;
- cout << i1.lte() << " " << i1.end() << " " << i1.gtb() << " " <<
- i1.beg() << " " << i1.first() << " " << i1.last() << endl;
- i2 = list.first();
- cout << i2.lte() << " " << i2.end() << " " << i2.gtb() << " " <<
- i2.beg() << " " << i2.first() << " " << i2.last() << endl;
- i3 = list.last();
- cout << i3.lte() << " " << i3.end() << " " << i3.gtb() << " " <<
- i3.beg() << " " << i3.first() << " " << i3.last() << endl;
-
- cout << "One Item" << endl;
- list.append( 1 );
-
- /* Iterator constructed from an a list with one item. */
- List::Iter i4(list);
- cout << i4.lte() << " " << i4.end() << " " << i4.gtb() << " " <<
- i4.beg() << " " << i4.first() << " " << i4.last() << endl;
- List::Iter i5(list.first());
- cout << i5.lte() << " " << i5.end() << " " << i5.gtb() << " " <<
- i5.beg() << " " << i5.first() << " " << i5.last() << endl;
- List::Iter i6(list.last());
- cout << i6.lte() << " " << i6.end() << " " << i6.gtb() << " " <<
- i6.beg() << " " << i6.first() << " " << i6.last() << endl;
-
- /* Iterator assigned from an a list with one item. */
- i4 = list;
- cout << i4.lte() << " " << i4.end() << " " << i4.gtb() << " " <<
- i4.beg() << " " << i4.first() << " " << i4.last() << endl;
- i5 = list.first();
- cout << i5.lte() << " " << i5.end() << " " << i5.gtb() << " " <<
- i5.beg() << " " << i5.first() << " " << i5.last() << endl;
- i6 = list.last();
- cout << i6.lte() << " " << i6.end() << " " << i6.gtb() << " " <<
- i6.beg() << " " << i6.first() << " " << i6.last() << endl;
-
- cout << "Two Items" << endl;
- list.append( 2 );
-
- /* Iterator constructed from an a list with two items. */
- List::Iter i7(list);
- cout << i7.lte() << " " << i7.end() << " " << i7.gtb() << " " <<
- i7.beg() << " " << i7.first() << " " << i7.last() << endl;
- List::Iter i8(list.first());
- cout << i8.lte() << " " << i8.end() << " " << i8.gtb() << " " <<
- i8.beg() << " " << i8.first() << " " << i8.last() << endl;
- List::Iter i9(list.last());
- cout << i9.lte() << " " << i9.end() << " " << i9.gtb() << " " <<
- i9.beg() << " " << i9.first() << " " << i9.last() << endl;
-
- /* Iterator assigned from an a list with two items. */
- i7 = list;
- cout << i7.lte() << " " << i7.end() << " " << i7.gtb() << " " <<
- i7.beg() << " " << i7.first() << " " << i7.last() << endl;
- i8 = list.first();
- cout << i8.lte() << " " << i8.end() << " " << i8.gtb() << " " <<
- i8.beg() << " " << i8.first() << " " << i8.last() << endl;
- i9 = list.last();
- cout << i9.lte() << " " << i9.end() << " " << i9.gtb() << " " <<
- i9.beg() << " " << i9.first() << " " << i9.last() << endl;
-
- list.empty();
- list.append( 1 );
- list.append( 2 );
- list.append( 3 );
- list.append( 4 );
-
- cout << "test1" << endl;
- List::Iter it1 = list;
- for ( ; it1.lte(); it1++ )
- cout << it1->value << endl;
-
- cout << "test2" << endl;
- List::Iter it2 = list.first();
- for ( ; it2.lte(); it2++ )
- cout << it2->value << endl;
-
- cout << "test3" << endl;
- List::Iter it3 = list.last();
- for ( ; it3.gtb(); it3-- )
- cout << it3->value << endl;
-
- cout << "test4" << endl;
- it1 = list;
- for ( ; !it1.end(); it1++ )
- cout << it1->value << endl;
-
- cout << "test5" << endl;
- it2 = list.first();
- for ( ; !it2.end(); it2++ )
- cout << it2->value << endl;
-
- cout << "test6" << endl;
- it3 = list.last();
- for ( ; !it3.beg(); it3-- )
- cout << it3->value << endl;
-}
-
-int main()
-{
- testDoubleList();
- testDLIter();
- return 0;
-}
-
diff --git a/test/test_doublelist.cpp b/test/test_doublelist.cpp
deleted file mode 100644
index 5367262a..00000000
--- a/test/test_doublelist.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2001 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <stdio.h>
-#include <iostream>
-#include "dlist.h"
-#include "dlistmel.h"
-#include "dlistval.h"
-
-using std::cout;
-using std::endl;
-
-/*
- * DListMel
- */
-struct obj;
-class MyListEl1 : public DListEl<obj> { };
-class MyListEl2 : public DListEl<obj> { };
-struct obj : public MyListEl1, public MyListEl2
-{
- int data;
-};
-template class DListMel< obj, MyListEl2 >;
-
-/*
- * DList
- */
-struct SingleObj : public DListEl<SingleObj> { };
-template class DList< SingleObj >;
-
-/*
- * DListVal
- */
-template class DListVal< int >;
-
-struct Integer
-{
- Integer(const int &i) : i(i) { }
- Integer() : i(0) { }
-
- int i;
-};
-
-void testDoubleList()
-{
- DListVal<Integer> dl;
- Integer i = 0;
- dl.append(Integer(1));
- dl.prepend( i );
- dl.addAfter( dl.head, Integer(22) );
-
- DListVal<Integer>::Iter it = dl;
- for ( it = dl; ! it.end(); it++ )
- printf("%i\n", it->value.i);
-}
-
-void testConstructors1()
-{
- DListVal<int> dl;
- dl.append( 1 );
- dl.append( 2 );
- DListVal<int> copy(dl);
- dl.empty();
-
- for ( DListVal<int>::Iter i = copy; i.lte(); i++ )
- cout << i->value << endl;
- dl.empty();
-}
-
-void testConstructors2()
-{
- DListVal<int> dl;
- dl.append( 1 );
- dl.append( 2 );
- DListVal<int> copy(dl);
- dl.empty();
-
- for ( DListVal<int>::Iter i = copy; i.lte(); i++ )
- cout << i->value << endl;
-
- dl.empty();
-}
-
-int main()
-{
- testDoubleList();
- testConstructors1();
- testConstructors2();
- return 0;
-}
diff --git a/test/test_insertsort.cpp b/test/test_insertsort.cpp
deleted file mode 100644
index 511e29de..00000000
--- a/test/test_insertsort.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2002 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <stdlib.h>
-#include <time.h>
-#include <iostream>
-#include <vector>
-#include "vector.h"
-#include "insertsort.h"
-#include "compare.h"
-
-using namespace std;
-
-void testInsertSort1()
-{
- Vector<int> v;
- InsertSort< int, CmpOrd<int> > is;
-
- int numItems = 1 + (random() % 100);
- for ( int i = 0; i < numItems; i++ )
- v.append(random() % 100);
-
- is.sort( v.data, v.tabLen );
- int *tel = v.data;
- int tlen = v.tabLen;
- for ( int i = 0; i < tlen; i++, tel++ )
- cout << *tel << endl;
-}
-
-struct Data
-{
- Data() { }
- Data(const Data&) { cout << __PRETTY_FUNCTION__ << endl; }
- ~Data() { }
- Data &operator=(const Data&) { cout << __PRETTY_FUNCTION__ << endl; return *this; }
-
- double data[4];
-
- static inline int compare( const Data &d1, const Data &d2 )
- {
- return memcmp( d1.data, d2.data, sizeof(d1.data) );
- }
-};
-
-#define TEST2_SIZE 1000
-void testInsertSort2()
-{
- Data data[TEST2_SIZE];
- InsertSort<Data, Data> is;
-
- for ( int i = 0; i < TEST2_SIZE; i++ ) {
- data[i].data[0] = drand48();
- data[i].data[1] = drand48();
- data[i].data[2] = drand48();
- data[i].data[3] = drand48();
- }
-
- is.sort( data, TEST2_SIZE );
-}
-
-#define TEST3_SIZE 20000
-void testInsertSort3()
-{
- static int data[TEST3_SIZE];
- InsertSort< int, CmpOrd<int> > is;
-
- for ( int i = 0; i < TEST3_SIZE; i++ )
- data[i] = random();
-
- is.sort( data, TEST3_SIZE );
-}
-
-int main()
-{
- srandom( time(0) );
- srand48( time(0) );
- testInsertSort3();
- return 0;
-}
-
diff --git a/test/test_mergesort.cpp b/test/test_mergesort.cpp
deleted file mode 100644
index 5d9981e7..00000000
--- a/test/test_mergesort.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2001, 2002 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <stdlib.h>
-#include <time.h>
-#include <iostream>
-#include <vector>
-#include "vector.h"
-#include "mergesort.h"
-#include "compare.h"
-
-using namespace std;
-
-void testMergeSort1()
-{
- Vector<int> v;
- MergeSort< int, CmpOrd<int> > mergeSort;
-
- int numItems = 1 + (random() % 100);
- for ( int i = 0; i < numItems; i++ )
- v.append(random() % 100);
-
- mergeSort.sort( v.data, v.tabLen );
- int *tel = v.data;
- int tlen = v.tabLen;
- for ( int i = 0; i < tlen; i++, tel++ )
- cout << *tel << endl;
-}
-
-struct Data
-{
- Data() { }
- Data(const Data&) { cout << __PRETTY_FUNCTION__ << endl; }
- ~Data() { }
- Data &operator=(const Data&) { cout << __PRETTY_FUNCTION__ << endl; return *this; }
-
- double data[4];
-
- static inline int compare( const Data &d1, const Data &d2 )
- {
- return memcmp( d1.data, d2.data, sizeof(d1.data) );
- }
-};
-
-#define TEST2_SIZE 100000
-void testMergeSort2()
-{
- static Data data[TEST2_SIZE];
- MergeSort<Data, Data> mergeSort;
-
- for ( int i = 0; i < TEST2_SIZE; i++ ) {
- data[i].data[0] = drand48();
- data[i].data[1] = drand48();
- data[i].data[2] = drand48();
- data[i].data[3] = drand48();
- }
-
- mergeSort.sort( data, TEST2_SIZE );
-}
-
-#define TEST3_SIZE 1000000
-void testMergeSort3()
-{
- static int data[TEST3_SIZE];
- MergeSort< int, CmpOrd<int> > mergeSort;
-
- for ( int i = 0; i < TEST3_SIZE; i++ )
- data[i] = random();
-
- mergeSort.sort( data, TEST3_SIZE );
-}
-
-int main()
-{
- srandom( time(0) );
- srand48( time(0) );
- testMergeSort3();
- return 0;
-}
-
diff --git a/test/test_quicksort.cpp b/test/test_quicksort.cpp
deleted file mode 100644
index 37dfc3ad..00000000
--- a/test/test_quicksort.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2002 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <stdlib.h>
-#include <time.h>
-#include <iostream>
-#include <vector>
-#include "vector.h"
-#include "quicksort.h"
-#include "compare.h"
-
-using namespace std;
-
-void testQuickSort1()
-{
- Vector<int> v;
- QuickSort< int, CmpOrd<int> > qs;
-
- int numItems = 1 + (random() % 100);
- for ( int i = 0; i < numItems; i++ )
- v.append(random() % 100);
-
- qs.sort( v.data, v.tabLen );
- int *tel = v.data;
- int tlen = v.tabLen;
- for ( int i = 0; i < tlen; i++, tel++ )
- cout << *tel << endl;
-}
-
-struct Data
-{
- Data() { }
- Data(const Data&) { cout << __PRETTY_FUNCTION__ << endl; }
- ~Data() { }
- Data &operator=(const Data&) { cout << __PRETTY_FUNCTION__ << endl; return *this; }
-
- double data[4];
-
- static inline int compare( const Data &d1, const Data &d2 )
- {
- return memcmp( d1.data, d2.data, sizeof(d1.data) );
- }
-};
-
-#define TEST2_SIZE 100000
-void testQuickSort2()
-{
- static Data data[TEST2_SIZE];
- QuickSort<Data, Data> qs;
-
- for ( int i = 0; i < TEST2_SIZE; i++ ) {
- data[i].data[0] = drand48();
- data[i].data[1] = drand48();
- data[i].data[2] = drand48();
- data[i].data[3] = drand48();
- }
-
- qs.sort( data, TEST2_SIZE );
-}
-
-#define TEST3_SIZE 1000000
-void testQuickSort3()
-{
- static int data[TEST3_SIZE];
- QuickSort< int, CmpOrd<int> > qs;
- for ( int i = 0; i < TEST3_SIZE; i++ )
- data[i] = random();
-
- qs.sort( data, TEST3_SIZE );
-}
-
-int main()
-{
- srandom( time(0) );
- srand48( time(0) );
- testQuickSort3();
- return 0;
-}
diff --git a/test/test_rope.cpp b/test/test_rope.cpp
deleted file mode 100644
index 681bc66a..00000000
--- a/test/test_rope.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2002 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include "rope.h"
-#include <iostream>
-
-using std::cout;
-
-int main()
-{
- Rope r;
-
- r.append( "dude\n", 5 );
- r.append( "dude\n", 5 );
-
- for ( RopeBlock *rb = r.hblk; rb != 0; rb = rb->next ) {
- cout.write( r.data(rb), r.length(rb) );
- }
-
- return 0;
-}
-
diff --git a/test/test_sbstmap.cpp b/test/test_sbstmap.cpp
deleted file mode 100644
index f07dc6f1..00000000
--- a/test/test_sbstmap.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2001, 2002 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <iostream>
-#include <stdio.h>
-
-#include "sbstmap.h"
-
-template class SBstMap< char *, int, CmpStr >;
-
-int main()
-{
- return 0;
-}
diff --git a/test/test_sbstset.cpp b/test/test_sbstset.cpp
deleted file mode 100644
index 04f7306a..00000000
--- a/test/test_sbstset.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2001, 2002 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <iostream>
-#include <stdio.h>
-
-#include "sbstset.h"
-
-using namespace std;
-
-template class SBstSet< int, CmpOrd<int> >;
-
-int main()
-{
- SBstSet< int, CmpOrd<int> > set;
- set.insert(0);
- set.insert(0);
- set.insert(2);
-
- SBstSet< int, CmpOrd<int> >::Iter it;
- for ( it = set; !it.end(); it++ )
- cout << *it << endl;
-
- return 0;
-}
diff --git a/test/test_sbsttable.cpp b/test/test_sbsttable.cpp
deleted file mode 100644
index cb5dcfd2..00000000
--- a/test/test_sbsttable.cpp
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Copyright 2001 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <iostream>
-#include <stdio.h>
-
-#include "sbsttable.h"
-#include "sbstmap.h"
-#include "sbstset.h"
-
-using namespace std;
-
-struct MyElement : public CmpOrd<int>
-{
- MyElement() {}
- MyElement(int key) : key(key) { }
- const int &getKey() const { return key; }
- int key;
-};
-
-template class SBstTable<MyElement, int>;
-
-void testBstTable1()
-{
- SBstMap<int, int, CmpOrd<int> > table;
-
- table.insert(1, 3);
- table.insert(3, 1);
- table.insert(5, 0);
- table.insert(7, 1);
- table.insert(4, 8);
- table.insert(2, 0);
- table.insert(6, 1);
-
- table.remove(2);
- table.remove(3);
- table.remove(6);
- table.remove(4);
- table.remove(5);
- table.remove(7);
-
- SBstMapEl<int, int> *tab = table.data;
- int len = table.length();
- for (int i = 0; i < len; i++, tab++)
- printf("(%i) maps to %i\n", tab->key, tab->value);
-}
-
-struct CompoundKey
-{
- int Key1;
- int Key2;
-};
-
-struct CompoundKeyCompare
-{
- inline static int compare(const CompoundKey &key1, const CompoundKey &key2)
- {
- if ( key1.Key1 < key2.Key1 )
- return -1;
- else if ( key1.Key1 > key2.Key1 )
- return 1;
- else
- {
- if ( key1.Key2 < key2.Key2 )
- return -1;
- else if ( key1.Key2 > key2.Key2 )
- return 1;
- else
- return 0;
- }
- }
-};
-
-void testBstTable2()
-{
- SBstMap<CompoundKey, int, CompoundKeyCompare > table;
-
- CompoundKey k;
-
- k.Key1 = 1; k.Key2 = 2;
- table.insert(k, 10);
-
- k.Key1 = 1; k.Key2 = 3;
- table.insert(k, 10);
-
- k.Key1 = 2; k.Key2 = 2;
- table.insert(k, 10);
-
- k.Key1 = 0; k.Key2 = 2;
- table.insert(k, 10);
-
- k.Key1 = 2; k.Key2 = -10;
- table.insert(k, 10);
-
- SBstMapEl<CompoundKey, int> *tab = table.data;
- int len = table.length();
- for (int i = 0; i < len; i++, tab++)
- printf("(%i, %i) maps to %i\n", tab->key.Key1, tab->key.Key2, tab->value);
-}
-
-struct KeyStruct
-{
- /* Constructors. */
- KeyStruct() : key(0) { }
- KeyStruct(int i) : key(i)
- { cout << "KeyStruct(" << key << ")" << endl; }
- KeyStruct(const KeyStruct &o) : key(o.key)
- { cout << "KeyStruct(KeyStruct &)" << endl; }
-
- /* Destructors. */
- ~KeyStruct() { cout << "~KeyStruct = {" << key << "}" << endl; }
-
- int key;
-};
-
-struct KeyStructCompare
-{
- static inline int compare(const KeyStruct &k1, const KeyStruct &k2)
- { return CmpOrd<int>::compare(k1.key, k2.key); }
-};
-
-int testBstTable3()
-{
- SBstMap<KeyStruct, int, KeyStructCompare > tbl;
-
- cout << "ins res = " << tbl.insert(KeyStruct(0), 1) << endl;
- cout << "ins res = " << tbl.insert(KeyStruct(1), 1) << endl;
- return 0;
-}
-
-int testBstTable4()
-{
- SBstMap<int, int, CmpOrd<int> > tbl;
-
- tbl.insertMulti(1, 1);
- tbl.insertMulti(4, 1);
- tbl.insertMulti(2, 1);
- tbl.insertMulti(1, 1);
- tbl.insertMulti(1, 1);
- tbl.insertMulti(1, 3);
- tbl.insertMulti(3, 1);
- tbl.insertMulti(1, 0);
- tbl.insertMulti(7, 1);
- tbl.insertMulti(4, 8);
- tbl.insertMulti(1, 0);
- tbl.insertMulti(6, 1);
-
- SBstMapEl<int, int> *low, *high;
-
- tbl.findMulti( 1, low, high );
- cout << high - low + 1 << endl;
-
- cout << tbl.removeMulti( 1 ) << endl;
- cout << tbl.findMulti( 1, low, high ) << endl;
- return 0;
-}
-
-int testBstTable5()
-{
- cout << "TEST 5" << endl;
-
- SBstTable<MyElement, int> table1, table2;
- table1.insert( 1 );
- table1.insert( 2 );
- table1.insert( 3 );
- table1.insertMulti( 2 );
-
- table2.insert( 3 );
- table2.insert( table1 );
-
- for ( int i = 0; i < table2.length(); i++ )
- cout << table2.data[i].key << endl;
-
- table2.insertMulti( table1 );
- for ( int i = 0; i < table2.length(); i++ )
- cout << table2.data[i].key << endl;
- return 0;
-}
-
-int main()
-{
- testBstTable1();
- testBstTable2();
- testBstTable3();
- testBstTable4();
- testBstTable5();
- return 0;
-}
diff --git a/test/test_string.cpp b/test/test_string.cpp
deleted file mode 100644
index 6a6b25d5..00000000
--- a/test/test_string.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2002 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <iostream>
-#include "astring.h"
-
-using namespace std;
-
-template class StrTmpl<char>;
-
-void testString1()
-{
- String str1 = "hello";
- String str2 = "my";
- String str3 = "friend";
-
- String fmt( 5, "%.7f", 1.3/2.7 );
- String final = str1 + " there " + str2 + " " + str3;
-
- cout << String( 50, "%.7f", 1.3/2.7 ) << endl;
- cout << final << endl;
- cout << fmt << " " << fmt.length() << endl;
-
- String str4;
- StringStream ss( str4 );
-
- ss << 0.0000000011111111 << endl;
- cout << str4;
- cout.flush();
-}
-
-int main()
-{
- testString1();
- return 0;
-}
diff --git a/test/test_svector.cpp b/test/test_svector.cpp
deleted file mode 100644
index 96345f9d..00000000
--- a/test/test_svector.cpp
+++ /dev/null
@@ -1,547 +0,0 @@
-/*
- * Copyright 2001, 2003 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <stdio.h>
-#include <iostream>
-#include <assert.h>
-#include <time.h>
-
-#include "resize.h"
-#include "vector.h"
-#include "svector.h"
-#include "compare.h"
-
-#include "util.h"
-
-using namespace std;
-
-template class SVector< int, ResizeExpn >;
-template class SVector< int, ResizeLin >;
-template class SVector< int, ResizeConst >;
-template class SVector< int, ResizeRunTime >;
-template class SVector< int, ResizeCtLin<0> >;
-
-template struct CmpSTable< int, CmpOrd<int> >;
-
-void testVector1()
-{
- int pos, len;
- char c, string[200];
- SVector<char, ResizeLin> v;
-
- while( scanf("%c", &c) == 1 ) {
- switch (c) {
- case 'a':
- /* Get the string to append. */
- fgets(string, 200, stdin);
-
- /* hack off the newline. */
- len = strlen(string) - 1;
- string[len] = 0;
-
- v.append(string, len);
- break;
-
- case 'p':
- /* Get the string to prepend. */
- fgets(string, 200, stdin);
-
- /* hack off the newline. */
- len = strlen(string) - 1;
- string[len] = 0;
-
- v.prepend(string, len);
- break;
-
- case 's':
- /* Get the string to set. */
- fgets(string, 200, stdin);
-
- /* hack off the newline. */
- len = strlen(string) - 1;
- string[len] = 0;
-
- v.setAs(string, len);
- break;
-
- case 'r':
- /* Get the pos */
- scanf("%i ", &pos);
-
- /* Get the string to replace. */
- fgets(string, 200, stdin);
-
- /* hack off the newline. */
- len = strlen(string) - 1;
- string[len] = 0;
-
- v.replace(pos, string, len);
- break;
-
- case 'i':
- /* Get the pos */
- scanf("%i ", &pos);
-
- /* Get the string to insert. */
- fgets(string, 200, stdin);
-
- /* hack off the newline. */
- len = strlen(string) - 1;
- string[len] = 0;
-
- v.insert(pos, string, len);
- break;
-
- case 'd':
- /* Get the length to remove. */
- scanf("%i", &pos);
- scanf("%i", &len);
- v.remove(pos, len);
- break;
-
- case 'w':
- if ( v.data == 0 ) {
- printf("L: 0 AL: 0\n");
- fputc('\n', stdout);
- }
- else {
- STabHead *head = ((STabHead*)v.data) - 1;
- printf("L: %li AL: %li\n", head->tabLen, head->allocLen);
- fwrite(v.data, 1, head->tabLen, stdout);
- fputc('\n', stdout);
- }
- break;
-
- case 'q':
- goto end;
-
- }
- }
-
-end:
- fwrite(v.data, 1, v.length(), stdout);
- fputc('\n', stdout);
-}
-
-/* Globals that the constructors and destructor count with. */
-int defaultCount = 0;
-int nonDefCount = 0;
-int copyCount = 0;
-int destructorCount = 0;
-
-/* Reset the globals for the next test. */
-void reset()
-{
- defaultCount = 0;
- nonDefCount = 0;
- copyCount = 0;
- destructorCount = 0;
-}
-
-/* An assert that resets the globals and does an assert. */
-#define assert_reset(test) assert(test); reset();
-
-/* Data structure whos constructors and destructor count callings. */
-struct TheData
-{
- TheData() : i(0) { defaultCount++; }
- TheData(int i) : i(i) { nonDefCount++; }
- TheData(const TheData &d) : i(1) { copyCount++; }
- ~TheData() { destructorCount++; }
- int i;
-};
-
-bool operator==(const TheData &td1, const TheData &td2)
- { return td1.i == td2.i; }
-
-void testDelete()
-{
- /* Initialization. */
- SVector< TheData, ResizeLin > v1;
- v1.setAsNew(10);
- assert_reset( defaultCount == 10 );
-
- /* Delete some. */
- v1.remove( 5, 3 );
- assert_reset( destructorCount == 3 );
-
- /* Delete some more. */
- v1.remove( 0, 4 );
- assert_reset( destructorCount == 4 );
-
- /* Test length. */
- assert_reset( v1.length() == 3 );
-}
-
-void testInsert()
-{
- /* Simple Construct calls. */
- TheData sampleData[10];
- assert_reset( defaultCount == 10 );
-
- /* Initialization. */
- SVector< TheData, ResizeLin > v1;
- v1.setAsNew(6);
- assert_reset( defaultCount == 6 );
-
- /* Copy Constructor. */
- SVector< TheData, ResizeLin > v2(v1);
- assert_reset( copyCount == 0 );
-
- /* Insert, some shifted over. */
- v1.insert(1, sampleData, 4);
- assert_reset( v1.length() == 10 && destructorCount == 0 && copyCount == 10 );
-
- /* Insert, none shifted over. */
- v1.insert(10, sampleData, 4);
- assert_reset( defaultCount == 0 && copyCount == 4 );
-
- /* Insert some new items. */
- v1.insertNew(0, 10);
- assert_reset( v1.length() == 24 && defaultCount == 10 && copyCount == 0 );
-
- /* Insert some duplicates. */
- v1.insertDup(-1, TheData(), 6);
- assert_reset( v1.length() == 30 && defaultCount == 1 && copyCount == 6 );
-}
-
-void testSetAs()
-{
- /* Simple Construct calls. */
- TheData sampleData[10];
- assert_reset( defaultCount == 10 );
-
- /* Initialization. */
- SVector< TheData, ResizeLin > v1;
- v1.setAsNew(6);
- assert_reset( defaultCount == 6 );
-
- v1.setAs( sampleData, 10 );
- assert_reset( destructorCount == 6 && copyCount == 10 && defaultCount == 0 );
-}
-
-
-void testReplace()
-{
- /* Simple Construct calls. */
- TheData sampleData[10];
- assert_reset( defaultCount == 10 );
-
- /* Initialization. */
- SVector< TheData, ResizeLin > v1;
- v1.setAsNew(4);
- assert_reset( defaultCount == 4 );
-
- /* Copy Constructor. */
- SVector< TheData, ResizeLin > v2(v1);
- assert_reset( copyCount == 0 );
-
- /* Replace, some remove, some new. */
- v1.replace(1, sampleData, 4);
- assert_reset( destructorCount == 0 && copyCount == 5 );
-
- /* Replace, all remove. */
- v1.replace(0, sampleData, 5);
- assert_reset( destructorCount == 5 && copyCount == 5 );
-
- /* Replace, all new. */
- v1.replace(5, sampleData, 2);
- assert_reset( destructorCount == 0 && copyCount == 2 );
-
- /* Overwrite without going to the end. */
- v1.replace(0, sampleData, 1);
- assert_reset( destructorCount == 1 && defaultCount == 0 && copyCount == 1 );
-
- /* Ensure length is good. */
- assert_reset( v1.length() == 7 );
-}
-
-void testWithValues()
-{
- SVector< int, ResizeLin > v1;
- SVector< int, ResizeLin > v2;
-
- int i = 1;
- v1.append( i );
- v2.setAs(v1);
- i = 2;
- v1.insert( 0, i );
- assert_reset( v1.data[0] == 2 && v2.data[0] == 1 );
-
-}
-
-void testOperators1()
-{
- SVector<int, ResizeLin> v;
- v.append( 10 );
- v.append( 11 );
-
- printf("%li\n", v.size());
- printf("%i\n", v[0]);
- printf("%i\n", v[1]);
-
- SVector<int, ResizeLin>::Iter it;
- for ( it = v; it.lte(); it++ )
- cout << *it << endl;
-
- SVector<int, ResizeLin>::Iter itr;
- for ( itr = v; itr.gtb(); itr-- )
- cout << *itr << endl;
-}
-
-void testOperators2()
-{
- SVector< SVector<int> > vvi;
- vvi.setAsNew(1);
- SVector< SVector<int> >::Iter it;
- for ( it = vvi; it.lte(); it++ )
- cout << it->size() << endl;
-}
-
-void testCopying()
-{
- SVector<int> v1;
- v1.append(1);
- v1.append(2);
- v1.append(3);
-
- SVector<int> v2;
- v2.append(4);
- v2 = v1;
- cout << v2.size() << endl;
-}
-
-/* Data structure whos constructors and destructor count callings. */
-struct NoisyData
-{
- NoisyData() : i(0) { cout << __PRETTY_FUNCTION__ << endl; }
- NoisyData(int i) : i(i) { cout << __PRETTY_FUNCTION__ << endl; }
- NoisyData(const NoisyData &d) : i(d.i) { cout << __PRETTY_FUNCTION__ << endl; }
- ~NoisyData() { cout << __PRETTY_FUNCTION__ << endl; }
- int i;
-};
-
-template class SVector<NoisyData>;
-
-int testShared()
-{
- cout << sizeof(SVector<NoisyData>) << endl;
- SVector<NoisyData> v1;
- v1.setAsNew(2);
- SVector<NoisyData> v2;
- SVector<NoisyData> v3;
-
- v2.insert( 0, NoisyData(1) );
- v2.insert( 0, NoisyData(2) );
- v2.insert( 0, NoisyData(3) );
-
- v3 = v2;
- v3.replaceDup( 1, NoisyData(4), 4 );
-
- for ( int i = 0; i < v3.length(); i++ )
- cout << v3.data[i].i << endl;
-
- return 0;
-}
-
-#define LEN_THRESH 1000
-#define STATS_PERIOD 211
-#define OUTBUFSIZE 1000
-#define NUM_ROUNDS 1e9
-int curRound = 0;
-
-/* Print a statistics header. */
-void printHeader()
-{
- char buf[OUTBUFSIZE];
- expandTab( buf, "round\tlength\n" );
- fputs(buf, stdout);
-}
-
-
-/* Replace the current stats line with new stats. For one vect. */
-void printStats( Vector<TheData> &v1 )
-{
- /* Print stats. */
- char buf1[OUTBUFSIZE];
- char buf2[OUTBUFSIZE];
-
- memset( buf1, '\b', OUTBUFSIZE );
- fwrite( buf1, 1, OUTBUFSIZE, stdout );
- sprintf( buf1, "%i\t%li\t", curRound, v1.length() );
- expandTab( buf2, buf1 );
- fputs( buf2, stdout );
- fflush( stdout);
-}
-
-Vector<TheData> v1;
-SVector<TheData> v2;
-typedef SVector<int> SVect;
-
-void testIterator()
-{
- SVect vect;
-
- cout << "Iterator Default Constructor" << endl;
-
- /* Default constructed iterator. */
- SVect::Iter defIt;
- cout << defIt.lte() << " " << defIt.end() << " " << defIt.gtb() << " " <<
- defIt.beg() << " " << defIt.first() << " " << defIt.last() << endl;
-
- cout << "Zero Items" << endl;
-
- /* Iterator constructed from empty vect. */
- SVect::Iter i1(vect);
- cout << i1.lte() << " " << i1.end() << " " << i1.gtb() << " " <<
- i1.beg() << " " << i1.first() << " " << i1.last() << endl;
- SVect::Iter i2(vect.first());
- cout << i2.lte() << " " << i2.end() << " " << i2.gtb() << " " <<
- i2.beg() << " " << i2.first() << " " << i2.last() << endl;
- SVect::Iter i3(vect.last());
- cout << i3.lte() << " " << i3.end() << " " << i3.gtb() << " " <<
- i3.beg() << " " << i3.first() << " " << i3.last() << endl;
-
- /* Iterator assigned from an empty vect. */
- i1 = vect;
- cout << i1.lte() << " " << i1.end() << " " << i1.gtb() << " " <<
- i1.beg() << " " << i1.first() << " " << i1.last() << endl;
- i2 = vect.first();
- cout << i2.lte() << " " << i2.end() << " " << i2.gtb() << " " <<
- i2.beg() << " " << i2.first() << " " << i2.last() << endl;
- i3 = vect.last();
- cout << i3.lte() << " " << i3.end() << " " << i3.gtb() << " " <<
- i3.beg() << " " << i3.first() << " " << i3.last() << endl;
-
- cout << "One Item" << endl;
- vect.append( 1 );
-
- /* Iterator constructed from an a vect with one item. */
- SVect::Iter i4(vect);
- cout << i4.lte() << " " << i4.end() << " " << i4.gtb() << " " <<
- i4.beg() << " " << i4.first() << " " << i4.last() << endl;
- SVect::Iter i5(vect.first());
- cout << i5.lte() << " " << i5.end() << " " << i5.gtb() << " " <<
- i5.beg() << " " << i5.first() << " " << i5.last() << endl;
- SVect::Iter i6(vect.last());
- cout << i6.lte() << " " << i6.end() << " " << i6.gtb() << " " <<
- i6.beg() << " " << i6.first() << " " << i6.last() << endl;
-
- /* Iterator assigned from an a vect with one item. */
- i4 = vect;
- cout << i4.lte() << " " << i4.end() << " " << i4.gtb() << " " <<
- i4.beg() << " " << i4.first() << " " << i4.last() << endl;
- i5 = vect.first();
- cout << i5.lte() << " " << i5.end() << " " << i5.gtb() << " " <<
- i5.beg() << " " << i5.first() << " " << i5.last() << endl;
- i6 = vect.last();
- cout << i6.lte() << " " << i6.end() << " " << i6.gtb() << " " <<
- i6.beg() << " " << i6.first() << " " << i6.last() << endl;
-
- cout << "Two Items" << endl;
- vect.append( 2 );
-
- /* Iterator constructed from an a vect with two items. */
- SVect::Iter i7(vect);
- cout << i7.lte() << " " << i7.end() << " " << i7.gtb() << " " <<
- i7.beg() << " " << i7.first() << " " << i7.last() << endl;
- SVect::Iter i8(vect.first());
- cout << i8.lte() << " " << i8.end() << " " << i8.gtb() << " " <<
- i8.beg() << " " << i8.first() << " " << i8.last() << endl;
- SVect::Iter i9(vect.last());
- cout << i9.lte() << " " << i9.end() << " " << i9.gtb() << " " <<
- i9.beg() << " " << i9.first() << " " << i9.last() << endl;
-
- /* Iterator assigned from an a vect with two items. */
- i7 = vect;
- cout << i7.lte() << " " << i7.end() << " " << i7.gtb() << " " <<
- i7.beg() << " " << i7.first() << " " << i7.last() << endl;
- i8 = vect.first();
- cout << i8.lte() << " " << i8.end() << " " << i8.gtb() << " " <<
- i8.beg() << " " << i8.first() << " " << i8.last() << endl;
- i9 = vect.last();
- cout << i9.lte() << " " << i9.end() << " " << i9.gtb() << " " <<
- i9.beg() << " " << i9.first() << " " << i9.last() << endl;
-
- vect.empty();
- vect.append( 1 );
- vect.append( 2 );
- vect.append( 3 );
- vect.append( 4 );
-
- cout << "test1" << endl;
- SVect::Iter it1 = vect;
- for ( ; it1.lte(); it1++ )
- cout << *it1 << endl;
-
- cout << "test2" << endl;
- SVect::Iter it2 = vect.first();
- for ( ; it2.lte(); it2++ )
- cout << *it2 << endl;
-
- cout << "test3" << endl;
- SVect::Iter it3 = vect.last();
- for ( ; it3.gtb(); it3-- )
- cout << *it3 << endl;
-
- cout << "test4" << endl;
- it1 = vect;
- for ( ; !it1.end(); it1++ )
- cout << *it1 << endl;
-
- cout << "test5" << endl;
- it2 = vect.first();
- for ( ; !it2.end(); it2++ )
- cout << *it2 << endl;
-
- cout << "test6" << endl;
- it3 = vect.last();
- for ( ; !it3.beg(); it3-- )
- cout << *it3 << endl;
-}
-
-void testConstructor()
-{
- reset();
- SVector<TheData> v1( TheData(1) );
- v1.append( TheData() );
- SVector<TheData> v2( v1.data, v1.length() );
-
- cout << "testConstructor" << endl;
- assert( destructorCount == 2 && defaultCount == 1 && nonDefCount == 1 && copyCount == 4 );
-}
-
-int main()
-{
- testReplace();
- testInsert();
- testSetAs();
- testDelete();
- testWithValues();
- testOperators1();
- testOperators2();
- testCopying();
- testShared();
- testIterator();
- testConstructor();
- return 0;
-}
diff --git a/test/test_svectsimp.cpp b/test/test_svectsimp.cpp
deleted file mode 100644
index d193b996..00000000
--- a/test/test_svectsimp.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2002 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <iostream>
-#include <stdio.h>
-#include <assert.h>
-#include <time.h>
-
-#include "vectsimp.h"
-#include "svectsimp.h"
-
-using namespace std;
-
-template class SVectSimp<char>;
-
-void testVectSimp1()
-{
- SVectSimp< char > buffer;
- while ( ! cin.eof() ) {
- char c;
- cin >> c;
- buffer.append(c);
- }
-}
-
-void testSVectSimp2()
-{
- SVectSimp<char> b;
- for (int i = 0; i < 1000000; i++ )
- b.append("age writes code ", 12);
-}
-
-/* Data structure whos constructors and destructor count callings. */
-struct TheData
-{
- TheData() : i(0) { }
- TheData(int i) : i(i) { }
- TheData(const TheData &d) : i(1) { }
- ~TheData() { }
-
- int i;
-};
-
-bool operator==(const TheData &td1, const TheData &td2)
- { return td1.i == td2.i; }
-
-#define LEN_THRESH 1000
-#define STATS_PERIOD 211
-#define OUTBUFSIZE 1000
-//#define NUM_ROUNDS 1e9
-#define NUM_ROUNDS 100000
-int curRound = 0;
-
-void expandTab( char *dst, char *src );
-
-/* Print a statistics header. */
-void printHeader()
-{
- char buf[OUTBUFSIZE];
- expandTab( buf, "round\tlength" );
- cout << buf << endl;
-}
-
-
-/* Replace the current stats line with new stats. For one tree. */
-void printStats( VectSimp<TheData> &v1 )
-{
- /* Print stats. */
- static char buf[OUTBUFSIZE] = { 0 };
- char tmpBuf[OUTBUFSIZE];
-
- memset( buf, '\b', strlen(buf) );
- cout << buf;
- sprintf( tmpBuf, "%i\t%li\t", curRound, v1.length() );
- expandTab( buf, tmpBuf );
- cout << buf;
- cout.flush();
-}
-
-int main()
-{
- testSVectSimp2();
- return 0;
-}
diff --git a/test/test_tavltree.cpp b/test/test_tavltree.cpp
deleted file mode 100644
index 5b6fc282..00000000
--- a/test/test_tavltree.cpp
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Copyright 2001 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <iostream>
-#include "tavltree.h"
-#include "avltree.h"
-
-using namespace std;
-
-#define TAVLTREE
-
-#ifdef TAVLTREE
-
-/* Test element 1. */
-struct TreeEl1 : public TAvlTreeEl, public CmpOrd<int>
-{
- TreeEl1() { }
- TreeEl1(const int key) : key(key) { }
-
- int getKey() { return key; }
- int key;
-};
-
-/* Test element 2. */
-struct TreeEl2 : public TAvlTreeEl, public CmpOrd<int>
-{
- TreeEl2() { }
- TreeEl2(const int key) : key(key) { }
-
- int getKey() { return key; }
- int key;
-};
-
-/* Test element 3. */
-struct TreeEl3 : public TAvlTreeEl, public CmpOrd<int>
-{
- TreeEl3() { }
- TreeEl3(const int key) : key(key) { }
-
- int getKey() { return key; }
- int key;
-};
-
-/* Test element 4. */
-struct TreeEl4 : public TAvlTreeEl, public CmpOrd<int>
-{
- TreeEl4() { }
- TreeEl4(const int key) : key(key) { }
-
- int getKey() { return key; }
- int key;
-};
-
-/* Test element 5. */
-struct TreeEl5 : public TAvlTreeEl, public CmpOrd<int>
-{
- TreeEl5() { }
- TreeEl5(const int key) : key(key) { }
-
- int getKey() { return key; }
- int key;
-};
-
-/* Test element 6. */
-struct TreeEl6 : public TAvlTreeEl, public CmpOrd<int>
-{
- TreeEl6() { }
- TreeEl6(const int key) : key(key) { }
-
- int getKey() { return key; }
- int key;
-};
-
-typedef TAvlTree< TreeEl1, int > Tree1;
-typedef TAvlTree< TreeEl2, int > Tree2;
-typedef TAvlTree< TreeEl3, int > Tree3;
-typedef TAvlTree< TreeEl4, int > Tree4;
-typedef TAvlTree< TreeEl5, int > Tree5;
-typedef TAvlTree< TreeEl6, int > Tree6;
-
-/* Instantiate the entire tree. */
-//template class TAvlTree< TreeEl1, int >;
-//template class TAvlTree< TreeEl2, int >;
-//template class TAvlTree< TreeEl3, int >;
-//template class TAvlTree< TreeEl4, int >;
-//template class TAvlTree< TreeEl5, int >;
-//template class TAvlTree< TreeEl6, int >;
-
-#else
-
-/* Test element 1. */
-struct TreeEl1 : public AvlTreeEl<TreeEl1>, public CmpOrd<int>
-{
- TreeEl1() { }
- TreeEl1(const int key) : key(key) { }
-
- int getKey() { return key; }
- int key;
-};
-
-/* Test element 2. */
-struct TreeEl2 : public AvlTreeEl<TreeEl2>, public CmpOrd<int>
-{
- TreeEl2() { }
- TreeEl2(const int key) : key(key) { }
-
- int getKey() { return key; }
- int key;
-};
-
-/* Test element 3. */
-struct TreeEl3 : public AvlTreeEl<TreeEl3>, public CmpOrd<int>
-{
- TreeEl3() { }
- TreeEl3(const int key) : key(key) { }
-
- int getKey() { return key; }
- int key;
-};
-
-/* Test element 4. */
-struct TreeEl4 : public AvlTreeEl<TreeEl4>, public CmpOrd<int>
-{
- TreeEl4() { }
- TreeEl4(const int key) : key(key) { }
-
- int getKey() { return key; }
- int key;
-};
-
-/* Test element 5. */
-struct TreeEl5 : public AvlTreeEl<TreeEl5>, public CmpOrd<int>
-{
- TreeEl5() { }
- TreeEl5(const int key) : key(key) { }
-
- int getKey() { return key; }
- int key;
-};
-
-/* Test element 6. */
-struct TreeEl6 : public AvlTreeEl<TreeEl6>, public CmpOrd<int>
-{
- TreeEl6() { }
- TreeEl6(const int key) : key(key) { }
-
- int getKey() { return key; }
- int key;
-};
-
-typedef AvlTree< TreeEl1, int > Tree1;
-typedef AvlTree< TreeEl2, int > Tree2;
-typedef AvlTree< TreeEl3, int > Tree3;
-typedef AvlTree< TreeEl4, int > Tree4;
-typedef AvlTree< TreeEl5, int > Tree5;
-typedef AvlTree< TreeEl6, int > Tree6;
-
-/* Instantiate the entire tree. */
-//template class TAvlTree< TreeEl1, int >;
-//template class TAvlTree< TreeEl2, int >;
-//template class TAvlTree< TreeEl3, int >;
-//template class TAvlTree< TreeEl4, int >;
-//template class TAvlTree< TreeEl5, int >;
-//template class TAvlTree< TreeEl6, int >;
-
-#endif
-
-void testTAvlTree1()
-{
- Tree1 tree;
- TreeEl1 element1(1), element2(2);
- tree.insert( &element1 );
- tree.insert( &element2 );
- Tree1::Iter it = tree.first();
- for ( ; it.lte(); it++ )
- cout << it->key << endl;
-}
-
-void testTAvlTree2()
-{
- Tree2 tree;
- TreeEl2 element1(1), element2(2);
- tree.insert( &element1 );
- tree.insert( &element2 );
- Tree2::Iter it = tree.first();
- for ( ; it.lte(); it++ )
- cout << it->key << endl;
-}
-
-void testTAvlTree3()
-{
- Tree3 tree;
- TreeEl3 element1(1), element2(2);
- tree.insert( &element1 );
- tree.insert( &element2 );
- Tree3::Iter it = tree.first();
- for ( ; it.lte(); it++ )
- cout << it->key << endl;
-}
-
-void testTAvlTree4()
-{
- Tree4 tree;
- TreeEl4 element1(1), element2(2);
- tree.insert( &element1 );
- tree.insert( &element2 );
- Tree4::Iter it = tree.first();
- for ( ; it.lte(); it++ )
- cout << it->key << endl;
-}
-
-void testTAvlTree5()
-{
- Tree5 tree;
- TreeEl5 element1(1), element2(2);
- tree.insert( &element1 );
- tree.insert( &element2 );
- Tree5::Iter it = tree.first();
- for ( ; it.lte(); it++ )
- cout << it->key << endl;
-}
-
-void testTAvlTree6()
-{
- Tree6 tree;
- TreeEl6 element1(1), element2(2);
- tree.insert( &element1 );
- tree.insert( &element2 );
- Tree6::Iter it = tree.first();
- for ( ; it.lte(); it++ )
- cout << it->key << endl;
-}
-
-int main()
-{
- testTAvlTree1();
- testTAvlTree2();
- testTAvlTree3();
- testTAvlTree4();
- testTAvlTree5();
- testTAvlTree6();
- return 0;
-}
diff --git a/test/test_tdlist.cpp b/test/test_tdlist.cpp
deleted file mode 100644
index cb421332..00000000
--- a/test/test_tdlist.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright 2003 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <iostream>
-#include "tdlist.h"
-#include "dlist.h"
-
-using namespace std;
-
-#define TD
-
-#ifdef TD
-struct ListEl1 : public TDListEl { int i; };
-struct ListEl2 : public TDListEl { int i; };
-struct ListEl3 : public TDListEl { int i; };
-struct ListEl4 : public TDListEl { int i; };
-struct ListEl5 : public TDListEl { int i; };
-struct ListEl6 : public TDListEl { int i; };
-typedef TDList<ListEl1> List1;
-typedef TDList<ListEl2> List2;
-typedef TDList<ListEl3> List3;
-typedef TDList<ListEl4> List4;
-typedef TDList<ListEl5> List5;
-typedef TDList<ListEl6> List6;
-#else
-struct ListEl1 : public DListEl<ListEl1> { int i; };
-struct ListEl2 : public DListEl<ListEl2> { int i; };
-struct ListEl3 : public DListEl<ListEl3> { int i; };
-struct ListEl4 : public DListEl<ListEl4> { int i; };
-struct ListEl5 : public DListEl<ListEl5> { int i; };
-struct ListEl6 : public DListEl<ListEl6> { int i; };
-typedef DList<ListEl1> List1;
-typedef DList<ListEl2> List2;
-typedef DList<ListEl3> List3;
-typedef DList<ListEl4> List4;
-typedef DList<ListEl5> List5;
-typedef DList<ListEl6> List6;
-#endif
-
-
-void testTDList1()
-{
- List1 list;
- ListEl1 lel;
- list.append( &lel );
- List1::Iter it = list.first();
- for ( ; it.lte(); it++ )
- cout << it->i << endl;
- List1 copy( list );
- copy.empty();
- cout << list.head << endl;
- cout << copy.head << endl;
-}
-
-void testTDList2()
-{
- List2 list;
- ListEl2 lel;
- list.append( &lel );
- List2::Iter it = list.first();
- for ( ; it.lte(); it++ )
- cout << it->i << endl;
- List2 copy( list );
- copy.empty();
- cout << list.head << endl;
- cout << copy.head << endl;
-}
-
-
-void testTDList3()
-{
- List3 list;
- ListEl3 lel;
- list.append( &lel );
- List3::Iter it = list.first();
- for ( ; it.lte(); it++ )
- cout << it->i << endl;
- List3 copy( list );
- copy.empty();
- cout << list.head << endl;
- cout << copy.head << endl;
-}
-
-
-void testTDList4()
-{
- List4 list;
- ListEl4 lel;
- list.append( &lel );
- List4::Iter it = list.first();
- for ( ; it.lte(); it++ )
- cout << it->i << endl;
- List4 copy( list );
- copy.empty();
- cout << list.head << endl;
- cout << copy.head << endl;
-}
-
-
-void testTDList5()
-{
- List5 list;
- ListEl5 lel;
- list.append( &lel );
- List5::Iter it = list.first();
- for ( ; it.lte(); it++ )
- cout << it->i << endl;
- List5 copy( list );
- copy.empty();
- cout << list.head << endl;
- cout << copy.head << endl;
-}
-
-void testTDList6()
-{
- List6 list;
- ListEl6 lel;
- list.append( &lel );
- List6::Iter it = list.first();
- for ( ; it.lte(); it++ )
- cout << it->i << endl;
- List6 copy( list );
- copy.empty();
- cout << list.head << endl;
- cout << copy.head << endl;
-}
-
-int main()
-{
- testTDList1();
- testTDList2();
- testTDList3();
- testTDList4();
- testTDList5();
- testTDList6();
- return 0;
-}
diff --git a/test/test_tdlistall.cpp b/test/test_tdlistall.cpp
deleted file mode 100644
index 9ccb3fd3..00000000
--- a/test/test_tdlistall.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2002 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <iostream>
-#include "tdlist.h"
-#include "tdlistmel.h"
-#include "tdlistval.h"
-#include "dlist.h"
-#include "dlistmel.h"
-#include "dlistval.h"
-
-using namespace std;
-
-/*
- * TDList
- */
-struct ListEl1 : public TDListEl { int i; };
-typedef TDList<ListEl1> List1;
-
-/*
- * TDListMel
- */
-struct ListEl2_A : public TDListEl { };
-struct ListEl2_B : public TDListEl { };
-struct ListEl2 : public ListEl2_A, public ListEl2_B { int i; };
-typedef TDListMel<ListEl2, ListEl2_A> List2;
-
-/*
- * TDListVal
- */
-typedef TDListVal<int> List3;
-
-
-/* Instantiate all lists. */
-template class TDListMel<ListEl2, ListEl2_A>;
-template class TDListVal<int>;
-template class TDList<ListEl1>;
-
-int main()
-{
- return 0;
-}
diff --git a/test/test_tdlistmel.cpp b/test/test_tdlistmel.cpp
deleted file mode 100644
index a435a393..00000000
--- a/test/test_tdlistmel.cpp
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright 2003 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <iostream>
-#include "tdlistmel.h"
-#include "dlistmel.h"
-
-using namespace std;
-
-#define TD
-
-#ifdef TD
-struct ListEl1_A : public TDListEl { };
-struct ListEl1_B : public TDListEl { };
-struct ListEl2_A : public TDListEl { };
-struct ListEl2_B : public TDListEl { };
-struct ListEl3_A : public TDListEl { };
-struct ListEl3_B : public TDListEl { };
-struct ListEl4_A : public TDListEl { };
-struct ListEl4_B : public TDListEl { };
-struct ListEl5_A : public TDListEl { };
-struct ListEl5_B : public TDListEl { };
-struct ListEl6_A : public TDListEl { };
-struct ListEl6_B : public TDListEl { };
-struct ListEl1 : public ListEl1_A, public ListEl1_B { int i; };
-struct ListEl2 : public ListEl2_A, public ListEl2_B { int i; };
-struct ListEl3 : public ListEl3_A, public ListEl3_B { int i; };
-struct ListEl4 : public ListEl4_A, public ListEl4_B { int i; };
-struct ListEl5 : public ListEl5_A, public ListEl5_B { int i; };
-struct ListEl6 : public ListEl6_A, public ListEl6_B { int i; };
-typedef TDListMel<ListEl1, ListEl1_A> List1;
-typedef TDListMel<ListEl2, ListEl2_A> List2;
-typedef TDListMel<ListEl3, ListEl3_A> List3;
-typedef TDListMel<ListEl4, ListEl4_A> List4;
-typedef TDListMel<ListEl5, ListEl5_A> List5;
-typedef TDListMel<ListEl6, ListEl6_A> List6;
-#else
-struct ListEl1;
-struct ListEl2;
-struct ListEl3;
-struct ListEl4;
-struct ListEl5;
-struct ListEl1_A : public DListEl<ListEl1> { };
-struct ListEl1_B : public DListEl<ListEl1> { };
-struct ListEl2_A : public DListEl<ListEl2> { };
-struct ListEl2_B : public DListEl<ListEl2> { };
-struct ListEl3_A : public DListEl<ListEl3> { };
-struct ListEl3_B : public DListEl<ListEl3> { };
-struct ListEl4_A : public DListEl<ListEl4> { };
-struct ListEl4_B : public DListEl<ListEl4> { };
-struct ListEl5_A : public DListEl<ListEl5> { };
-struct ListEl5_B : public DListEl<ListEl5> { };
-struct ListEl6_A : public DListEl<ListEl6> { };
-struct ListEl6_B : public DListEl<ListEl6> { };
-struct ListEl1 : public ListEl1_A, public ListEl1_B { int i; };
-struct ListEl2 : public ListEl2_A, public ListEl2_B { int i; };
-struct ListEl3 : public ListEl3_A, public ListEl3_B { int i; };
-struct ListEl4 : public ListEl4_A, public ListEl4_B { int i; };
-struct ListEl5 : public ListEl5_A, public ListEl5_B { int i; };
-struct ListEl6 : public ListEl6_A, public ListEl6_B { int i; };
-typedef DListMel<ListEl1, ListEl1_A> List1;
-typedef DListMel<ListEl2, ListEl2_A> List2;
-typedef DListMel<ListEl3, ListEl3_A> List3;
-typedef DListMel<ListEl4, ListEl4_A> List4;
-typedef DListMel<ListEl5, ListEl5_A> List5;
-typedef DListMel<ListEl6, ListEl6_A> List6;
-#endif
-
-
-void testTDList1()
-{
- List1 list;
- ListEl1 lel;
- list.append( &lel );
- List1::Iter it = list.first();
- for ( ; it.lte(); it++ )
- cout << it->i << endl;
- List1 copy( list );
- copy.empty();
- cout << list.head << endl;
- cout << copy.head << endl;
-}
-
-void testTDList2()
-{
- List2 list;
- ListEl2 lel;
- list.append( &lel );
- List2::Iter it = list.first();
- for ( ; it.lte(); it++ )
- cout << it->i << endl;
- List2 copy( list );
- copy.empty();
- cout << list.head << endl;
- cout << copy.head << endl;
-}
-
-
-void testTDList3()
-{
- List3 list;
- ListEl3 lel;
- list.append( &lel );
- List3::Iter it = list.first();
- for ( ; it.lte(); it++ )
- cout << it->i << endl;
- List3 copy( list );
- copy.empty();
- cout << list.head << endl;
- cout << copy.head << endl;
-}
-
-
-void testTDList4()
-{
- List4 list;
- ListEl4 lel;
- list.append( &lel );
- List4::Iter it = list.first();
- for ( ; it.lte(); it++ )
- cout << it->i << endl;
- List4 copy( list );
- copy.empty();
- cout << list.head << endl;
- cout << copy.head << endl;
-}
-
-
-void testTDList5()
-{
- List5 list;
- ListEl5 lel;
- list.append( &lel );
- List5::Iter it = list.first();
- for ( ; it.lte(); it++ )
- cout << it->i << endl;
- List5 copy( list );
- copy.empty();
- cout << list.head << endl;
- cout << copy.head << endl;
-}
-
-void testTDList6()
-{
- List6 list;
- ListEl6 lel;
- list.append( &lel );
- List6::Iter it = list.first();
- for ( ; it.lte(); it++ )
- cout << it->i << endl;
- List6 copy( list );
- copy.empty();
- cout << list.head << endl;
- cout << copy.head << endl;
-}
-
-int main()
-{
- testTDList1();
- testTDList2();
- testTDList3();
- testTDList4();
- testTDList5();
- return 0;
-}
diff --git a/test/test_tdlistval.cpp b/test/test_tdlistval.cpp
deleted file mode 100644
index efb27a63..00000000
--- a/test/test_tdlistval.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright 2003 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <iostream>
-#include "tdlist.h"
-#include "tdlistmel.h"
-#include "tdlistval.h"
-
-using namespace std;
-
-#define TD
-
-#ifdef TD
-typedef TDListVal<char> List1;
-typedef TDListVal<unsigned char> List2;
-typedef TDListVal<short> List3;
-typedef TDListVal<unsigned short> List4;
-typedef TDListVal<int> List5;
-typedef TDListVal<unsigned int> List6;
-#else
-typedef DListVal<char> List1;
-typedef DListVal<unsigned char> List2;
-typedef DListVal<short> List3;
-typedef DListVal<unsigned short> List4;
-typedef DListVal<int> List5;
-typedef DListVal<unsigned int> List6;
-#endif
-
-void testTDList1()
-{
- List1 list;
- list.append( 1 );
- List1::Iter it = list.first();
- for ( ; it.lte(); it++ )
- cout << *it << endl;
- List1 copy( list );
- copy.empty();
- cout << list.head << endl;
- cout << copy.head << endl;
-}
-
-void testTDList2()
-{
- List2 list;
- list.append( 1 );
- List2::Iter it = list.first();
- for ( ; it.lte(); it++ )
- cout << *it << endl;
- List2 copy( list );
- copy.empty();
- cout << list.head << endl;
- cout << copy.head << endl;
-}
-
-
-void testTDList3()
-{
- List3 list;
- list.append( 1 );
- List3::Iter it = list.first();
- for ( ; it.lte(); it++ )
- cout << *it << endl;
- List3 copy( list );
- copy.empty();
- cout << list.head << endl;
- cout << copy.head << endl;
-}
-
-
-void testTDList4()
-{
- List4 list;
- list.append( 1 );
- List4::Iter it = list.first();
- for ( ; it.lte(); it++ )
- cout << *it << endl;
- List4 copy( list );
- copy.empty();
- cout << list.head << endl;
- cout << copy.head << endl;
-}
-
-
-void testTDList5()
-{
- List5 list;
- list.append( 1 );
- List5::Iter it = list.first();
- for ( ; it.lte(); it++ )
- cout << *it << endl;
- List5 copy( list );
- copy.empty();
- cout << list.head << endl;
- cout << copy.head << endl;
-}
-
-void testTDList6()
-{
- List6 list;
- list.append( 1 );
- List6::Iter it = list.first();
- for ( ; it.lte(); it++ )
- cout << *it << endl;
- List6 copy( list );
- copy.empty();
- cout << list.head << endl;
- cout << copy.head << endl;
-}
-
-int main()
-{
- testTDList1();
- testTDList2();
- testTDList3();
- testTDList4();
- testTDList5();
- testTDList6();
- return 0;
-}
diff --git a/test/test_tsvectsimp.cpp b/test/test_tsvectsimp.cpp
deleted file mode 100644
index ce7dd6b2..00000000
--- a/test/test_tsvectsimp.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 2003 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <iostream>
-#include "tsvectsimp.h"
-#include "svectsimp.h"
-#include "svector.h"
-
-using namespace std;
-
-struct POD1 { POD1(int i, int j) : i(i),j(j) {} int i, j; };
-struct POD2 { POD2(int i, int j) : i(i),j(j) {} int i, j; };
-struct POD3 { POD3(int i, int j) : i(i),j(j) {} int i, j; };
-struct POD4 { POD4(int i, int j) : i(i),j(j) {} int i, j; };
-struct POD5 { POD5(int i, int j) : i(i),j(j) {} int i, j; };
-struct POD6 { POD6(int i, int j) : i(i),j(j) {} int i, j; };
-
-#define TINY_VECT
-
-#ifdef TINY_VECT
-typedef TSVectSimp<POD1> Vect1;
-typedef TSVectSimp<POD2> Vect2;
-typedef TSVectSimp<POD3> Vect3;
-typedef TSVectSimp<POD4> Vect4;
-typedef TSVectSimp<POD5> Vect5;
-typedef TSVectSimp<POD6> Vect6;
-#else
-typedef SVectSimp<POD1> Vect1;
-typedef SVectSimp<POD2> Vect2;
-typedef SVectSimp<POD3> Vect3;
-typedef SVectSimp<POD4> Vect4;
-typedef SVectSimp<POD5> Vect5;
-typedef SVectSimp<POD6> Vect6;
-#endif
-
-//template TSVectSimp<POD1>;
-//template TSVectSimp<POD2>;
-//template TSVectSimp<POD3>;
-//template TSVectSimp<POD4>;
-//template TSVectSimp<POD5>;
-//template TSVectSimp<POD6>;
-
-void testTSVectSimp1()
-{
- POD1 pod(1,2);
- Vect1 b;
- for (int i = 0; i < 1000000; i++ )
- b.append(pod);
- for ( Vect1::Iter i = b.first(); i.lte(); i++ )
- i->i = i->j + 1;
-}
-
-void testTSVectSimp2()
-{
- POD2 pod(3,4);
- Vect2 b;
- for (int i = 0; i < 1000000; i++ )
- b.append(pod);
- for ( Vect2::Iter i = b.first(); i.lte(); i++ )
- i->i = i->j + 1;
-}
-
-void testTSVectSimp3()
-{
- POD3 pod(5,6);
- Vect3 b;
- for (int i = 0; i < 1000000; i++ )
- b.append(pod);
- for ( Vect3::Iter i = b.first(); i.lte(); i++ )
- i->i = i->j + 1;
-}
-
-void testTSVectSimp4()
-{
- POD4 pod(7,8);
- Vect4 b;
- for (int i = 0; i < 1000000; i++ )
- b.append(pod);
- for ( Vect4::Iter i = b.first(); i.lte(); i++ )
- i->i = i->j + 1;
-}
-
-void testTSVectSimp5()
-{
- POD5 pod(9,10);
- Vect5 b;
- for (int i = 0; i < 1000000; i++ )
- b.append(pod);
- for ( Vect5::Iter i = b.first(); i.lte(); i++ )
- i->i = i->j + 1;
-}
-
-void testTSVectSimp6()
-{
- POD6 pod(11,12);
- Vect6 b;
- for (int i = 0; i < 1000000; i++ )
- b.append(pod);
- for ( Vect6::Iter i = b.first(); i.lte(); i++ )
- i->i = i->j + 1;
-}
-
-int main()
-{
- testTSVectSimp1();
- testTSVectSimp2();
- testTSVectSimp3();
- testTSVectSimp4();
- testTSVectSimp5();
- testTSVectSimp6();
- return 0;
-}
diff --git a/test/test_tvectsimp.cpp b/test/test_tvectsimp.cpp
deleted file mode 100644
index 61deeb8f..00000000
--- a/test/test_tvectsimp.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright 2003 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <iostream>
-#include "tvectsimp.h"
-#include "vectsimp.h"
-#include "vector.h"
-
-using namespace std;
-
-struct POD1 { POD1(int i, int j) : i(i),j(j) {} int i, j; };
-struct POD2 { POD2(int i, int j) : i(i),j(j) {} int i, j; };
-struct POD3 { POD3(int i, int j) : i(i),j(j) {} int i, j; };
-struct POD4 { POD4(int i, int j) : i(i),j(j) {} int i, j; };
-struct POD5 { POD5(int i, int j) : i(i),j(j) {} int i, j; };
-struct POD6 { POD6(int i, int j) : i(i),j(j) {} int i, j; };
-
-#define TINY_VECT
-
-#ifdef TINY_VECT
-typedef TVectSimp<POD1> Vect1;
-typedef TVectSimp<POD2> Vect2;
-typedef TVectSimp<POD3> Vect3;
-typedef TVectSimp<POD4> Vect4;
-typedef TVectSimp<POD5> Vect5;
-typedef TVectSimp<POD6> Vect6;
-#else
-typedef VectSimp<POD1> Vect1;
-typedef VectSimp<POD2> Vect2;
-typedef VectSimp<POD3> Vect3;
-typedef VectSimp<POD4> Vect4;
-typedef VectSimp<POD5> Vect5;
-typedef VectSimp<POD6> Vect6;
-#endif
-
-void testTVectSimp1()
-{
- POD1 pod(1,2);
- Vect1 b;
- for (int i = 0; i < 1000000; i++ ) {
- pod.i = 1;
- b.append(pod);
- }
-}
-
-void testTVectSimp2()
-{
- POD2 pod(3,4);
- Vect2 b;
- for (int i = 0; i < 1000000; i++ ) {
- pod.i = 1;
- b.append(pod);
- }
-}
-
-void testTVectSimp3()
-{
- POD3 pod(5,6);
- Vect3 b;
- for (int i = 0; i < 1000000; i++ ) {
- pod.i = 1;
- b.append(pod);
- }
-}
-
-void testTVectSimp4()
-{
- POD4 pod(7,8);
- Vect4 b;
- for (int i = 0; i < 1000000; i++ ) {
- pod.i = 1;
- b.append(pod);
- }
-}
-
-void testTVectSimp5()
-{
- POD5 pod(9,10);
- Vect5 b;
- for (int i = 0; i < 1000000; i++ ) {
- pod.i = 1;
- b.append(pod);
- }
-}
-
-void testTVectSimp6()
-{
- POD6 pod(11,12);
- Vect6 b;
- for (int i = 0; i < 1000000; i++ ) {
- pod.i = 1;
- b.append(pod);
- }
-}
-
-int main()
-{
- testTVectSimp1();
- testTVectSimp2();
- testTVectSimp3();
- testTVectSimp4();
- testTVectSimp5();
- testTVectSimp6();
- return 0;
-}
diff --git a/test/test_vector.cpp b/test/test_vector.cpp
deleted file mode 100644
index 638538de..00000000
--- a/test/test_vector.cpp
+++ /dev/null
@@ -1,474 +0,0 @@
-/*
- * Copyright 2001 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <stdio.h>
-#include <iostream>
-#include <assert.h>
-
-#include "resize.h"
-#include "vector.h"
-
-using namespace std;
-
-template class Vector< int, ResizeExpn >;
-template class Vector< int, ResizeLin >;
-template class Vector< int, ResizeConst >;
-template class Vector< int, ResizeRunTime >;
-template class Vector< int, ResizeCtLin<0> >;
-
-void testVector1()
-{
- int pos, len;
- char c, string[200];
- Vector<char, ResizeLin> v;
-
- while( scanf("%c", &c) == 1 )
- {
- switch (c) {
- case 'a':
- /* Get the string to append. */
- fgets(string, 200, stdin);
-
- /* hack off the newline. */
- len = strlen(string) - 1;
- string[len] = 0;
-
- v.append(string, len);
- break;
-
- case 'p':
- /* Get the string to prepend. */
- fgets(string, 200, stdin);
-
- /* hack off the newline. */
- len = strlen(string) - 1;
- string[len] = 0;
-
- v.prepend(string, len);
- break;
-
- case 's':
- /* Get the string to set. */
- fgets(string, 200, stdin);
-
- /* hack off the newline. */
- len = strlen(string) - 1;
- string[len] = 0;
-
- v.setAs(string, len);
- break;
-
- case 'r':
- /* Get the pos */
- scanf("%i ", &pos);
-
- /* Get the string to replace. */
- fgets(string, 200, stdin);
-
- /* hack off the newline. */
- len = strlen(string) - 1;
- string[len] = 0;
-
- v.replace(pos, string, len);
- break;
-
- case 'i':
- /* Get the pos */
- scanf("%i ", &pos);
-
- /* Get the string to insert. */
- fgets(string, 200, stdin);
-
- /* hack off the newline. */
- len = strlen(string) - 1;
- string[len] = 0;
-
- v.insert(pos, string, len);
- break;
-
- case 'd':
- /* Get the length to remove. */
- scanf("%i", &pos);
- scanf("%i", &len);
- v.remove(pos, len);
- break;
-
- case 'w':
- printf("L: %li AL: %li\n", v.tabLen, v.allocLen);
- fwrite(v.data, 1, v.tabLen, stdout);
- fputc('\n', stdout);
- break;
-
- case 'q':
- goto end;
-
- }
- }
-
-end:
- fwrite(v.data, 1, v.tabLen, stdout);
- fputc('\n', stdout);
-}
-
-
-/* Globals that the constructors and destructor count with. */
-int defaultCount = 0;
-int copyCount = 0;
-int destructorCount = 0;
-
-/* Reset the globals for the next test. */
-void reset()
-{
- defaultCount = 0;
- copyCount = 0;
- destructorCount = 0;
-}
-
-/* An assert that resets the globals and does an assert. */
-#define assert_reset(test) assert(test); reset();
-
-/* Data structure whos constructors and destructor count callings. */
-struct theData
-{
- theData() : i(0) { defaultCount++; }
- theData(const theData &d) : i(1) { copyCount++; }
- ~theData() { destructorCount++; }
- int i;
-};
-
-void testDelete()
-{
- /* Initialization. */
- Vector< theData, ResizeLin > v1;
- v1.setAsNew(10);
- assert_reset( defaultCount == 10 );
-
- /* Delete some. */
- v1.remove( 5, 3 );
- assert_reset( destructorCount == 3 );
-
- /* Delete some more. */
- v1.remove( 0, 4 );
- assert_reset( destructorCount == 4 );
-
- /* Test tabLen. */
- assert_reset( v1.tabLen == 3 );
-}
-
-void testInsert()
-{
- /* Simple Construct calls. */
- theData sampleData[10];
- assert_reset( defaultCount == 10 );
-
- /* Initialization. */
- Vector< theData, ResizeLin > v1;
- v1.setAsNew(6);
- assert_reset( defaultCount == 6 );
-
- /* Copy Constructor. */
- Vector< theData, ResizeLin > v2(v1);
- assert_reset( copyCount == 6 );
-
- /* Insert, some shifted over. */
- v1.insert(1, sampleData, 4);
- assert_reset( v1.tabLen == 10 && destructorCount == 0 && copyCount == 4 );
-
- /* Insert, none shifted over. */
- v1.insert(10, sampleData, 4);
- assert_reset( defaultCount == 0 && copyCount == 4 );
-
- /* Insert some new items. */
- v1.insertNew(0, 10);
- assert_reset( v1.tabLen == 24 && defaultCount == 10 && copyCount == 0 );
-
- /* Insert some duplicates. */
- v1.insertDup(-1, theData(), 6);
- assert_reset( v1.tabLen == 30 && defaultCount == 1 && copyCount == 6 );
-}
-
-void testSetAs()
-{
- /* Simple Construct calls. */
- theData sampleData[10];
- assert_reset( defaultCount == 10 );
-
- /* Initialization. */
- Vector< theData, ResizeLin > v1;
- v1.setAsNew(6);
- assert_reset( defaultCount == 6 );
-
- v1.setAs( sampleData, 10 );
- assert_reset( destructorCount == 6 && copyCount == 10 && defaultCount == 0 );
-}
-
-
-void testReplace()
-{
- /* Simple Construct calls. */
- theData sampleData[10];
- assert_reset( defaultCount == 10 );
-
- /* Initialization. */
- Vector< theData, ResizeLin > v1;
- v1.setAsNew(4);
- assert_reset( defaultCount == 4 );
-
- /* Copy Constructor. */
- Vector< theData, ResizeLin > v2(v1);
- assert_reset( copyCount == 4 );
-
- /* Replace, some remove, some new. */
- v1.replace(1, sampleData, 4);
- assert_reset( destructorCount == 3 && copyCount == 4 );
-
- /* Replace, all remove. */
- v1.replace(0, sampleData, 5);
- assert_reset( destructorCount == 5 && copyCount == 5 );
-
- /* Replace, all new. */
- v1.replace(5, sampleData, 2);
- assert_reset( destructorCount == 0 && copyCount == 2 );
-
- /* Overwrite without going to the end. */
- v1.replace(0, sampleData, 1);
- assert_reset( destructorCount == 1 && defaultCount == 0 && copyCount == 1 );
-
- /* Ensure tabLen is good. */
- assert_reset( v1.tabLen == 7 );
-}
-
-
-void testWithValues()
-{
- Vector< int, ResizeLin > v1;
- Vector< int, ResizeLin > v2;
-
- int i = 1;
- v1.append( i );
- v2.setAs(v1);
- i = 2;
- v1.insert( 0, i );
- assert_reset( v1.data[0] == 2 && v2.data[0] == 1 );
-
-}
-
-void testOperators1()
-{
- Vector<int, ResizeLin> v;
- v.append( 10 );
- v.append( 11 );
-
- cout << v.size() << endl;
- cout << v.data[0] << endl;
- cout << v[1] << endl;
-
- Vector<int, ResizeLin>::Iter it;
- for ( it = v; it.lte(); it++)
- cout << *it << endl;
-
- it = v.last();
- for ( it = v; it.gtb(); it-- )
- cout << *it << endl;
-}
-
-void testOperators2()
-{
- Vector< Vector<int> > vvi;
- vvi.setAsNew(1);
- Vector< Vector<int> >::Iter it;
- for ( it = vvi; it.lte(); it++ )
- cout << it->size() << endl;
-}
-
-void testCopying()
-{
- Vector<int> v1;
- v1.append(1);
- v1.append(2);
- v1.append(3);
-
- Vector<int> v2;
- v2.append(4);
- v2 = v1;
- cout << v2.size() << endl;
-}
-
-void testBounds()
-{
- Vector<int, ResizeLin> v;
- v.setAsNew(1);
- v.setAsNew(0);
- return;
-}
-
-typedef Vector<int> Vect;
-
-void testIterator()
-{
- Vect vect;
-
- cout << "Iterator Default Constructor" << endl;
-
- /* Default constructed iterator. */
- Vect::Iter defIt;
- cout << defIt.lte() << " " << defIt.end() << " " << defIt.gtb() << " " <<
- defIt.beg() << " " << defIt.first() << " " << defIt.last() << endl;
-
- cout << "Zero Items" << endl;
-
- /* Iterator constructed from empty vect. */
- Vect::Iter i1(vect);
- cout << i1.lte() << " " << i1.end() << " " << i1.gtb() << " " <<
- i1.beg() << " " << i1.first() << " " << i1.last() << endl;
- Vect::Iter i2(vect.first());
- cout << i2.lte() << " " << i2.end() << " " << i2.gtb() << " " <<
- i2.beg() << " " << i2.first() << " " << i2.last() << endl;
- Vect::Iter i3(vect.last());
- cout << i3.lte() << " " << i3.end() << " " << i3.gtb() << " " <<
- i3.beg() << " " << i3.first() << " " << i3.last() << endl;
-
- /* Iterator assigned from an empty vect. */
- i1 = vect;
- cout << i1.lte() << " " << i1.end() << " " << i1.gtb() << " " <<
- i1.beg() << " " << i1.first() << " " << i1.last() << endl;
- i2 = vect.first();
- cout << i2.lte() << " " << i2.end() << " " << i2.gtb() << " " <<
- i2.beg() << " " << i2.first() << " " << i2.last() << endl;
- i3 = vect.last();
- cout << i3.lte() << " " << i3.end() << " " << i3.gtb() << " " <<
- i3.beg() << " " << i3.first() << " " << i3.last() << endl;
-
- cout << "One Item" << endl;
- vect.append( 1 );
-
- /* Iterator constructed from an a vect with one item. */
- Vect::Iter i4(vect);
- cout << i4.lte() << " " << i4.end() << " " << i4.gtb() << " " <<
- i4.beg() << " " << i4.first() << " " << i4.last() << endl;
- Vect::Iter i5(vect.first());
- cout << i5.lte() << " " << i5.end() << " " << i5.gtb() << " " <<
- i5.beg() << " " << i5.first() << " " << i5.last() << endl;
- Vect::Iter i6(vect.last());
- cout << i6.lte() << " " << i6.end() << " " << i6.gtb() << " " <<
- i6.beg() << " " << i6.first() << " " << i6.last() << endl;
-
- /* Iterator assigned from an a vect with one item. */
- i4 = vect;
- cout << i4.lte() << " " << i4.end() << " " << i4.gtb() << " " <<
- i4.beg() << " " << i4.first() << " " << i4.last() << endl;
- i5 = vect.first();
- cout << i5.lte() << " " << i5.end() << " " << i5.gtb() << " " <<
- i5.beg() << " " << i5.first() << " " << i5.last() << endl;
- i6 = vect.last();
- cout << i6.lte() << " " << i6.end() << " " << i6.gtb() << " " <<
- i6.beg() << " " << i6.first() << " " << i6.last() << endl;
-
- cout << "Two Items" << endl;
- vect.append( 2 );
-
- /* Iterator constructed from an a vect with two items. */
- Vect::Iter i7(vect);
- cout << i7.lte() << " " << i7.end() << " " << i7.gtb() << " " <<
- i7.beg() << " " << i7.first() << " " << i7.last() << endl;
- Vect::Iter i8(vect.first());
- cout << i8.lte() << " " << i8.end() << " " << i8.gtb() << " " <<
- i8.beg() << " " << i8.first() << " " << i8.last() << endl;
- Vect::Iter i9(vect.last());
- cout << i9.lte() << " " << i9.end() << " " << i9.gtb() << " " <<
- i9.beg() << " " << i9.first() << " " << i9.last() << endl;
-
- /* Iterator assigned from an a vect with two items. */
- i7 = vect;
- cout << i7.lte() << " " << i7.end() << " " << i7.gtb() << " " <<
- i7.beg() << " " << i7.first() << " " << i7.last() << endl;
- i8 = vect.first();
- cout << i8.lte() << " " << i8.end() << " " << i8.gtb() << " " <<
- i8.beg() << " " << i8.first() << " " << i8.last() << endl;
- i9 = vect.last();
- cout << i9.lte() << " " << i9.end() << " " << i9.gtb() << " " <<
- i9.beg() << " " << i9.first() << " " << i9.last() << endl;
-
- vect.empty();
- vect.append( 1 );
- vect.append( 2 );
- vect.append( 3 );
- vect.append( 4 );
-
- cout << "test1" << endl;
- Vect::Iter it1 = vect;
- for ( ; it1.lte(); it1++ )
- cout << *it1 << endl;
-
- cout << "test2" << endl;
- Vect::Iter it2 = vect.first();
- for ( ; it2.lte(); it2++ )
- cout << *it2 << endl;
-
- cout << "test3" << endl;
- Vect::Iter it3 = vect.last();
- for ( ; it3.gtb(); it3-- )
- cout << *it3 << endl;
-
- cout << "test4" << endl;
- it1 = vect;
- for ( ; !it1.end(); it1++ )
- cout << *it1 << endl;
-
- cout << "test5" << endl;
- it2 = vect.first();
- for ( ; !it2.end(); it2++ )
- cout << *it2 << endl;
-
- cout << "test6" << endl;
- it3 = vect.last();
- for ( ; !it3.beg(); it3-- )
- cout << *it3 << endl;
-}
-
-void testConstructor()
-{
- reset();
- theData someData;
- Vector<theData> v1( someData );
- v1.append( theData() );
- Vector<theData> v2( v1.data, v1.length() );
-
- cout << "testConstructor" << endl;
- assert( destructorCount == 1 && defaultCount == 2 && copyCount == 4 );
-}
-
-int main()
-{
- testReplace();
- testInsert();
- testSetAs();
- testDelete();
- testWithValues();
- testOperators1();
- testOperators2();
- testCopying();
- testBounds();
- testIterator();
- testConstructor();
- return 0;
-}
diff --git a/test/test_vectsimp.cpp b/test/test_vectsimp.cpp
deleted file mode 100644
index 3f80a562..00000000
--- a/test/test_vectsimp.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2002 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <iostream>
-#include "vectsimp.h"
-#include "vector.h"
-
-using namespace std;
-
-template class VectSimp<char>;
-
-void testVectSimp1()
-{
- VectSimp< char > buffer;
- while ( ! cin.eof() ) {
- char c;
- cin >> c;
- buffer.append(c);
- }
-}
-
-void testVectSimp2()
-{
- VectSimp<char> b;
- for (int i = 0; i < 1000000; i++ )
- b.append("age writes code ", 12);
-}
-
-int main()
-{
- testVectSimp2();
- return 0;
-}
diff --git a/test/util.cpp b/test/util.cpp
deleted file mode 100644
index 47afa3ff..00000000
--- a/test/util.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2002 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <iostream>
-#include <string.h>
-#include <signal.h>
-#include <unistd.h>
-#include <stdlib.h>
-#define TAB_WIDTH 10
-
-using namespace std;
-
-void handleAlarm( int )
-{
- cout << endl;
- exit(0);
-}
-
-void processArgs( int argc, char** argv )
-{
- if ( argc > 1 ) {
- int secs = atoi( argv[1] );
- if ( secs > 0 ) {
- signal( SIGALRM, &handleAlarm );
- alarm( secs );
- }
- }
-}
-
-/* Expand the tabs in a buffer a buffer. */
-void expandTab( char *dst, const char *src )
-{
- char *pd = dst;
- for ( ; *src != 0; src++ ) {
- if ( *src != '\t' )
- *pd++ = *src;
- else {
- int n = TAB_WIDTH - ((pd - dst)%TAB_WIDTH);
- memset( pd, ' ', n );
- pd += n;
- }
- }
- *pd = 0;
-}
-
-
diff --git a/test/util.h b/test/util.h
deleted file mode 100644
index 3d272d93..00000000
--- a/test/util.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef __UTIL_H
-#define __UTIL_H
-
-void handleAlarm( int );
-void processArgs( int argc, char** argv );
-void expandTab( char *dst, const char *src );
-
-#endif
-