Drop main() prototype. Syncs with NetBSD-8
[minix.git] / minix / tests / test66.c
blobb5e26b9acb89de4b6108b4c42e43fec82cddb207
1 /* test66: test a whole bunch of basic comparisons.
3 * this test can be used both to generate test cases and run the test
4 * case. all the results to be computed are in myresults[] on each iteration.
5 * invoke the test with an argument, e.g. "./test66 gen" to generate
6 * test66expected.h. then recompile, and run the result. so all you
7 * have to do to add a (integer-valued) test expression as a function
8 * of an int, float or double, is increase SUBRESULTS, add the expression
9 * to myresults[], and regenerate the desired results file.
12 #include <stdio.h>
13 #include <assert.h>
15 int max_error = 10;
16 #include "common.h"
20 #define RESULTSNAME desired
21 #define SUBRESULTS 131
23 int desired[][SUBRESULTS] = {
24 #include "test66expected.h"
27 #define CASES (sizeof(desired)/sizeof(desired[0]))
29 int main(int argc, char *argv[])
31 int a, b;
32 int gen = 0;
33 int n = 0;
35 if(argc != 1) gen = 1;
36 else start(66);
38 for(a = -10; a < 10; a++) {
39 for(b = -10; b < 10; b++) {
40 float fa = a/4.0, fb = b/4.0;
41 double da = a/4.0, db = b/4.0;
42 signed long long a64s = a, b64s = b, ds, ms;
43 unsigned long long a64u = a, b64u = b, mu;
44 signed long a32s = a, b32s = b, ds32, ms32;
45 unsigned long a32u = a, b32u = b, mu32;
47 /* indicate no result */
48 mu32 = ds32 = ms32 = mu = ds = ms = 31337;
50 if(b64s != 0) {
51 /* some 64-bit arithmetic */
52 ds = a64s/b64s; ms = a64s%b64s;
53 mu = a64u%b64u;
54 ds32 = a32s/b32s; ms32 = a32s%b32s;
55 mu32 = a32u%b32u;
58 int myresults[SUBRESULTS] = {
59 /* these results lots of combinations of float, double, int
60 * and signed and unsigned 64-bit comparisons (and therefore
61 * also conversions).
63 a < b, a <= b, a == b, a >= b, a > b, a < fb, a <= fb, a == fb,
64 a >= fb, a > fb, a < db, a <= db, a == db, a >= db, a > db, a < b64s,
65 a <= b64s, a == b64s, a >= b64s, a > b64s, a < b64u, a <= b64u, a == b64u,
66 a >= b64u, a > b64u, fa < b, fa <= b, fa == b, fa >= b, fa > b, fa < fb,
67 fa <= fb, fa == fb, fa >= fb, fa > fb, fa < db, fa <= db, fa == db,
68 fa >= db, fa > db, fa < b64s, fa <= b64s, fa == b64s, fa >= b64s,
69 fa > b64s, fa < b64u, fa <= b64u, fa == b64u, fa >= b64u, fa > b64u,
70 da < b, da <= b, da == b, da >= b, da > b, da < fb, da <= fb, da == fb,
71 da >= fb, da > fb, da < db, da <= db, da == db, da >= db, da > db,
72 da < b64s, da <= b64s, da == b64s, da >= b64s, da > b64s, da < b64u,
73 da <= b64u, da == b64u, da >= b64u, da > b64u, a64s < b, a64s <= b, a64s == b,
74 a64s >= b, a64s > b, a64s < fb, a64s <= fb, a64s == fb, a64s >= fb,
75 a64s > fb, a64s < db, a64s <= db, a64s == db, a64s >= db, a64s > db,
76 a64s < b64s, a64s <= b64s, a64s == b64s, a64s >= b64s, a64s > b64s,
77 a64s < b64u, a64s <= b64u, a64s == b64u, a64s >= b64u, a64s > b64u, a64u < b,
78 a64u <= b, a64u == b, a64u >= b, a64u > b, a64u < fb, a64u <= fb,
79 a64u == fb, a64u >= fb, a64u > fb, a64u < db, a64u <= db, a64u == db,
80 a64u >= db, a64u > db, a64u < b64s, a64u <= b64s, a64u == b64s,
81 a64u >= b64s, a64u > b64s, a64u < b64u, a64u <= b64u, a64u == b64u,
82 a64u >= b64u, a64u > b64u,
84 /* 64-bit divison, modulo operations */
85 (int) ds, (int) ms, (int) mu,
87 /* 32-bit divison, modulo operations */
88 (int) ds32, (int) ms32, (int) mu32
92 if(gen) {
93 int r;
94 printf("{ ");
95 for(r = 0; r < SUBRESULTS; r++) {
96 printf("%d, ", myresults[r]);
98 printf(" }, \n");
99 } else {
100 int subresults;
101 int s;
102 subresults = sizeof(desired[n])/
103 sizeof(desired[n][0]);
104 assert(subresults == SUBRESULTS);
105 for(s = 0; s < subresults; s++) {
106 if(desired[n][s] != myresults[s]) {
107 printf("a, b = %d, %d: %d != %d\n",
108 a, b, desired[n][s],
109 myresults[s]);
110 e(n);
111 } else {
112 assert(desired[n][s] == myresults[s]);
117 n++;
121 if(!gen) {
122 assert(n == CASES);
123 quit();
126 return 0;