|
@@ -15,11 +15,15 @@
|
|
|
*
|
|
|
*/
|
|
|
|
|
|
+char rcs_id[] = "$Header$" ;
|
|
|
+
|
|
|
/* C-compiler test 1 */
|
|
|
/* This program can be used to test C-compilers */
|
|
|
|
|
|
+#ifndef NOFLOAT
|
|
|
# define EPSD 1e-6
|
|
|
# define EPSF 1e-6
|
|
|
+#endif
|
|
|
|
|
|
/* global counters */
|
|
|
|
|
@@ -58,7 +62,9 @@ char *alloc(size) {
|
|
|
return(retval) ;
|
|
|
}
|
|
|
|
|
|
+#ifndef NOFLOAT
|
|
|
double fabs(a) double a ; { return( a<0 ? -a : a) ; }
|
|
|
+#endif
|
|
|
|
|
|
|
|
|
|
|
@@ -68,23 +74,29 @@ int i,j,k,l,m;
|
|
|
|
|
|
long li,lj,lk,ll,lm;
|
|
|
|
|
|
+#ifndef NOFLOAT
|
|
|
float xf, yf, zf;
|
|
|
|
|
|
double xd, yd, zd;
|
|
|
+#endif
|
|
|
|
|
|
struct tp2 {
|
|
|
char c1;
|
|
|
int i,j;
|
|
|
+#ifndef NOFLOAT
|
|
|
float aaa;
|
|
|
double bbb;
|
|
|
+#endif
|
|
|
} r1, r2;
|
|
|
|
|
|
int p, *p1, *p11, **p2, ***p3, ****p4, *****p5;
|
|
|
|
|
|
struct tp2 *pp1, *pp2, *pp3;
|
|
|
int a1[20];
|
|
|
+#ifndef NOFLOAT
|
|
|
float a2[20];
|
|
|
double a3[20];
|
|
|
+#endif
|
|
|
|
|
|
main()
|
|
|
{
|
|
@@ -100,7 +112,9 @@ main()
|
|
|
test8();
|
|
|
test9();
|
|
|
test10();
|
|
|
+#ifndef NOFLOAT
|
|
|
test11();
|
|
|
+#endif
|
|
|
printf("End of test program, %d tests completed, %d errors detected\n",
|
|
|
tct,ect);
|
|
|
return 0 ;
|
|
@@ -659,110 +673,47 @@ test5() /* testing local long variables */
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-test6() /* real arithmetic */
|
|
|
-{
|
|
|
- double fabs();
|
|
|
- double epsd;
|
|
|
- float epsf;
|
|
|
- float locxf;
|
|
|
-
|
|
|
- t = 6;
|
|
|
- tct++;
|
|
|
- epsf = EPSF;
|
|
|
- epsd = EPSD;
|
|
|
- xf = 1.50;
|
|
|
- yf = 3.00;
|
|
|
- zf = 0.10;
|
|
|
- xd = 1.50;
|
|
|
- yd = 3.00;
|
|
|
- zd = 0.10;
|
|
|
- if ( fabs(1.0 + 1.0 - 2.0) > epsd ) e(1);
|
|
|
- if ( fabs( 1e10-1e10 ) > epsd ) e(2);
|
|
|
- if ( fabs( 1.0e+5 * 1.0e+5 - 100e+8 ) > epsd ) e(3);
|
|
|
- if ( fabs( 10.0/3.0 * 3.0/10.0 - 100e-2 ) > epsd ) e(4);
|
|
|
- if ( 0.0e0 != 0 ) e(5);
|
|
|
- if ( fabs( 32767.0 - 32767 ) > epsd ) e(6);
|
|
|
- if ( fabs( 1.0+2+5+3.0e0+7.5e+1+140e-1-100.0 ) > epsd ) e(7);
|
|
|
- if ( fabs(-1+(-1)+(-1.0)+(-1.0e0)+(-1.0e-0)+(-1e0)+6 ) > epsd ) e(8);
|
|
|
- if ( fabs(5.0*yf*zf-xf) > epsf ) e(9);
|
|
|
- if ( fabs(5.0*yd*zd-xd) > epsd ) e(10);
|
|
|
- if ( fabs(yd*yd - (2.0*xd)*(2.0*xd) ) > epsd ) e(11);
|
|
|
- if ( fabs(yf*yf - (2.0*xf)*(2.0*xf) ) > epsf ) e(12);
|
|
|
- if ( fabs( yd*yd+zd*zd+2.0*yd*zd-(yd+zd)*(zd+yd) ) > epsf ) e(13);
|
|
|
- if ( fabs( yf*yf+zf*zf+2.0*yf*zf-(yf+zf)*(zf+yf) ) > epsf ) e(14);
|
|
|
- xf = 1.10;
|
|
|
- yf = 1.20;
|
|
|
- if ( yd<xd ) e(15);
|
|
|
- if ( yd<=xd ) e(16);
|
|
|
- if ( yd==xd ) e(17);
|
|
|
- if ( xd>=yd ) e(18);
|
|
|
- if ( yd<xd ) e(19);
|
|
|
- if ( fabs(yd-xd-1.5) > epsd ) e(20);
|
|
|
- if ( 1.0 * 3.0 != 3.0 * 1.0 ) e(21);
|
|
|
- if ( 1.0 != 1e+0 ) e(22);
|
|
|
- if ( 4.5 < 4.4 ) e(23);
|
|
|
- if ( -3.4 != -3.4 ) e(24);
|
|
|
- if ( 10/3.0 - 10/3.0 != 0.0 ) e(25);
|
|
|
- if ( fabs( (1<<0) * (-5.3) + 5.3 ) > epsd ) e(26);
|
|
|
- if ( fabs( (1<<3) * 5.0 - 4e+1 ) > epsd ) e(27);
|
|
|
- if ( fabs( ((1<<5)>>5) - 1e-0 ) > epsd ) e(28);
|
|
|
- if ( fabs ( 00000 * 3.0 ) > epsd ) e(29);
|
|
|
- if ( fabs ( 8 * 5.0 - 02 * 02 + 04 / 1.0 -40.0 ) > epsd ) e(30);
|
|
|
- if ( fabs ( 'a' / 1.0 - 'a' ) > epsd ) e(31);
|
|
|
- if ( fabs ( (!1) * ( 2.0 / -34e-1 ) ) > epsd ) e(32);
|
|
|
- if ( fabs ( (01 | 1 | 2) * 4.0 - 12.0 ) > epsd ) e(33);
|
|
|
- if ( fabs ( 1.0 * 2.0 * 3.0 * 4.0 * 5.0 - 120.0 ) > epsd ) e(34);
|
|
|
- if ( fabs ( 1.0 * 2.0 * (1 | (4>>1)) - 6 ) > epsd ) e(35);
|
|
|
- if ( fabs ( ( 0 ^ 0 ^ 0 ^ 0 ) * 0.0 ) > epsd ) e(36);
|
|
|
- if ( fabs ( 1.0 * 2.0 * (1 ^ (4>>1)) - 6 ) > epsd ) e(37);
|
|
|
- if ( fabs ( (((((-1.0 * (((((-1.0))))) - 1.0 ))))) ) > epsd) e(38);
|
|
|
- if ( fabs ( ( 2==3 ) * 3.0 ) > epsd ) e(39);
|
|
|
- if ( ( 4 + 3 > 5 ? 3.4 : -5e+3 ) != 3.4 ) e(40);
|
|
|
- if ( ( -4 -'a' > 0 ? 3.4 : -5e+3 ) != -5e+3 ) e(41);
|
|
|
- locxf = 3.0;
|
|
|
- xf = 3.0;
|
|
|
- if ( locxf != locxf ) e(42);
|
|
|
- if ( locxf != xf ) e(43);
|
|
|
- if ( locxf * xf != xf * locxf ) e(44);
|
|
|
- if ( fabs ( ((2*3)>>1) / 3.0 - 1.0 ) > epsd ) e(45);
|
|
|
- if ( fabs ( 'a' / locxf - 'a' / xf ) > epsd ) e(46);
|
|
|
- if ( fabs( xf * locxf - 9.0 ) > epsd ) e(47);
|
|
|
- yd = 3.0;
|
|
|
- if ( fabs( xf*yd - 9.0) > epsd ) e(48);
|
|
|
- if ( yd >= 4 ) e(49);
|
|
|
- if ( locxf == 2 ) e(50);
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-test7() /* global records */
|
|
|
+test6() /* global records */
|
|
|
{
|
|
|
+#ifndef NOFLOAT
|
|
|
double epsd;
|
|
|
float epsf;
|
|
|
double fabs();
|
|
|
+#endif
|
|
|
|
|
|
- t = 7;
|
|
|
+ t = 6;
|
|
|
tct++;
|
|
|
+#ifndef NOFLOAT
|
|
|
epsd = EPSD;
|
|
|
epsf = EPSF;
|
|
|
+#endif
|
|
|
r1.c1 = 'x';
|
|
|
r1.i = 40;
|
|
|
r1.j = 50;
|
|
|
+#ifndef NOFLOAT
|
|
|
r1.aaa = 3.0;
|
|
|
r1.bbb = 4.0;
|
|
|
+#endif
|
|
|
r2.c1 = r1.c1;
|
|
|
r2.i = 50;
|
|
|
r2.j = 40;
|
|
|
+#ifndef NOFLOAT
|
|
|
r2.aaa = 4.0;
|
|
|
r2.bbb = 5.0;
|
|
|
- if ( r1.c1 != 'x' || r1.i != 40 || r1.aaa != 3.0 ) e(1);
|
|
|
+#endif
|
|
|
+ if ( r1.c1 != 'x' || r1.i != 40 ) e(1);
|
|
|
+#ifndef NOFLOAT
|
|
|
+ if ( r1.aaa != 3.0 ) e(1);
|
|
|
+#endif
|
|
|
if ( r1.i != 40 || r2.i != 50 ) e(2);
|
|
|
if ( r2.j != 40 || r1.j != 50 ) e(3);
|
|
|
if ( (r1.c1 + r2.c1)/2 != 'x' ) e(4);
|
|
|
+#ifndef NOFLOAT
|
|
|
if ( r1.aaa * r1.aaa + r2.aaa * r2.aaa != r2.bbb * r2.bbb ) e(5);
|
|
|
r1.i = r1.j = r2.i = r2.j = 3.0;
|
|
|
+#else
|
|
|
+ r1.i = r1.j = r2.i = r2.j = 3;
|
|
|
+#endif
|
|
|
if ( r1.i != 3 ) e(6);
|
|
|
if ( r1.i * r2.j - 9 ) e(7);
|
|
|
r1.i++;
|
|
@@ -785,11 +736,13 @@ test7() /* global records */
|
|
|
if ( (r1.i | r1.i | r1.i | r1.i | r1.i) != r1.i ) e(21);
|
|
|
if ( (r2.j & r1.j & r2.j & r2.i) != (r1.i<<3>>3) ) e(22);
|
|
|
r1.j = 1;
|
|
|
+#ifndef NOFLOAT
|
|
|
r1.aaa = 2.0;
|
|
|
if ( fabs ( r1.j * r1.aaa - 2.0 ) > epsd ) e(23);
|
|
|
if ( (r1.j << 4) * r1.aaa != (r1.j << 4) * r1.aaa ) e(24);
|
|
|
if ( ((r1.j<<6)&r1.j) * r1.aaa ) e(25);
|
|
|
if ((r1.j | (r1.j << 1)) * r1.aaa != ((r1.j << 1) ^ r1.j) * r1.aaa) e(26);
|
|
|
+#endif
|
|
|
r1.i = r1.j = r2.i = r2.j = -2;
|
|
|
if ( r1.i > 0 || r1.j >= 0 ) e(27);
|
|
|
if ( r1.i != r2.j ) e(28);
|
|
@@ -799,44 +752,65 @@ test7() /* global records */
|
|
|
if ( (r1.i % r1.j) % r1.i ) e(31);
|
|
|
if ( 0 % r2.j ) e(32);
|
|
|
if ( 03 * r1.i != -6 ) e(33);
|
|
|
+#ifndef NOFLOAT
|
|
|
r1.aaa = r2.aaa = -4;
|
|
|
r1.bbb = r2.bbb = 4;
|
|
|
if ( r1.aaa > -3.5 ) e(34);
|
|
|
if ( fabs ( r1.aaa - r2.aaa ) > epsf ) e(35);
|
|
|
+#endif
|
|
|
r1.c1 = '\03';
|
|
|
+#ifndef NOFLOAT
|
|
|
if ( fabs ( r2.aaa * r1.aaa - r1.c1 * 5 - 1.0 ) > epsf ) e(36);
|
|
|
+#else
|
|
|
+ if ( 5*r1.c1 != 15 ) e(36) ;
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-test8() /* local records */
|
|
|
+test7() /* local records */
|
|
|
{
|
|
|
+#ifndef NOFLOAT
|
|
|
double epsd;
|
|
|
float epsf;
|
|
|
double fabs();
|
|
|
+#endif
|
|
|
struct tp2 s1, s2;
|
|
|
|
|
|
- t = 8;
|
|
|
+ t = 7;
|
|
|
tct++;
|
|
|
+#ifndef NOFLOAT
|
|
|
epsd = EPSD;
|
|
|
epsf = EPSF;
|
|
|
+#endif
|
|
|
s1.c1 = 'x';
|
|
|
s1.i = 40;
|
|
|
s1.j = 50;
|
|
|
+#ifndef NOFLOAT
|
|
|
s1.aaa = 3.0;
|
|
|
s1.bbb = 4.0;
|
|
|
+#endif
|
|
|
s2.c1 = s1.c1;
|
|
|
s2.i = 50;
|
|
|
s2.j = 40;
|
|
|
+#ifndef NOFLOAT
|
|
|
s2.aaa = 4.0;
|
|
|
s2.bbb = 5.0;
|
|
|
- if ( s1.c1 != 'x' || s1.i != 40 || s1.aaa != 3.0 ) e(1);
|
|
|
+#endif
|
|
|
+ if ( s1.c1 != 'x' || s1.i != 40 ) e(1);
|
|
|
+#ifndef NOFLOAT
|
|
|
+ if ( s1.aaa != 3.0 ) e(1);
|
|
|
+#endif
|
|
|
if ( s1.i != 40 || s2.i != 50 ) e(2);
|
|
|
if ( s2.j != 40 || s1.j != 50 ) e(3);
|
|
|
if ( (s1.c1 + s2.c1)/2 != 'x' ) e(4);
|
|
|
+#ifndef NOFLOAT
|
|
|
if ( s1.aaa * s1.aaa + s2.aaa * s2.aaa != s2.bbb * s2.bbb ) e(5);
|
|
|
s1.i = s1.j = s2.i = s2.j = 3.0;
|
|
|
+#else
|
|
|
+ s1.i = s1.j = s2.i = s2.j = 3;
|
|
|
+#endif
|
|
|
if ( s1.i != 3 ) e(6);
|
|
|
if ( s1.i * s2.j - 9 ) e(7);
|
|
|
s1.i++;
|
|
@@ -859,11 +833,13 @@ test8() /* local records */
|
|
|
if ( (s1.i | s1.i | s1.i | s1.i | s1.i) != s1.i ) e(21);
|
|
|
if ( (s2.j & s1.j & s2.j & s2.i) != (s1.i<<3>>3) ) e(22);
|
|
|
s1.j = 1;
|
|
|
+#ifndef NOFLOAT
|
|
|
s1.aaa = 2.0;
|
|
|
if ( fabs ( s1.j * s1.aaa - 2.0 ) > epsd ) e(23);
|
|
|
if ( (s1.j << 4) * s1.aaa != (s1.j << 4) * s1.aaa ) e(24);
|
|
|
if ( ((s1.j<<6)&s1.j) * s1.aaa ) e(25);
|
|
|
if ((s1.j | (s1.j << 1)) * s1.aaa != ((s1.j << 1) ^ s1.j) * s1.aaa) e(26);
|
|
|
+#endif
|
|
|
s1.i = s1.j = s2.i = s2.j = -2;
|
|
|
if ( s1.i > 0 || s1.j >= 0 ) e(27);
|
|
|
if ( s1.i != s2.j ) e(28);
|
|
@@ -873,33 +849,44 @@ test8() /* local records */
|
|
|
if ( (s1.i % s1.j) % s1.i ) e(31);
|
|
|
if ( 0 % s2.j ) e(32);
|
|
|
if ( 03 * s1.i != -6 ) e(33);
|
|
|
+#ifndef NOFLOAT
|
|
|
s1.aaa = s2.aaa = -4;
|
|
|
s1.bbb = s2.bbb = 4;
|
|
|
if ( s1.aaa > -3.5 ) e(34);
|
|
|
if ( fabs ( s1.aaa - s2.aaa ) > epsf ) e(35);
|
|
|
+#endif
|
|
|
s1.c1 = '\03';
|
|
|
+#ifndef NOFLOAT
|
|
|
if ( fabs ( s2.aaa * s1.aaa - s1.c1 * 5 - 1.0 ) > epsf ) e(36);
|
|
|
+#else
|
|
|
+ if ( 5*r1.c1 != 15 ) e(36) ;
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-test9() /* global arrays */
|
|
|
+test8() /* global arrays */
|
|
|
{
|
|
|
+#ifndef NOFLOAT
|
|
|
float epsf;
|
|
|
double epsd;
|
|
|
double fabs();
|
|
|
+#endif
|
|
|
|
|
|
- t = 9;
|
|
|
+ t = 8;
|
|
|
tct++;
|
|
|
+#ifndef NOFLOAT
|
|
|
epsf = EPSF;
|
|
|
epsd = EPSD;
|
|
|
+#endif
|
|
|
for ( i=0; i<20 ; i++ )
|
|
|
a1[i] = i*i;
|
|
|
if ( a1[9] != 81 || a1[17] != 289 || a1[0] != 0 ) e(1);
|
|
|
if ( a1[1] + a1[2] + a1[3] != 14 ) e(2);
|
|
|
if ( ! a1[15] ) e(3);
|
|
|
if ( a1[8] / a1[4] != 4 ) e(4);
|
|
|
+#ifndef NOFLOAT
|
|
|
for ( i=0; i<20; i++ )
|
|
|
a2[i] = 10.0e-1 + i/54.324e-1;
|
|
|
if ( fabs(a2[4]*a2[4]-a2[4]*(10.0e-1 + 4/54.324e-1 ) ) > epsf ) e(5);
|
|
@@ -910,6 +897,7 @@ test9() /* global arrays */
|
|
|
if ( fabs(a3[4]*a3[4]-a3[4]*(1.0e0+4/54.324e-1 )) > epsd ) e(8);
|
|
|
if ( fabs( a3[8]*a3[9]/a3[8]/a3[9]-a3[10]+a3[10]-1000e-3) > epsd ) e(9);
|
|
|
if ( fabs(a3[8]+a3[6]-2*a3[7]) > epsd ) e(10);
|
|
|
+#endif
|
|
|
for ( i=0; i<20; i++ )
|
|
|
a1[i] = i+1;
|
|
|
if ( a1[a1[a1[a1[a1[a1[0]]]]]] != 6 ) e(11);
|
|
@@ -970,39 +958,50 @@ test9() /* global arrays */
|
|
|
if ( a1[a1[1]^a1[2]^a1[4]^a1[8]] != a1[a1[1]|a1[2]|a1[4]|a1[8]] ) e(50);
|
|
|
for ( i = 0; i<20; i++ )
|
|
|
a1[i] = i+1;
|
|
|
+#ifndef NOFLOAT
|
|
|
for ( i = 0; i<20; i++ )
|
|
|
a2[i] = a3[i] = a1[i];
|
|
|
if ( a2[5] != 6.0 ) e(51);
|
|
|
if ( a2[13] != 14.0 ) e(52);
|
|
|
if ( a2[a1[a1[a1[a1[a1[0]]]]]] != 6.0 ) e(53);
|
|
|
+#endif
|
|
|
if ( a1[12] != 13 ) e(54);
|
|
|
+#ifndef NOFLOAT
|
|
|
if ( a1[ a1[12] = a2[a1[11]] ] != 14 ) e(55);
|
|
|
if ( fabs( a2[13] - a2[a1[12]] ) > epsf ) e(56);
|
|
|
if ( a2[8] != a1[8] ) e(57);
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-test10() /* local arrays */
|
|
|
+test9() /* local arrays */
|
|
|
{
|
|
|
+#ifndef NOFLOAT
|
|
|
float epsf;
|
|
|
double epsd;
|
|
|
double fabs();
|
|
|
+#endif
|
|
|
int b1[20];
|
|
|
+#ifndef NOFLOAT
|
|
|
float b2[20];
|
|
|
double b3[20];
|
|
|
+#endif
|
|
|
|
|
|
- t = 10;
|
|
|
+ t = 9;
|
|
|
tct++;
|
|
|
+#ifndef NOFLOAT
|
|
|
epsf = EPSF;
|
|
|
epsd = EPSD;
|
|
|
+#endif
|
|
|
for ( i=0; i<20 ; i++ )
|
|
|
b1[i] = i*i;
|
|
|
if ( b1[9] != 81 || b1[17] != 289 || b1[0] != 0 ) e(1);
|
|
|
if ( b1[1] + b1[2] + b1[3] != 14 ) e(2);
|
|
|
if ( ! b1[15] ) e(3);
|
|
|
if ( b1[8] / b1[4] != 4 ) e(4);
|
|
|
+#ifndef NOFLOAT
|
|
|
for ( i=0; i<20; i++ )
|
|
|
b2[i] = 10.0e-1 + i/54.324e-1;
|
|
|
if ( fabs(b2[4]*b2[4]-b2[4]*(10.0e-1 + 4/54.324e-1 ) ) > epsf ) e(5);
|
|
@@ -1013,6 +1012,7 @@ test10() /* local arrays */
|
|
|
if ( fabs(b3[4]*b3[4]-b3[4]*(1.0e0+4/54.324e-1 )) > epsd ) e(8);
|
|
|
if ( fabs( b3[8]*b3[9]/b3[8]/b3[9]-b3[10]+b3[10]-1000e-3) > epsd ) e(9);
|
|
|
if ( fabs(b3[8]+b3[6]-2*b3[7]) > epsd ) e(10);
|
|
|
+#endif
|
|
|
for ( i=0; i<20; i++ )
|
|
|
b1[i] = i+1;
|
|
|
if ( b1[b1[b1[b1[b1[b1[0]]]]]] != 6 ) e(11);
|
|
@@ -1073,29 +1073,37 @@ test10() /* local arrays */
|
|
|
if ( b1[b1[1]^b1[2]^b1[4]^b1[8]] != b1[b1[1]|b1[2]|b1[4]|b1[8]] ) e(50);
|
|
|
for ( i = 0; i<20; i++ )
|
|
|
b1[i] = i+1;
|
|
|
+#ifndef NOFLOAT
|
|
|
for ( i = 0; i<20; i++ )
|
|
|
b2[i] = b3[i] = b1[i];
|
|
|
if ( b2[5] != 6.0 ) e(51);
|
|
|
if ( b2[13] != 14.0 ) e(52);
|
|
|
if ( b2[b1[b1[b1[b1[b1[0]]]]]] != 6.0 ) e(53);
|
|
|
+#endif
|
|
|
if ( b1[12] != 13 ) e(54);
|
|
|
+#ifndef NOFLOAT
|
|
|
if ( b1[ b1[12] = b2[b1[11]] ] != 14 ) e(55);
|
|
|
if ( fabs( b2[13] - b2[b1[12]] ) > epsf ) e(56);
|
|
|
if ( b2[8] != b1[8] ) e(57);
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-test11() /* global pointers */
|
|
|
+test10() /* global pointers */
|
|
|
{
|
|
|
+#ifndef NOFLOAT
|
|
|
float epsf;
|
|
|
double fabs();
|
|
|
+#endif
|
|
|
int li;
|
|
|
struct tp2 strp2;
|
|
|
|
|
|
+#ifndef NOFLOAT
|
|
|
epsf = EPSF;
|
|
|
- t = 11;
|
|
|
+#endif
|
|
|
+ t = 10;
|
|
|
tct++;
|
|
|
p1 = &li;
|
|
|
li = 076;
|
|
@@ -1138,6 +1146,7 @@ test11() /* global pointers */
|
|
|
pp1->i++;
|
|
|
if ( ++pp2->i != pp1->i ) e(52);
|
|
|
if ( pp2->i != 4 ) e(53);
|
|
|
+#ifndef NOFLOAT
|
|
|
pp1->aaa = 3.0;
|
|
|
pp2->aaa = -3.0;
|
|
|
pp3->bbb = 25.0;
|
|
@@ -1145,16 +1154,103 @@ test11() /* global pointers */
|
|
|
if ( fabs( pp1->aaa + pp2->aaa ) > epsf ) e(55);
|
|
|
if ( fabs( pp1->aaa * pp2->aaa + pp3->bbb - 16 ) > epsf ) e(56);
|
|
|
if ( fabs( pp1->aaa / pp2->aaa + 1 ) > epsf ) e(57);
|
|
|
+#endif
|
|
|
pp1->c1 = 'x';
|
|
|
pp1->i = pp1->j = 45;
|
|
|
+#ifndef NOFLOAT
|
|
|
pp1->aaa = 100.0;
|
|
|
pp1->bbb = 1024.0;
|
|
|
+#endif
|
|
|
strp2.c1 = pp1->c1; /* strp2 is a local struct */
|
|
|
strp2.i = pp1->i = strp2.j = pp1->j;
|
|
|
+#ifndef NOFLOAT
|
|
|
strp2.aaa = pp1->aaa;
|
|
|
strp2.bbb = pp1->bbb;
|
|
|
+#endif
|
|
|
if ( strp2.c1 != 'x' ) e(58);
|
|
|
if ( strp2.i != strp2.j ) e(59);
|
|
|
+#ifndef NOFLOAT
|
|
|
if ( strp2.aaa != pp1->aaa ) e(60);
|
|
|
if ( strp2.bbb != pp1->bbb ) e(61);
|
|
|
+#endif
|
|
|
}
|
|
|
+
|
|
|
+#ifndef NOFLOAT
|
|
|
+
|
|
|
+test11() /* real arithmetic */
|
|
|
+{
|
|
|
+ double fabs();
|
|
|
+ double epsd;
|
|
|
+ float epsf;
|
|
|
+ float locxf;
|
|
|
+
|
|
|
+ t = 11 ;
|
|
|
+ tct++;
|
|
|
+ epsf = EPSF;
|
|
|
+ epsd = EPSD;
|
|
|
+ xf = 1.50;
|
|
|
+ yf = 3.00;
|
|
|
+ zf = 0.10;
|
|
|
+ xd = 1.50;
|
|
|
+ yd = 3.00;
|
|
|
+ zd = 0.10;
|
|
|
+ if ( fabs(1.0 + 1.0 - 2.0) > epsd ) e(1);
|
|
|
+ if ( fabs( 1e10-1e10 ) > epsd ) e(2);
|
|
|
+ if ( fabs( 1.0e+5 * 1.0e+5 - 100e+8 ) > epsd ) e(3);
|
|
|
+ if ( fabs( 10.0/3.0 * 3.0/10.0 - 100e-2 ) > epsd ) e(4);
|
|
|
+ if ( 0.0e0 != 0 ) e(5);
|
|
|
+ if ( fabs( 32767.0 - 32767 ) > epsd ) e(6);
|
|
|
+ if ( fabs( 1.0+2+5+3.0e0+7.5e+1+140e-1-100.0 ) > epsd ) e(7);
|
|
|
+ if ( fabs(-1+(-1)+(-1.0)+(-1.0e0)+(-1.0e-0)+(-1e0)+6 ) > epsd ) e(8);
|
|
|
+ if ( fabs(5.0*yf*zf-xf) > epsf ) e(9);
|
|
|
+ if ( fabs(5.0*yd*zd-xd) > epsd ) e(10);
|
|
|
+ if ( fabs(yd*yd - (2.0*xd)*(2.0*xd) ) > epsd ) e(11);
|
|
|
+ if ( fabs(yf*yf - (2.0*xf)*(2.0*xf) ) > epsf ) e(12);
|
|
|
+ if ( fabs( yd*yd+zd*zd+2.0*yd*zd-(yd+zd)*(zd+yd) ) > epsf ) e(13);
|
|
|
+ if ( fabs( yf*yf+zf*zf+2.0*yf*zf-(yf+zf)*(zf+yf) ) > epsf ) e(14);
|
|
|
+ xf = 1.10;
|
|
|
+ yf = 1.20;
|
|
|
+ if ( yd<xd ) e(15);
|
|
|
+ if ( yd<=xd ) e(16);
|
|
|
+ if ( yd==xd ) e(17);
|
|
|
+ if ( xd>=yd ) e(18);
|
|
|
+ if ( yd<xd ) e(19);
|
|
|
+ if ( fabs(yd-xd-1.5) > epsd ) e(20);
|
|
|
+ if ( 1.0 * 3.0 != 3.0 * 1.0 ) e(21);
|
|
|
+ if ( 1.0 != 1e+0 ) e(22);
|
|
|
+ if ( 4.5 < 4.4 ) e(23);
|
|
|
+ if ( -3.4 != -3.4 ) e(24);
|
|
|
+ if ( 10/3.0 - 10/3.0 != 0.0 ) e(25);
|
|
|
+ if ( fabs( (1<<0) * (-5.3) + 5.3 ) > epsd ) e(26);
|
|
|
+ if ( fabs( (1<<3) * 5.0 - 4e+1 ) > epsd ) e(27);
|
|
|
+ if ( fabs( ((1<<5)>>5) - 1e-0 ) > epsd ) e(28);
|
|
|
+ if ( fabs ( 00000 * 3.0 ) > epsd ) e(29);
|
|
|
+ if ( fabs ( 8 * 5.0 - 02 * 02 + 04 / 1.0 -40.0 ) > epsd ) e(30);
|
|
|
+ if ( fabs ( 'a' / 1.0 - 'a' ) > epsd ) e(31);
|
|
|
+ if ( fabs ( (!1) * ( 2.0 / -34e-1 ) ) > epsd ) e(32);
|
|
|
+ if ( fabs ( (01 | 1 | 2) * 4.0 - 12.0 ) > epsd ) e(33);
|
|
|
+ if ( fabs ( 1.0 * 2.0 * 3.0 * 4.0 * 5.0 - 120.0 ) > epsd ) e(34);
|
|
|
+ if ( fabs ( 1.0 * 2.0 * (1 | (4>>1)) - 6 ) > epsd ) e(35);
|
|
|
+ if ( fabs ( ( 0 ^ 0 ^ 0 ^ 0 ) * 0.0 ) > epsd ) e(36);
|
|
|
+ if ( fabs ( 1.0 * 2.0 * (1 ^ (4>>1)) - 6 ) > epsd ) e(37);
|
|
|
+ if ( fabs ( (((((-1.0 * (((((-1.0))))) - 1.0 ))))) ) > epsd) e(38);
|
|
|
+ if ( fabs ( ( 2==3 ) * 3.0 ) > epsd ) e(39);
|
|
|
+ if ( ( 4 + 3 > 5 ? 3.4 : -5e+3 ) != 3.4 ) e(40);
|
|
|
+ if ( ( -4 -'a' > 0 ? 3.4 : -5e+3 ) != -5e+3 ) e(41);
|
|
|
+ locxf = 3.0;
|
|
|
+ xf = 3.0;
|
|
|
+ if ( locxf != locxf ) e(42);
|
|
|
+ if ( locxf != xf ) e(43);
|
|
|
+ if ( locxf * xf != xf * locxf ) e(44);
|
|
|
+ if ( fabs ( ((2*3)>>1) / 3.0 - 1.0 ) > epsd ) e(45);
|
|
|
+ if ( fabs ( 'a' / locxf - 'a' / xf ) > epsd ) e(46);
|
|
|
+ if ( fabs( xf * locxf - 9.0 ) > epsd ) e(47);
|
|
|
+ yd = 3.0;
|
|
|
+ if ( fabs( xf*yd - 9.0) > epsd ) e(48);
|
|
|
+ if ( yd >= 4 ) e(49);
|
|
|
+ if ( locxf == 2 ) e(50);
|
|
|
+}
|
|
|
+
|
|
|
+#endif
|
|
|
+
|
|
|
+
|