head	1.17;
access
	monica
	thoth
	fjsoria;
symbols
	Eglin_alpha_1:1.11;
locks
	monica:1.17; strict;
comment	@// @;


1.17
date	94.11.21.20.17.28;	author thoth;	state Exp;
branches;
next	1.16;

1.16
date	94.10.18.18.32.49;	author monica;	state Exp;
branches;
next	1.15;

1.15
date	94.10.06.01.20.06;	author monica;	state Exp;
branches;
next	1.14;

1.14
date	94.08.21.15.20.36;	author monica;	state Exp;
branches;
next	1.13;

1.13
date	94.03.04.19.49.33;	author thoth;	state Exp;
branches;
next	1.12;

1.12
date	93.07.15.11.46.49;	author thoth;	state Exp;
branches;
next	1.11;

1.11
date	92.12.07.12.08.22;	author thoth;	state Exp;
branches;
next	1.10;

1.10
date	92.11.11.12.12.23;	author thoth;	state Exp;
branches;
next	1.9;

1.9
date	92.11.04.12.02.45;	author thoth;	state Exp;
branches;
next	1.8;

1.8
date	92.10.25.20.58.13;	author thoth;	state Exp;
branches;
next	1.7;

1.7
date	92.10.21.15.01.17;	author thoth;	state Exp;
branches;
next	1.6;

1.6
date	92.09.30.10.43.11;	author thoth;	state Exp;
branches;
next	1.5;

1.5
date	92.09.20.17.41.51;	author thoth;	state Exp;
branches;
next	1.4;

1.4
date	92.09.20.14.06.03;	author thoth;	state Exp;
branches;
next	1.3;

1.3
date	92.09.07.13.25.10;	author thoth;	state Exp;
branches;
next	1.2;

1.2
date	92.08.25.15.34.46;	author thoth;	state Exp;
branches;
next	1.1;

1.1
date	92.08.23.13.30.26;	author thoth;	state Exp;
branches;
next	;


desc
@CFrontified version
@


1.17
log
@Added tests for reflection through origin (operator-() )
@
text
@// Emacs: -*- C++ -*-
static char rcsid[] = "$Id: gen-test.c,v 1.16 1994/10/18 18:32:49 monica Exp thoth $";

// 
// $Log: gen-test.c,v $
// Revision 1.16  1994/10/18  18:32:49  monica
// added parens on line 543
//
// Revision 1.15  1994/10/06  01:20:06  monica
// fixed for DOS filename convention
//
// Revision 1.14  1994/08/21  15:20:36  monica
// updated for file name shortening (DblPoint, etc)
//
// Revision 1.13  1994/03/04  19:49:33  thoth
// a test for the FloatPointSets.
//
// Revision 1.12  93/07/15  11:46:49  thoth
// IA_ prefix for most classes now necessary.
// 
// Revision 1.11  92/12/07  12:08:22  thoth
// test for new IntPoint index(unsigned) method.
// 
// Revision 1.10  92/11/11  12:12:23  thoth
// test of another restriction utility.
// 
// Revision 1.9  92/11/04  12:02:45  thoth
// test of new image extension support routines.
// 
// Revision 1.8  92/10/25  20:58:13  thoth
// changed argument passing on set restriction routines.
// made recursion termination constants have sensible names.
// 
// Revision 1.7  92/10/21  15:01:17  thoth
// added test for image restriction utility.
// 
// Revision 1.6  92/09/30  10:43:11  thoth
// infimum & supremum virtuals now inf & sup.
// 
// Revision 1.5  92/09/20  17:41:51  thoth
// fixed spelling error.
// altered lattice tests to catch more errors.
// added minkowski test.
// 
// Revision 1.4  92/09/20  14:06:03  thoth
// tests added for the new infimum and supremum methods
// 
// Revision 1.3  92/09/07  13:25:10  thoth
// new test for the IntPoint array constructor
// 
// Revision 1.2  92/08/25  15:34:46  thoth
// generic tests now check lattice properties of set operations
// new test for translation verification
// 
// Revision 1.1  92/08/23  13:30:26  thoth
// Initial revision
// 
//

#include "IntPoint.h"
#include "IntPS.h"
#include "PSIter.h"
#include "DblPoint.h"
#include "DblPS.h"
#include "Set.h"

#include "gen-test.h"

void test_union(IA_Set<IA_Point<int> > a, IA_Set<IA_Point<int> > b, IA_Set<IA_Point<int> > ab)
{
    IA_Point<int>	p;
    
    IA_PSIter<IA_Point<int> >	iter;
    
    iter = a;
    
    while (iter(p)) {
	if (!ab.contains(p)) {
	    cout << p;
	    cout << "##missing##\n";
	}
    }
    
    iter = b;
    
    while (iter(p)) {
	if (!ab.contains(p)) {
	    cout << p;
	    cout << "##missing##\n";
	}
    }
    
    iter = ab;
    
    while (iter(p)) {
	if (! (a.contains(p) || b.contains(p))) {
	    cout << p;
	    cout << "##extra##\n";
	}
    }

    if (! (a<=ab))
	cout << "## ! a <= a|b ##\n";
    if (! (b<=ab))
	cout << "## ! b <= a|b ##\n";

    cout << "union test complete\n";
}

