diff options
Diffstat (limited to 'tests/function_basics.c')
| -rw-r--r-- | tests/function_basics.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/function_basics.c b/tests/function_basics.c index 1d79ad7..83fb66e 100644 --- a/tests/function_basics.c +++ b/tests/function_basics.c @@ -71,6 +71,31 @@ char* f8(char* buf, int a, int b, int c, int d, int e, int f, int g, int h, int return buf; } +typedef struct { + long x, y; +} S; + +int f9(int select, int a, int b, int c, int d, S e, int f, int g) { + switch (select) { + case 0: + return a; + case 1: + return b; + case 2: + return c; + case 3: + return d; + case 4: + return e.x; + case 5: + return e.y; + case 6: + return f; + case 7: + return g; + } +} + int main() { ASSERT_EQ(66, foo()); ASSERT_EQ(10, 10 * f(1, 2, 3, 4, 5, 6)); @@ -89,4 +114,16 @@ int main() { char buf[100]; ASSERT_EQ(0, strcmp("1,2,3,4,5,6,7,8,9,10", f8(buf, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10))); + + S s; + s.x = 5; + s.y = 6; + ASSERT_EQ(1, f9(0, 1, 2, 3, 4, s, 7, 8)); + ASSERT_EQ(2, f9(1, 1, 2, 3, 4, s, 7, 8)); + ASSERT_EQ(3, f9(2, 1, 2, 3, 4, s, 7, 8)); + ASSERT_EQ(4, f9(3, 1, 2, 3, 4, s, 7, 8)); + ASSERT_EQ(5, f9(4, 1, 2, 3, 4, s, 7, 8)); + ASSERT_EQ(6, f9(5, 1, 2, 3, 4, s, 7, 8)); + ASSERT_EQ(7, f9(6, 1, 2, 3, 4, s, 7, 8)); + ASSERT_EQ(8, f9(7, 1, 2, 3, 4, s, 7, 8)); } |
