head     1.2;
branch   ;
access   ;
symbols  ;
locks    ; strict;
comment  @@;


1.2
date     92.06.03.16.15.05;  author fischer;  state Exp;
branches ;
next     1.1;

1.1
date     92.05.27.07.46.46;  author fischer;  state Exp;
branches ;
next     ;


desc
@new set of tests.
@


1.2
log
@*** empty log message ***
@
text
@static char rcsid[] = "$Id: test5.cc,v 1.1 92/05/27 07:46:46 fischer Exp Locker: fischer $";


#include	<iostream.h>
#include	<Coord.h>

int main()
{
    Coord	ci1(2), ci2(-4), cf1(3.14), cf2(89.2), a, b, c;
    float       float1 = 89.2, float2;
    int         int1, int2;
    void        pr(char *label, Coord coord);
    

//     pr("ci1", ci1);
//     pr("ci2", ci2);
//     pr("cf1", cf1);
//     pr("cf2", cf2);
// 
//     ci1 <<= 2;
//     pr("ci1 <<= 2", ci1);
//     ci1 >>= 2;
//     pr("ci1 >>= 2", ci1);
//     ci1 <<= 1;
//     pr("ci1 <<= 1", ci1);
// 
//     ci2 += 5;
//     pr("ci2 += 5", ci2);
// 
//     
//     ci1 = ci1 << ci2;
//     pr("ci1 = ci1<<ci2", ci1);


    // For comparison, this is plain old float (-g flag):
    //
    // g++ -g:   0.980u 0.040s 0:01.08 94.4% 0+186k 0+0io 0pf+0w
    // g++ -O:   0.460u 0.050s 0:00.58 87.9% 0+179k 0+0io 0pf+0w
    //
    // for (int i = 0; i < 1000000; i++)
    //     float1 += 10.4;    
    //
    // Coord floating point runs 1/5 th speed in optimized case:
    //
    // g++ -g:  7.830u 0.070s 0:08.07 97.8% 0+195k 0+0io 0pf+0w
    // g++ -O:  3.030u 0.070s 0:03.17 97.7% 0+191k 0+0io 0pf+0w
    //
    // for (int i = 0; i < 1000000; i++)
    //      cf2 = cf2 + 10.4;    
    
    ci1 = cf1;

    ci1 = ci2 = 0;
    pr ("ci1", ci1);

    pr ("testing ``ci1 && (ci2=69)'', ci2", ci2);
    if (ci1 && (ci2 = 69))
	pr ("lhs && evaluated true: ci2 is now ", ci2);
    else
	pr ("lhs && evaluated false: ci2 is now ", ci2);

    ci1 = ci2 = -1;
    pr ("ci1", ci1);

    pr ("testing ``ci1 && (ci2=69)'', ci2", ci2);
    if (ci1 && (ci2 = 69))
	pr ("lhs && evaluated true: ci2 is now ", ci2);
    else
	pr ("lhs && evaluated false: ci2 is now ", ci2);

    cout << "\n";


    cf1 = cf2 = 0.75;

    if (cf1 == 0) {
	cout << "oops! ``cf1 == 0'' is true for cf1: " << cf1 << "\n";
    };
       

    pr ("cf1", cf1);

    pr ("testing ``cf1 && (cf2=69)'', cf2", cf2);
    if (cf1 && (cf2 = 69))
	pr ("lhs && evaluated true: cf2 is now ", cf2);
    else
	pr ("lhs && evaluated false: cf2 is now ", cf2);

    cf1 = cf2 = 1.5;
    pr ("cf1", cf1);

    pr ("testing ``cf1 && (cf2=69)'', cf2", cf2);
    if (cf1 && (cf2 = 69))
	pr ("lhs && evaluated true: cf2 is now ", cf2);
    else
	pr ("lhs && evaluated false: cf2 is now ", cf2);


    return 0;
}

void
pr (char *label, Coord coord)
{
    // overly verbose to check all major access functions.

    cout << label 
	 << ",\t type: " << coord.type() 
	 << ",\t value: " << coord << "\n";
}
@


1.1
log
@Initial revision
@
text
@d1 1
a1 1
static char rcsid[] = "$Id: test4.cc,v 1.5 1992/05/26 11:30:30 fischer Exp fischer $";
@