void test_intersection(IA_Set<IA_Point<int> > a, IA_Set<IA_Point<int> > b, IA_Set<IA_Point<int> > ab)
{
    IA_Point<int>	p;
    
    IA_PSIter<IA_Point<int> >	iter;
    
    iter = a;
    
    while (iter(p)) {
	if (b.contains(p) != ab.contains(p)) {
	    cout << p;
	    cout << "##a error##\n";
	}
    }
    
    iter = b;
    
    while (iter(p)) {
	if (a.contains(p) != ab.contains(p)) {
	    cout << p;
	    cout << "##b error##\n";
	}
    }
    
    iter = ab;
    
    while (iter(p)) {
	if (! (a.contains(p) && b.contains(p))) {
	    cout << p;
	    cout << "##ab extra##\n";
	}
    }

    if (! (a>=ab))
	cout << "## ! a >= a&b ##\n";
    if (! (b>=ab))
	cout << "## ! b >= a&b ##\n";
    cout << "intersection test complete\n";
}

void test_XOR(IA_Set<IA_Point<int> > a, IA_Set<IA_Point<int> > b, IA_Set<IA_Point<int> > ab)
{
    IA_Point<int>	p;
    
    IA_PSIter<IA_Point<int> >	iter;
    
    iter = a;
    
    while (iter(p)) {
	if (b.contains(p) && ab.contains(p)) {
	    cout << p;
	    cout << "##a extra error##\n";
	} else if (!b.contains(p) && !ab.contains(p)) {
	    cout << p;
	    cout << "##a missing error##\n";
	}
    }
    
    iter = b;
    
    while (iter(p)) {
	if (a.contains(p) && ab.contains(p)) {
	    cout << p;
	    cout << "##b extra error##\n";
	} else if (!a.contains(p) && !ab.contains(p)) {
	    cout << p;
	    cout << "##b missing error##\n";
	}
    }
    
    iter = ab;
    
    while (iter(p)) {
	if (a.contains(p) == b.contains(p)) {
	    cout << p;
	    cout << "##ab extra##\n";
	}
    }
    
    if ( ((a/b) | (b/a)) != ab ) {
	cout << "(a/b) | (b/a) != a^b\n";
    }
    
    cout << "symmetric difference test complete\n";
}

void test_minus(IA_Set<IA_Point<int> > a, IA_Set<IA_Point<int> > b, IA_Set<IA_Point<int> > ab)
{
    IA_Point<int>	p;
    
    IA_PSIter<IA_Point<int> >	iter;
    
    iter = a;
    
    while (iter(p)) {
	if (b.contains(p) && ab.contains(p)) {
	    cout << p << "##extra [a] error##\n";
	} else if ( ! b.contains(p) && ! ab.contains(p) ) {
	    cout << p << "##missing [a] error##\n";
	}
    }
    
    iter = b;
    
    while (iter(p)) {
	if (ab.contains(p)) {
	    cout << p;
	    cout << "##b error##\n";
	}
    }
    
    iter = ab;
    
    while (iter(p)) {
	if (!a.contains(p) || b.contains(p)) {
	    cout << p;
	    cout << "##ab extra##\n";
	}
    }

    if (! (a>=ab))
	cout << "## ! a >= a/b ##\n";

    cout << "difference test complete\n";
}

//
//
//


static void scan_restricted_ss(IA_PSIter<IA_Point<int> > *iter, 
		    const IA_SetStructure &ss,
		    IA_Set<IA_Point<int> > source, IA_Set<IA_Point<int> > trimmed)
{
    unsigned	i,j;
    IA_Point<int>	p;
    // cerr << "( ";
    for (i=0; i<ss.nintervals(); i++) {
	IA_ss_interval	temp(ss.retrieve_interval(i));
	// cerr << temp.count << " ";
	if (temp.substructure==IA_SetStructure::FIRST_ONLY) {
	    // cerr << "_";
	    for (j=0; j<temp.count; j++) {
		if (!(*iter)(p)) {
		    cout << "substructure too large\n";
		    return;
		}
		if (trimmed.contains(p)) {
		    cout << "restricted pointset contains skipped point ";
		    cout << p << "\n";
		}
	    }
	} else if (temp.substructure==IA_SetStructure::BOTH) {
	    //cerr << "*";
	    for (j=0; j<temp.count; j++) {
		if (!(*iter)(p)) {
		    cout << "substructure too large\n";
		    return;
		}
		if (!trimmed.contains(p)) {
		    cout << "restricted pointset missing point ";
		    cout << p << "\n";
		}
	    }
	} else {
	    for (j=0; j<temp.count; j++) {
		scan_restricted_ss(iter, temp.substructure, source, trimmed);
	    }
	}
	//cerr << "; ";
    }
    //cerr << " ) ";
}

void test_restriction(IA_Set<IA_Point<int> > a, IA_Set<IA_Point<int> > b)
{
    IA_Set<IA_Point<int> >	ab(a&b);

    IA_SetStructure	ss;
    IA_Set<IA_Point<int> > ab2(intersect_with_structure(a,b,&ss));

    if (ab!=ab2) {
	cout << "restriction intersection inaccurate\n";
	return;
    }

    IA_PSIter<IA_Point<int> >	iter(a);

    scan_restricted_ss(&iter, ss, a, ab);
    IA_Point<int>	p;
    if (iter(p)) {
	cout << "restriction structure too small\n";
    }
}

