head	1.6;
access
	monica
	thoth;
symbols
	Eglin_alpha_1:1.3;
locks
	monica:1.6; strict;
comment	@// @;


1.6
date	94.11.09.20.25.21;	author monica;	state Exp;
branches;
next	1.5;

1.5
date	94.10.06.01.07.08;	author monica;	state Exp;
branches;
next	1.4;

1.4
date	94.08.17.04.12.11;	author monica;	state Exp;
branches;
next	1.3;

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

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

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


desc
@CFrontified version
@


1.6
log
@removed include devfrags & any debugging calls to malloc
@
text
@// Emacs: -*- C++ -*-
static char rcsid[] = "$Id: test005.c,v 1.5 1994/10/06 01:07:08 monica Exp monica $";

//
// $Log: test005.c,v $
// Revision 1.5  1994/10/06  01:07:08  monica
// updated for DOS file naming
//
// Revision 1.4  1994/08/17  04:12:11  monica
// added int main & return 0
//
// Revision 1.3  1992/09/14  21:58:52  thoth
// dimension is now a parameter to the IA_Point<int> array constructor.
//
// Revision 1.2  92/08/25  15:40:18  thoth
// set difference is operator/, not -
// 
// Revision 1.1  92/08/23  13:30:42  thoth
// Initial revision
// 
//

#ifdef __GNUC__
#define USE_ACG
#endif

#include <stdlib.h>

#include "IntPoint.h"
#include "IntPS.h"
#include "PSIter.h"

#include "gen-test.h"

void
test_arr_ps(IA_Set<IA_Point<int> > ps, 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;
    }
  }

}

istream & operator >> (istream & i, IA_Point<int> &p)
{
    int	is[5];
    int	idx;
    char	delim;
    cin >> delim;
    if (delim != '<') {
	i.putback(delim);
	i.clear(ios::badbit|i.rdstate());
	return i;
    }

    if (i.flags() & ios::skipws) i >> ws;
    if (i.peek() == '>') {
	p = IA_Point<int>();
	return i;
    }

    for (idx=0; idx<5 && i ; idx++) {
	i >> is[idx] >> ws;
	if (i.peek() == '>') {
	    i >> delim;
	    idx++;
	    break;
	}
    }

    p = IA_Point<int>(is, idx);

    return i;
}

int main(int argc, char**argv)
{
    int	argidx=1;
    
    unsigned l1, l2;
    l1 = (argc<argidx+1) ? 40 : atoi(argv[argidx]);
    argidx++;
    l2 = (argc<argidx+1) ? 40 : atoi(argv[argidx]);
    argidx++;
    
    IA_Point<int>	*a1 = new IA_Point<int>[l1];
    IA_Point<int>	*a2 = new IA_Point<int>[l2];
    
    cout << "ready to fill the arrays\n" << flush;
    
    unsigned i;
    for (i=0; i<l1 && (cin >> a1[i]); i++) {
	// cout << a1[i];
    }
    l1 = i;
    cout << "array 1 filled " << l1 << "\n" << flush;
    IA_Set<IA_Point<int> >	ps1(a1[0].dim(), a1,l1);

    {
	char	blah[80];
	cin.clear(cin.rdstate() & ~ios::badbit);
	cin.width(sizeof(blah));
	*blah = 0;
	while (cin && !*blah) {
	    cin >> ws >> blah;
	    cout << "blah: " << blah << '\n';
	}
	if (!cin) {
	    cout << "ran out of shit: " << blah << "\n" << flush;
	    exit(1);
	}
    }

    for (i=0; i<l2 && (cin >> a2[i]); i++) {
	// cout << a2[i];
    }
    l2 = i;
    cout << "array 2 filled " << l2 << "\n" << flush;
    IA_Set<IA_Point<int> >	ps2(a2[0].dim(), a2,l2);
    
    SortIntPointArray(a1, l1);
    cout << "array 1 sorted\n" << flush;
    SortIntPointArray(a2, l2);
    cout << "array 2 sorted\n" << flush;
    
    test_arr_ps(ps1, a1, l1);
    cout << "ips 1 tested\n"<< flush;
    test_arr_ps(ps2, a2, l2);
    cout << "ips 2 tested\n"<< flush;
    
#if 1
    cout << "outputting ips 1\n";
    ps1.output(cout);
    cout << "outputting ips 2\n";
    ps2.output(cout);
#endif
    
    test_iter(ps1);
    test_iter(ps2);
    
    // list_ips(cout << "ps1: ",ps1);
    // list_ips(cout << "ps2: ",ps2);

    IA_Set<IA_Point<int> > temp;
#if 1
    temp = ps1|ps2;
    // list_ips(cout << "ps1|ps2: ",temp);
    test_union(ps1,ps2,temp);
    test_iter(temp);
    
    temp = ps1&ps2;
    // list_ips(cout << "ps1&ps2: ",temp);
    test_intersection(ps1,ps2,temp);
    test_iter(temp);
#endif
    
    temp = ps1^ps2;
    temp.output(cout);
    // list_ips(cout << "ps1^ps2: ",temp);
    test_XOR(ps1,ps2,temp);
    test_iter(temp);
    
    temp = ps1/ps2;
    // list_ips(cout << "ps1/ps2: ",temp);
    test_minus(ps1,ps2,temp);
    test_iter(temp);

    temp = ps1 + ps2.choice();
    test_offset(ps1, ps2.choice(), temp);
    test_iter(temp);

    return 0;

}
@


