root / tests / cris / check_int64.c @ 7296abac
History | View | Annotate | Download (584 Bytes)
1 | dd43edf4 | ths | #include <stdio.h> |
---|---|---|---|
2 | dd43edf4 | ths | #include <stdlib.h> |
3 | dd43edf4 | ths | #include <stdint.h> |
4 | dd43edf4 | ths | #include "sys.h" |
5 | dd43edf4 | ths | #include "crisutils.h" |
6 | dd43edf4 | ths | |
7 | dd43edf4 | ths | |
8 | dd43edf4 | ths | extern inline int64_t add64(const int64_t a, const int64_t b) { |
9 | dd43edf4 | ths | return a + b;
|
10 | dd43edf4 | ths | } |
11 | dd43edf4 | ths | |
12 | dd43edf4 | ths | extern inline int64_t sub64(const int64_t a, const int64_t b) { |
13 | dd43edf4 | ths | return a - b;
|
14 | dd43edf4 | ths | } |
15 | dd43edf4 | ths | |
16 | dd43edf4 | ths | int main(void) |
17 | dd43edf4 | ths | { |
18 | dd43edf4 | ths | int64_t a = 1;
|
19 | dd43edf4 | ths | int64_t b = 2;
|
20 | dd43edf4 | ths | |
21 | dd43edf4 | ths | /* FIXME: add some tests. */
|
22 | dd43edf4 | ths | a = add64(a, b); |
23 | dd43edf4 | ths | if (a != 3) |
24 | dd43edf4 | ths | err(); |
25 | dd43edf4 | ths | |
26 | dd43edf4 | ths | a = sub64(a, b); |
27 | dd43edf4 | ths | if (a != 1) |
28 | dd43edf4 | ths | err(); |
29 | dd43edf4 | ths | |
30 | dd43edf4 | ths | a = add64(a, -4);
|
31 | dd43edf4 | ths | if (a != -3) |
32 | dd43edf4 | ths | err(); |
33 | dd43edf4 | ths | |
34 | dd43edf4 | ths | a = add64(a, 3);
|
35 | dd43edf4 | ths | if (a != 0) |
36 | dd43edf4 | ths | err(); |
37 | dd43edf4 | ths | |
38 | dd43edf4 | ths | a = 0;
|
39 | dd43edf4 | ths | a = sub64(a, 1);
|
40 | dd43edf4 | ths | if (a != -1) |
41 | dd43edf4 | ths | err(); |
42 | dd43edf4 | ths | |
43 | dd43edf4 | ths | pass(); |
44 | dd43edf4 | ths | return 0; |
45 | dd43edf4 | ths | } |