static void scan_dualrestricted_ss(IA_PSIter<IA_Point<int> > *itera, 
                                   IA_PSIter<IA_Point<int> > *iterb,
				   IA_PSIter<IA_Point<int> > *iterab,
				   const IA_SetStructure &ss)
{
    unsigned	i,j;
    IA_Point<int>	p1,p2,p3;
    struct blah {
    blah() { cerr << "("; }
    ~blah() { cerr << ")"; }
    }; // _blah;

    for (i=0; i<ss.nintervals(); i++) {
	IA_ss_interval	temp(ss.retrieve_interval(i));
	// cerr << temp.count << " ";
	if (temp.substructure==IA_SetStructure::FIRST_ONLY) {
	    // cerr << "_1";
	    for (j=0; j<temp.count; j++) {
		if (!(*itera)(p1)) {
		    cout << "[a] substructure too large\n";
		    return;
		}
	    }
	} else if (temp.substructure==IA_SetStructure::SECOND_ONLY) {
	    // cerr << "_2";
	    for (j=0; j<temp.count; j++) {
		if (!(*iterb)(p1)) {
		    cout << "[b] substructure too large\n";
		    return;
		}
	    }
	} else if (temp.substructure==IA_SetStructure::BOTH) {
	    // cerr << "*";
	    for (j=0; j<temp.count; j++) {
		if (!(*itera)(p1)) {
		    cout << "[ab] substructure too large\n";
		    return;
		}
		if (!(*iterab)(p2)) {
		    cout << "[ab] substructure too large\n";
		    return;
		}
		if (!(*iterb)(p3)) {
		    cout << "[ab] substructure too large\n";
		    return;
		}
		if (p1 != p2 || p2 != p3) {
		    cout << "[ab] iterators out of step" << p1 << p2 << p3 << "\n";
		}
	    }
	} else {
	    for (j=0; j<temp.count; j++) {
		scan_dualrestricted_ss(itera, iterb, iterab,
				       temp.substructure);
	    }
	}
	// cerr << "; ";
    }
}

void test_dualrestriction(IA_Set<IA_Point<int> > a, IA_Set<IA_Point<int> > b)
{
    IA_Set<IA_Point<int> >	ab(a&b);

    IA_SetStructure	ss;
    IA_Set<IA_Point<int> > ab2(intersect_with_dualstruct(a,b,&ss));

    if (ab!=ab2) {
	cout << "restriction intersection inaccurate\n";
	return;
    }

    IA_PSIter<IA_Point<int> >	itera(a);
    IA_PSIter<IA_Point<int> >	iterb(b);
    IA_PSIter<IA_Point<int> >	iterab(ab);

    scan_dualrestricted_ss(&itera, &iterb, &iterab, ss);
    IA_Point<int>	p;
    if (itera(p) || iterb(p) || iterab(p)) {
	cout << "dualrestriction structure too small\n";
    }
}

//
//
//

static void scan_extended_ss(IA_PSIter<IA_Point<int> > *itera, 
			     IA_PSIter<IA_Point<int> > *iterb, 
			     IA_PSIter<IA_Point<int> > *iterab,
			     const IA_SetStructure &ss)
{
    unsigned	i,j;
    IA_Point<int>	p1,p2,p3;
    struct blah {
    blah() { cerr << "("; }
    ~blah() { cerr << ")"; }
    }; // _blah;

    for (i=0; i<ss.nintervals(); i++) {
	IA_ss_interval	temp(ss.retrieve_interval(i));
	// cerr << temp.count << " ";
	if (temp.substructure==IA_SetStructure::FIRST_ONLY) {
	    // cerr << "_1";
	    for (j=0; j<temp.count; j++) {
		if (!(*itera)(p1)) {
		    cout << "[a] substructure too large\n";
		    return;
		}
		if (!(*iterab)(p2)) {
		    cout << "[a] substructure too large\n";
		    return;
		}
		if (p1 != p2) {
		    cout << "[a] iterators out of step " << p1 << p2 << "\n";
		}
	    }
	} else if (temp.substructure==IA_SetStructure::SECOND_ONLY) {
	    // cerr << "_2";
	    for (j=0; j<temp.count; j++) {
		if (!(*iterb)(p1)) {
		    cout << "[b] substructure too large\n";
		    return;
		}
		if (!(*iterab)(p2)) {
		    cout << "[b] substructure too large\n";
		    return;
		}
		if (p1 != p2) {
		    cout << "[b] iterators out of step" << p1 << p2 << "\n";
		}
	    }
	} else if (temp.substructure==IA_SetStructure::BOTH) {
	    // cerr << "*";
	    for (j=0; j<temp.count; j++) {
		if (!(*itera)(p1)) {
		    cout << "[ab] substructure too large\n";
		    return;
		}
		if (!(*iterab)(p2)) {
		    cout << "[ab] substructure too large\n";
		    return;
		}
		if (!(*iterb)(p3)) {
		    cout << "[ab] substructure too large\n";
		    return;
		}
		if (p1 != p2 || p2 != p3) {
		    cout << "[ab] iterators out of step" << p1 << p2 << p3 << "\n";
		}
	    }
	} else {
	    for (j=0; j<temp.count; j++) {
		scan_extended_ss(itera, iterb, iterab, temp.substructure);
	    }
	}
	// cerr << "; ";
    }
}

