am-kernels/tests/cpu-tests/tests/max.c

28 lines
995 B
C
Raw Normal View History

2020-08-11 17:38:42 +00:00
#include "trap.h"
int max(int x, int y) {
int z;
if(x > y) { z = x; }
else { z = y; }
return z;
}
int test_data[] = {0, 1, 2, 0x7fffffff, 0x80000000, 0x80000001, 0xfffffffe, 0xffffffff};
int ans[] = {0, 0x1, 0x2, 0x7fffffff, 0, 0, 0, 0, 0x1, 0x1, 0x2, 0x7fffffff, 0x1, 0x1, 0x1, 0x1, 0x2, 0x2, 0x2, 0x7fffffff, 0x2, 0x2, 0x2, 0x2, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0, 0x1, 0x2, 0x7fffffff, 0x80000000, 0x80000001, 0xfffffffe, 0xffffffff, 0, 0x1, 0x2, 0x7fffffff, 0x80000001, 0x80000001, 0xfffffffe, 0xffffffff, 0, 0x1, 0x2, 0x7fffffff, 0xfffffffe, 0xfffffffe, 0xfffffffe, 0xffffffff, 0, 0x1, 0x2, 0x7fffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff};
#define NR_DATA LENGTH(test_data)
int main() {
int i, j, ans_idx = 0;
for(i = 0; i < NR_DATA; i ++) {
for(j = 0; j < NR_DATA; j ++) {
2020-08-11 17:40:29 +00:00
check(max(test_data[i], test_data[j]) == ans[ans_idx ++]);
2020-08-11 17:38:42 +00:00
}
2020-08-11 17:40:29 +00:00
check(j == NR_DATA);
2020-08-11 17:38:42 +00:00
}
2020-08-11 17:40:29 +00:00
check(i == NR_DATA);
2020-08-11 17:38:42 +00:00
return 0;
}