1.5
log
@updated for DOS file naming
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: test005.c,v 1.4 1994/08/17 04:12:11 monica Exp monica $";
d6 3
a28 1
#include "devfrags.h"
@


1.4
log
@added int main & return 0
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: test005.c,v 1.3 1992/09/14 21:58:52 thoth Exp monica $";
d6 3
d26 1
a26 1
#include "dev-frags.h"
d31 1
a31 1
#include "generic-tests.h"
@


1.3
log
@dimension is now a parameter to the IntPoint array constructor.
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: test005.C,v 1.2 92/08/25 15:40:18 thoth Exp Locker: thoth $";
d5 4
a8 1
// $Log:	test005.C,v $
d25 2
a26 2
#include "IntPointSet.h"
#include "IPSIter.h"
d31 1
a31 1
test_arr_ps(IntPointSet ps, IntPoint *arr, unsigned len)
d45 1
a45 1
  IPSIter	iter;
d48 1
a48 1
  IntPoint	ip;
d55 1
a55 1
    for (i=0; i<len && 1==(cmp=Pointcmp(ip,arr[i])); i++)
d64 1
a64 1
istream & operator >> (istream & i, IntPoint &p)
d78 1
a78 1
	p = IntPoint();
d91 1
a91 1
    p = IntPoint(is, idx);
d106 2
a107 2
    IntPoint	*a1 = new IntPoint[l1];
    IntPoint	*a2 = new IntPoint[l2];
d117 1
a117 1
    IntPointSet	ps1(a1[0].dimensions(), a1,l1);
d139 1
a139 1
    IntPointSet	ps2(a2[0].dimensions(), a2,l2);
d164 1
a164 1
    IntPointSet temp;
d191 3
@


1.2
log
@set difference is operator/, not -
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: test005.C,v 1.1 92/08/23 13:30:42 thoth Exp Locker: thoth $";
d6 3
d114 1
a114 1
    IntPointSet	ps1(a1,l1);
d136 1
a136 1
    IntPointSet	ps2(a2,l2);
@


1.1
log
@Initial revision
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: test004.cc,v 1.1 92/08/20 11:22:34 thoth Exp $";
d5 4
a8 1
// $Log:	test004.cc,v $
d177 2
a178 2
    temp = ps1-ps2;
    // list_ips(cout << "ps1-ps2: ",temp);
d180 4
@