static void pips(IA_Set<IA_Point<int> > ips)
{
    IA_PSIter<IA_Point<int> >	iter(ips);
    IA_Point<int>	p;
    while (iter(p))
	cout << p << " ";
    cout << "\n";
}

void test_extension(IA_Set<IA_Point<int> > a, IA_Set<IA_Point<int> > b)
{
    IA_Set<IA_Point<int> >	ab(a|b);

    IA_SetStructure	ss;
    IA_Set<IA_Point<int> > ab2(union_with_structure(a,b,&ss));
#if 0
    cout << "\n";
    pips(a);
    pips(b);
    pips(ab);
    pips(ab2);
#endif
    if (ab!=ab2) {
	cout << "extension union inaccurate (card << "
	     << ab.card() << "," << ab2.card() << "\n";
	ab.output(cout);
	cout << "\n";
	ab2.output(cout);
	cout << "\n";
	return;
    }

    IA_PSIter<IA_Point<int> >	iter1(a);
    IA_PSIter<IA_Point<int> >	iter2(b);
    IA_PSIter<IA_Point<int> >	iter3(ab2);

    scan_extended_ss(&iter1, &iter2, &iter3, ss);

    IA_Point<int>	p;
    if (iter1(p) || iter2(p) || iter3(p)) {
	cout << "extension structure too small\n";
    }
}


//
//
//


void test_offset(IA_Set<IA_Point<int> > a, IA_Point<int> x, IA_Set<IA_Point<int> > ax)
{
    IA_PSIter<IA_Point<int> >	iter(a);
    IA_Point<int>	p;

    while (iter(p)) {
	if (!ax.contains(p+x)) {
	    cout << p << " ##missing [a] error##\n";
	}
    }

    iter=ax;

    while (iter(p)) {
	if (!a.contains(p-x)) {
	    cout << p << " ##extra [ax] error##\n";
	}
    }

    cout << "offset test complete\n";
}

void test_minkowski(IA_Set<IA_Point<int> > a, IA_Set<IA_Point<int> > b, IA_Set<IA_Point<int> > ab)
{
    IA_PSIter<IA_Point<int> >	iter1(a), iter2(b);
    IA_Point<int>	p1, p2;

    while (iter1(p1)) {
	while (iter2(p2)) {
	    if (!ab.contains(p1+p2)) {
		cout << (p1+p2) << " ##missing [ab] error##\n";
	    }
	}
	if (! ( b+p1 <= ab) ) {
	    cout << "## ! (b+" << p1 << " <= ab) ##\n";
	}
    }

    iter1 = b;
    while (iter1(p1)) {
	if (! ( a+p1 <= ab) ) {
	    cout << "## ! (a+" << p1 << " <= ab) ##\n";
	}
    }

    iter1 = ab;
    while (iter1(p1)) {
	int	found;
	found = 0;
	iter2 = a;
	while (!found && iter2(p2)) {
	    if (b.contains(p1-p2)) {
		found=1;
	    }
	}
	if (!found) {
	    cout << p1 << "##missing ab-a : b error##\n";
	}
    }

    iter1 = ab;
    while (iter1(p1)) {
	int	found;
	found = 0;
	iter2 = b;
	while (!found && iter2(p2)) {
	    if (a.contains(p1-p2)) {
		found=1;
	    }
	}
	if (!found) {
	    cout << p1 << "##missing ab-b : a error##\n";
	}
    }

    cout << "minkowski test complete\n";
}


void test_oreflect(IA_Set<IA_Point<int> > a, IA_Set<IA_Point<int> > ma)
{
    IA_PSIter<IA_Point<int> >	iter(a);
    IA_Point<int>	p;

    while (iter(p)) {
	if (!ma.contains(-p)) {
	    cout << p << " ##missing [a] error##\n";
	}
    }

    iter=ma;

    while (iter(p)) {
	if (!a.contains(-p)) {
	    cout << p << " ##extra [ax] error##\n";
	}
    }

    cout << "origin reflect test complete\n";
}

//
//
//


void list_ips(ostream &o, IA_Set<IA_Point<int> > ips)
{
    IA_PSIter<IA_Point<int> >	iter(ips);
    IA_Point<int>	ip;
    while (iter(ip)) {
	o << ip << ' ';
    }
    o << "\n";
}


void printIntSet(IA_Set<IA_Point<int> > ips)
{
    char	image[80][40];
    int	x,y;
    
    for (x=0; x<40; x++)
	for (y=0; y<40; y++)
	    image[x][y] = ' ';
    
    IA_PSIter<IA_Point<int> >	iter(ips);
    IA_Point<int>	p;
    while (iter(p)) {
	image[p[0]+20][p[1]+10] = '#';
    }
    
    for (x=40; x<80; x++)
	for (y=0; y<40; y++)
	    image[x][y] = ips.contains(IA_Point<int>(x-60,y-10)) ? '*' : '.';
    
    for (y=0; y<40; y++) {
	for (x=0; x<75; x++)
	    cout << image[x][y];
	cout << '\n';
    }
    
}


