head	1.1;
access;
symbols
	r2_1:1.1
	r2_0:1.1
	r1_1_beta:1.1
	r0_11:1.1;
locks; strict;
comment	@ * @;


1.1
date	94.04.27.18.26.09;	author rjj;	state Exp;
branches;
next	;


desc
@Finally got this to work.
@


1.1
log
@Initial revision
@
text
@// -*- C++ -*-
//      Copyright 1993, Center for Computer Vision and Visualization,
//      University of Florida.  All rights reserved.

#include "Stack.h"

static char tests_Stack_c_rcsid[] = "$Id$";

// $Log$

#define silen(k) \
    cout << "\nsi" << k << ".length() = " << si##k.length()

#define hd(dstr,d) cout << "\n" << dstr << ".top() = " << d.top()

    int sint;
#define prtd(dstr, d) \
    cout << "\n" << dstr << "\t<"; \
    for (sint=0; sint < d.length();  sint++ ) \
	{ cout << d[sint] << " "; }; \
    cout << ">";
					

main() {
    IA::exit_on_throw = 0;

    cout << "Allocating si, si0 .. si4\n";
    
    IA_Stack<int> si,
	si0(0),
	si1(0,1),
	si2(0,1,2),
	si3(0,1,2,3),
	si4(0,1,2,3,4);

    int lvec[10];
    for (int i=0; i<10; i++) {
	lvec[i] = i*i + i;
    }
    IA_Stack<int> longL(lvec, 10);


//#define ITERATORS
#ifdef  ITERATORS
    int value;
    cout << "\nEntering while loop for si";
    while ( siter(value) ) {
	cout << "\n\tsiter returned: " << value;
    }
    cout << "\nEntering while loop for si0";
    while ( siter0(value) ) {
	cout << "\n\tsiter0 returned: " << value;
    }
    cout << "\nEntering while loop for si1";
    while ( siter1(value) ) {
	cout << "\n\tsiter1 returned: " << value;
    }
    cout << "\nEntering while loop for si2";
    while ( siter2(value) ) {
	cout << "\n\tsiter2 returned: " << value;
    }
    cout << "\nEntering while loop for si3";
    while ( siter3(value) ) {
	cout << "\n\tsiter3 returned: " << value;
    }
    cout << "\nEntering while loop for si4";
    while ( siter4(value) ) {
	cout << "\n\tsiter4 returned: " << value;
    }
#undef ITERATORS
#endif


#define OPERATORS
#ifdef  OPERATORS

    hd("si0", si0);
    hd("si1", si1);

    prtd("si3",si3);
    prtd("longL",longL);

    IA_Stack<int> tailL=longL;
    while( !tailL.empty() ) {
	prtd("tailL",tailL);
	tailL.pop(i);
    }
    prtd("tailL",tailL);
    cout << endl;

    IA_Stack<int> plus2thru7, plus3thru2, outOfBounds;

    prtd("plus2thru7",plus2thru7);
    for( int i27=2; i27<=7; i27++ ) {
	plus2thru7.push(i27);
	prtd("plus2thru7",plus2thru7);
    }
    cout << endl;

    prtd("si3",si3);
    cout << endl << "si3(1) = " << si3(1) << endl;
    si3[1] = si3(1) + 15;
    cout << "si3[1] = si3(1) + 15 = " << si3(1) << endl;

#undef  OPERATORS
#endif

//#define FUNCTIONS
#ifdef  FUNCTIONS
#undef  FUNCTIONS
#endif

    cout << "\n";
}

@
