head	1.1;
access;
symbols;
locks
	monica:1.1; strict;
comment	@// @;


1.1
date	94.11.20.14.36.02;	author monica;	state Exp;
branches;
next	;


desc
@@


1.1
log
@Initial revision
@
text
@// $Log$

#include <stdlib.h>

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

#include "gen-test.h"
#include "pt-util.h"
#include "ps-util.h"

IA_Set<IA_Point<int> >	eps1, eps2;

int cp1(IA_Point<int> ip)
{
    return eps1.contains(ip);
}

int cp2(IA_Point<int> ip)
{
    return eps2.contains(ip);
}

void check_equal(IA_Set<IA_Point<int> > a, IA_Set<IA_Point<int> > b)
{
    cout << "equality test ";
    cout << ( (a==b) ? "succeeded" : "failed" ) << '\n' << flush;
}

int main(int argc, char**argv)
{
    unsigned size;
    size = (argc<2) ? 2 : atoi(argv[1]);
    
    unsigned l1, l2;
    l1 = (argc<3) ? 40 : atoi(argv[2]);
    l2 = (argc<4) ? 40 : atoi(argv[3]);

    eps1 = make_random_pointset(size, l1, 0, 9);
    eps2 = make_random_pointset(size, l2, 0, 9);

    IA_Set<IA_Point<int> >	ps1(size, cp1), ps2(size, cp2);
    IA_Set<IA_Point<int> >	mask(extend_to_point(-10, size), extend_to_point(20, size));

#if 1
    cout << "outputting ips 1\n";
    ps1.output(cout);
    cout << "outputting ips 2\n";
    ps2.output(cout);
#endif

    IA_Set<IA_Point<int> > temp;

    temp = ps1|ps2;
    // list_ips(cout << "ps1|ps2: ",temp);
    test_union(ps1&mask,ps2&mask,temp&mask);
    temp.output(cout);
    temp &= mask;
    test_iter(temp);
    check_equal(temp, eps1|eps2);

    temp = ps1&ps2;
    // list_ips(cout << "ps1&ps2: ",temp);
    test_intersection(ps1&mask,ps2&mask,temp&mask);
    temp.output(cout);
    temp &= mask;
    test_iter(temp);
    check_equal(temp, eps1&eps2);

    temp = ps1^ps2;
    // list_ips(cout << "ps1^ps2: ",temp);
    test_XOR(ps1&mask,ps2&mask,temp&mask);
    temp.output(cout);
    temp &= mask;
    test_iter(temp);
    check_equal(temp, eps1^eps2);

    temp = ps1/ps2;
    // list_ips(cout << "ps1/ps2: ",temp);
    test_minus(ps1&mask,ps2&mask,temp&mask);
    temp.output(cout);
    temp &= mask;
    test_iter(temp);
    check_equal(temp, eps1/eps2);

    temp = ps2/ps1;
    // list_ips(cout << "ps2/ps1: ",temp);
    test_minus(ps2&mask,ps1&mask,temp&mask);
    temp.output(cout);
    temp &= mask;
    test_iter(temp);
    check_equal(temp, eps2/eps1);

    temp = ps1 + eps2.choice();
    test_offset(ps1&mask, eps2.choice(), temp&mask);
    temp.output(cout);
    temp &= mask;
    test_iter(temp);
    check_equal(temp, eps1+eps2.choice());

    return 0;

}
@