void test_iter(IA_Set<IA_Point<int> > ps)
{
    IA_PSIter<IA_Point<int> >	iter(ps);
    IA_Point<int>	p, oldp;
    unsigned	idx=0;
    IA_Point<int>	infi, supr, min, max;
    
    while (iter(p)) {
	
	// the following is not part of the IAC++ spec, it just happens
	// to be the way we implemented iteration.
	if (idx>0 && pointcmp(oldp,p)!=-1) {
	    cout << "iteration order error: " << oldp << ">=" << p << '\n';
	}
	
	// this IS part of the spec
	// cout << "index(" << p << ")=" << ps.index(p) << '\n';
	if (ps.index(p) != idx) {
	    cout << "Iteration order error: index("<<p<<")=" << ps.index(p)
		<< "!="<<idx<<'\n';
	}
	if (!(ps.index(idx) == p)) {
	    cout << "Iteration order error: index("<<idx<<")="<<ps.index(idx)
		 << "!="<<p<<'\n';
	}
	
	// we will set min on the first pass through
	if (min.dim()==0)
	    min = p;

	// max cache the last valid p
	max = p;

	if (infi.dim()==0) {
	    infi = p;
	    supr = p;
	} else {
	    infi = inf(infi,p);
	    supr = sup(supr,p);
	}

	idx++;
	oldp = p;
    }
    if (idx != ps.card()) {
	cout << "Cardinality error: ps.card()=" << ps.card()
	    << "!=" << idx << '\n';
    }
    if (min != ps.min()) {
	cout << "Minimum error: ps.min()=" << ps.min() << "!=" << min << '\n';
    }
    if (max != ps.max()) {
	cout << "Maximum error: ps.max()=" << ps.max() << "!=" << max << '\n';
    }
    if (infi != ps.inf()) {
	cout << "Infimum error: ps.inf()=" << ps.inf()
	     << "!=" << infi << '\n';
    }
    if (supr != ps.sup()) {
	cout << "Supremum error: ps.sup()=" << ps.sup()
	     << "!=" << supr << '\n';
    }
    cout << "iteration test complete\n";
}

void
test_arr_ps(IA_Set<IA_Point<int> > ps, const IA_Point<int> *arr, unsigned len)
{
  unsigned i;

  for (i=0; i<len; i++) {
#if 0
    cout << arr[i] << ' ';
#endif
    if (!ps.contains(arr[i])) {
      cout << "pointset missing "<<arr[i]<<" at index "<<i<<'\n'<<flush;
    }
  }
  cout << '\n';

  IA_PSIter<IA_Point<int> >	iter;
  iter = ps;

  IA_Point<int>	ip;
  i=0;
  while (iter(ip)) {
    int	cmp;
#if 0
    cout << ip << ' ';
#endif
    for (i=0; i<len && 1==(cmp=pointcmp(ip,arr[i])); i++)
      ;
    if (0!=cmp) {
      cout << "pointset extra "<<ip<<'\n'<<flush;
    }
  }

}


//
//
//

void
test_arr_ps(IA_Set<IA_Point<double> > ps, const IA_Point<int> *arr, unsigned len)
{
  unsigned i;

  for (i=0; i<len; i++) {
#if 0
    cout << arr[i] << ' ';
#endif
    if (!ps.contains(arr[i])) {
      cout << "pointset missing "<<arr[i]<<" at index "<<i<<'\n'<<flush;
    }
  }
  cout << '\n';

  IA_PSIter<IA_Point<double> >	iter;
  iter = ps;

  IA_Point<double>	ip;
  i=0;
  while (iter(ip)) {
    int	cmp;
#if 0
    cout << ip << ' ';
#endif
    for (i=0; i<len && 1==(cmp=pointcmp(ip,arr[i])); i++)
      ;
    if (0!=cmp) {
      cout << "pointset extra "<<ip<<'\n'<<flush;
    }
  }

}

@


1.16
log
@added parens on line 543
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: gen-test.c,v 1.15 1994/10/06 01:20:06 monica Exp monica $";
d6 3
d593 28
@


1.15
log
@fixed for DOS filename convention
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: gen-test.c,v 1.14 1994/08/21 15:20:36 monica Exp monica $";
d6 3
d543 1
a543 1
		cout << p1+p2 << " ##missing [ab] error##\n";
@


1.14
log
@updated for file name shortening (DblPoint, etc)
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: generic-tests.c,v 1.13 1994/03/04 19:49:33 thoth Exp monica $";
d5 4
a8 1
// $Log: generic-tests.c,v $
d61 1
a61 1
#include "generic-tests.h"
@


1.13
log
@a test for the FloatPointSets.
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: generic-tests.c,v 1.12 93/07/15 11:46:49 thoth Exp Locker: thoth $";
d5 4
a8 1
// $Log:	generic-tests.c,v $
d52 5
a56 2
#include "IntPointSet.h"
#include "IPSIter.h"
d60 1
a60 1
void test_union(IA_IntPointSet a, IA_IntPointSet b, IA_IntPointSet ab)
d62 1
a62 1
    IA_IntPoint	p;
