Added more tests
[fw/sdcc] / support / regression / tests / args.c
1 /** Tests argument passing to functions.
2     Assumes that up to the first two arguments can be passed in registers.
3
4     type1: char, int
5     type2: char, int
6     type3: char, int
7  */
8 #include <testfwk.h>
9
10 static {type1}
11 returnFirstArg({type1} arg1, {type2} arg2, {type3} arg3)
12 {
13     return arg1;
14 }
15
16 static {type2}
17 returnSecondArg({type1} arg1, {type2} arg2, {type3} arg3)
18 {
19     return arg2;
20 }
21
22 static {type3}
23 returnThirdArg({type1} arg1, {type2} arg2, {type3} arg3)
24 {
25     return arg3;
26 }
27
28 static void
29 testArgs(void)
30 {
31     ASSERT(returnFirstArg(123, 45, 67) == 123);
32     ASSERT(returnFirstArg(-123, 45, 67) == -123);
33
34     ASSERT(returnSecondArg(1, -23, 64) == -23);
35     ASSERT(returnSecondArg(1, 8, 64) == 8);
36
37     ASSERT(returnThirdArg(-33, -34, -35) == -35);
38     ASSERT(returnThirdArg(-33, -34, 35) == 35);
39 }