d64 1
a64 1
    IA_IPSIter	iter;
d101 1
a101 1
void test_intersection(IA_IntPointSet a, IA_IntPointSet b, IA_IntPointSet ab)
d103 1
a103 1
    IA_IntPoint	p;
d105 1
a105 1
    IA_IPSIter	iter;
d141 1
a141 1
void test_XOR(IA_IntPointSet a, IA_IntPointSet b, IA_IntPointSet ab)
d143 1
a143 1
    IA_IntPoint	p;
d145 1
a145 1
    IA_IPSIter	iter;
d187 1
a187 1
void test_minus(IA_IntPointSet a, IA_IntPointSet b, IA_IntPointSet ab)
d189 1
a189 1
    IA_IntPoint	p;
d191 1
a191 1
    IA_IPSIter	iter;
d232 3
a234 2
static void scan_restricted_ss(IA_IPSIter *iter, const IA_SetStructure &ss,
		    IA_IntPointSet source, IA_IntPointSet trimmed)
d237 1
a237 1
    IA_IntPoint	p;
d276 1
a276 1
void test_restriction(IA_IntPointSet a, IA_IntPointSet b)
d278 1
a278 1
    IA_IntPointSet	ab(a&b);
d281 1
a281 1
    IA_IntPointSet ab2(intersect_with_structure(a,b,&ss));
d288 1
a288 1
    IA_IPSIter	iter(a);
d291 1
a291 1
    IA_IntPoint	p;
d297 3
a299 2
static void scan_dualrestricted_ss(IA_IPSIter *itera, IA_IPSIter *iterb,
				   IA_IPSIter *iterab,
d303 1
a303 1
    IA_IntPoint	p1,p2,p3;
d357 1
a357 1
void test_dualrestriction(IA_IntPointSet a, IA_IntPointSet b)
d359 1
a359 1
    IA_IntPointSet	ab(a&b);
d362 1
a362 1
    IA_IntPointSet ab2(intersect_with_dualstruct(a,b,&ss));
d369 3
a371 3
    IA_IPSIter	itera(a);
    IA_IPSIter	iterb(b);
    IA_IPSIter	iterab(ab);
d374 1
a374 1
    IA_IntPoint	p;
d384 3
a386 1
static void scan_extended_ss(IA_IPSIter *itera, IA_IPSIter *iterb, IA_IPSIter *iterab,
d390 1
a390 1
    IA_IntPoint	p1,p2,p3;
d457 1
a457 1
static void pips(IA_IntPointSet ips)
d459 2
a460 2
    IA_IPSIter	iter(ips);
    IA_IntPoint	p;
d466 1
a466 1
void test_extension(IA_IntPointSet a, IA_IntPointSet b)
d468 1
a468 1
    IA_IntPointSet	ab(a|b);
d471 1
a471 1
    IA_IntPointSet ab2(union_with_structure(a,b,&ss));
d489 3
a491 3
    IA_IPSIter	iter1(a);
    IA_IPSIter	iter2(b);
    IA_IPSIter	iter3(ab2);
d495 1
a495 1
    IA_IntPoint	p;
d507 1
a507 1
void test_offset(IA_IntPointSet a, IA_IntPoint x, IA_IntPointSet ax)
d509 2
a510 2
    IA_IPSIter	iter(a);
    IA_IntPoint	p;
d529 1
a529 1
void test_minkowski(IA_IntPointSet a, IA_IntPointSet b, IA_IntPointSet ab)
d531 2
a532 2
    IA_IPSIter	iter1(a), iter2(b);
    IA_IntPoint	p1, p2;
d585 1
a585 1
void list_ips(ostream &o, IA_IntPointSet ips)
d587 2
a588 2
    IA_IPSIter	iter(ips);
    IA_IntPoint	ip;
d596 1
a596 1
void printIntSet(IA_IntPointSet ips)
d605 2
a606 2
    IA_IPSIter	iter(ips);
    IA_IntPoint	p;
d613 1
a613 1
	    image[x][y] = ips.contains(IA_IntPoint(x-60,y-10)) ? '*' : '.';
d624 1
a624 1
void test_iter(IA_IntPointSet ps)
d626 2
a627 2
    IA_IPSIter	iter(ps);
    IA_IntPoint	p, oldp;
d629 1
a629 1
    IA_IntPoint	infi, supr, min, max;
d635 1
a635 1
	if (idx>0 && Pointcmp(oldp,p)!=-1) {
d690 1
a690 1
test_arr_ps(IA_IntPointSet ps, const IA_IntPoint *arr, unsigned len)
d704 1
a704 1
  IA_IPSIter	iter;
d707 1
a707 1
  IA_IntPoint	ip;
d714 1
a714 1
    for (i=0; i<len && 1==(cmp=Pointcmp(ip,arr[i])); i++)
d729 1
a729 1
test_arr_ps(IA_FloatPointSet ps, const IA_FloatPoint *arr, unsigned len)
d743 1
a743 1
  IA_PSIter<IA_FloatPoint>	iter;
d746 1
a746 1
  IA_FloatPoint	ip;
d753 1
a753 1
    for (i=0; i<len && 1==(cmp=Pointcmp(ip,arr[i])); i++)
d761 1
@


1.12
log
@IA_ prefix for most classes now necessary.
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: generic-tests.c,v 1.11 92/12/07 12:08:22 thoth Exp Locker: thoth $";
d6 3
d698 39
@


1.11
log
@test for new IntPoint index(unsigned) method.
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: generic-tests.c,v 1.10 92/11/11 12:12:23 thoth Exp Locker: thoth $";
d6 3
d51 1
a51 1
void test_union(IntPointSet a, IntPointSet b, IntPointSet ab)
d53 1
a53 1
    IntPoint	p;
d55 1
a55 1
    IPSIter	iter;
d92 1
a92 1
void test_intersection(IntPointSet a, IntPointSet b, IntPointSet ab)
d94 1
a94 1
    IntPoint	p;
d96 1
a96 1
    IPSIter	iter;
d132 1
a132 1
void test_XOR(IntPointSet a, IntPointSet b, IntPointSet ab)
d134 1
a134 1
    IntPoint	p;
d136 1
a136 1
    IPSIter	iter;
d178 1
a178 1
void test_minus(IntPointSet a, IntPointSet b, IntPointSet ab)
d180 1
a180 1
    IntPoint	p;
d182 1
a182 1
    IPSIter	iter;
d223 2
a224 2
static void scan_restricted_ss(IPSIter *iter, const SetStructure &ss,
		    IntPointSet source, IntPointSet trimmed)
d227 1
a227 1
    IntPoint	p;
d230 1
a230 1
	ss_interval	temp(ss.retrieve_interval(i));
d232 1
a232 1
	if (temp.substructure==SetStructure::FIRST_ONLY) {
d244 1
a244 1
	} else if (temp.substructure==SetStructure::BOTH) {
d266 1
a266 1
void test_restriction(IntPointSet a, IntPointSet b)
d268 1
a268 1
    IntPointSet	ab(a&b);
d270 2
a271 2
    SetStructure	ss;
    IntPointSet ab2(intersect_with_structure(a,b,&ss));
d278 1
a278 1
    IPSIter	iter(a);
d281 1
a281 1
    IntPoint	p;
d287 3
a289 3
static void scan_dualrestricted_ss(IPSIter *itera, IPSIter *iterb,
				   IPSIter *iterab,
				   const SetStructure &ss)
d292 1
a292 1
    IntPoint	p1,p2,p3;
d299 1
a299 1
	ss_interval	temp(ss.retrieve_interval(i));
d301 1
a301 1
	if (temp.substructure==SetStructure::FIRST_ONLY) {
d309 1
a309 1
	} else if (temp.substructure==SetStructure::SECOND_ONLY) {
d317 1
a317 1
	} else if (temp.substructure==SetStructure::BOTH) {
d346 1
a346 1
void test_dualrestriction(IntPointSet a, IntPointSet b)
d348 1
a348 1
    IntPointSet	ab(a&b);
d350 2
a351 2
    SetStructure	ss;
    IntPointSet ab2(intersect_with_dualstruct(a,b,&ss));
d358 3
a360 3
    IPSIter	itera(a);
    IPSIter	iterb(b);
    IPSIter	iterab(ab);
d363 1
a363 1
    IntPoint	p;
d373 2
a374 2
static void scan_extended_ss(IPSIter *itera, IPSIter *iterb, IPSIter *iterab,
			     const SetStructure &ss)
d377 1
a377 1
    IntPoint	p1,p2,p3;
d384 1
a384 1
	ss_interval	temp(ss.retrieve_interval(i));
d386 1
a386 1
	if (temp.substructure==SetStructure::FIRST_ONLY) {
d401 1
a401 1
	} else if (temp.substructure==SetStructure::SECOND_ONLY) {
d416 1
a416 1
	} else if (temp.substructure==SetStructure::BOTH) {
d444 1
a444 1
static void pips(IntPointSet ips)
d446 2
a447 2
    IPSIter	iter(ips);
    IntPoint	p;
d453 1
a453 1
void test_extension(IntPointSet a, IntPointSet b)
d455 1
a455 1
    IntPointSet	ab(a|b);
d457 2
a458 2
    SetStructure	ss;
    IntPointSet ab2(union_with_structure(a,b,&ss));
d476 3
a478 3
    IPSIter	iter1(a);
    IPSIter	iter2(b);
    IPSIter	iter3(ab2);
d482 1
a482 1
    IntPoint	p;
d494 1
a494 1
void test_offset(IntPointSet a, IntPoint x, IntPointSet ax)
d496 2
a497 2
    IPSIter	iter(a);
    IntPoint	p;
d516 1
a516 1
void test_minkowski(IntPointSet a, IntPointSet b, IntPointSet ab)
d518 2
a519 2
    IPSIter	iter1(a), iter2(b);
    IntPoint	p1, p2;
d572 1
a572 1
void list_ips(ostream &o, IntPointSet ips)
d574 2
a575 2
    IPSIter	iter(ips);
    IntPoint	ip;
d583 1
a583 1
void printIntSet(IntPointSet ips)
d592 2
a593 2
    IPSIter	iter(ips);
    IntPoint	p;
d600 1
a600 1
	    image[x][y] = ips.contains(IntPoint(x-60,y-10)) ? '*' : '.';
d611 1
a611 1
void test_iter(IntPointSet ps)
d613 2
a614 2
    IPSIter	iter(ps);
    IntPoint	p, oldp;
d616 1
a616 1
    IntPoint	inf, supr, min, max;
d638 1
a638 1
	if (min.dimensions()==0)
d644 2
a645 2
	if (inf.dimensions()==0) {
	    inf = p;
d648 2
a649 2
	    inf = infimum(inf,p);
	    supr = supremum(supr,p);
d665 1
a665 1
    if (inf != ps.inf()) {
d667 1
a667 1
	     << "!=" << inf << '\n';
d677 1
a677 1
test_arr_ps(IntPointSet ps, const IntPoint *arr, unsigned len)
d691 1
a691 1
  IPSIter	iter;
d694 1
a694 1
  IntPoint	ip;
@


1.10
log
@test of another restriction utility.
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: generic-tests.c,v 1.9 92/11/04 12:02:45 thoth Exp Locker: thoth $";
d6 3
d628 4
@


1.9
log
@test of new image extension support routines.
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: generic-tests.c,v 1.8 92/10/25 20:58:13 thoth Exp Locker: thoth $";
d6 3
d277 83
a359 1
	cout << "extension structure too small\n";
@


1.8
log
@changed argument passing on set restriction routines.
made recursion termination constants have sensible names.
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: generic-tests.c,v 1.7 92/10/21 15:01:17 thoth Exp Locker: thoth $";
d6 4
d209 3
d213 1
d272 4
d277 124
@


1.7
log
@added test for image restriction utility.
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: generic-tests.c,v 1.6 92/09/30 10:43:11 thoth Exp Locker: thoth $";
d6 3
d206 1
a206 1
static void scan_ss(IPSIter *iter, const SetStructure &ss,
d215 1
a215 1
	if (temp.substructure==SetStructure::NEITHER) {
d227 1
a227 1
	} else if (temp.substructure==SetStructure::FIRST) {
d241 1
a241 1
		scan_ss(iter, temp.substructure, source, trimmed);
d252 4
a255 2
    IntPointSet ab2;
    SetStructure	ss(intersect_with_structure(a,b,&ab2));
a261 16
    IntPoint	p;
#if 0
    cout << "a ";
    while (iter(p))
	cout << p << " ";
    cout << "\n";
    iter=b;
    cout << "b ";
    while (iter(p))
	cout << p << " ";
    cout << "\n";
    iter=ab;
    cout << "ab ";
    while (iter(p))
	cout << p << " ";
    cout << "\n";
d263 1
a263 3
    iter=a;
#endif
    scan_ss(&iter, ss, a, ab);
@


1.6
log
@infimum & supremum virtuals now inf & sup.
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: generic-tests.c,v 1.5 92/09/20 17:41:51 thoth Exp Locker: thoth $";
d6 3
d201 78
@


1.5
log
@fixed spelling error.
altered lattice tests to catch more errors.
added minkowski test.
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: generic-tests.c,v 1.4 92/09/20 14:06:03 thoth Exp Locker: thoth $";
d6 5
d366 2
a367 2
    if (inf != ps.infimum()) {
	cout << "Infimum error: ps.infimum()=" << ps.infimum()
d370 2
a371 2
    if (supr != ps.supremum()) {
	cout << "Supremum error: ps.supremum()=" << ps.supremum()
@


1.4
log
@tests added for the new infemum and supremum methods
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: generic-tests.c,v 1.3 92/09/07 13:25:10 thoth Exp Locker: thoth $";
d6 3
d60 4
a63 4
    if (a>ab)
	cout << "## a > a|b ##\n";
    if (b>ab)
	cout << "## b > a|b ##\n";
d101 4
a104 4
    if (a<ab)
	cout << "## a < a&b ##\n";
    if (b<ab)
	cout << "## b < a&b ##\n";
d188 2
a189 2
    if (a<ab)
	cout << "## a < a/b ##\n";
d216 56
d361 2
a362 2
    if (inf != ps.infemum()) {
	cout << "Infemum error: ps.infemum()=" << ps.infemum()
@


1.3
log
@new test for the IntPoint array constructor
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: generic-tests.C,v 1.2 92/08/25 15:34:46 thoth Exp Locker: thoth $";
d5 4
a8 1
// $Log:	generic-tests.C,v $
d257 1
d274 15
d295 14
@


1.2
log
@generic tests now check lattice properties of set operations
new test for translation verification
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: generic-tests.C,v 1.1 92/08/23 13:30:26 thoth Exp Locker: thoth $";
d6 4
d278 34
@


1.1
log
@Initial revision
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: generic-tests.cc,v 1.1 92/08/20 11:22:07 thoth Exp $";
d5 4
a8 1
// $Log:	generic-tests.cc,v $
d49 6
d90 5
d137 2
a138 2
    if ( ((a-b) | (b-a)) != ab ) {
	cout << "(a-b) | (b-a) != a^b\n";
d177 4
a180 1
    
d182 22
@
