History

add test for abitest.c

jiang committed 12 years ago

Commit 4b505571 parent 2ac238f1 file · +53 −5Browse files

Unified · Split

tests/abitest.c+53−5
@@ -88,7 +88,7 @@ static int ret_2float_test_callback(void *ptr) { · 87 unmodified lines
8888 ret_2float_test_type a = {10, 35};
8989 ret_2float_test_type r;
9090 r = f(a);
91− return ((r.x == a.x*5) && (r.y == a.y*3)) ? 0 : -1;
91+ return ((r.x == a.x*5) && (r.y == a.y*3) && (f(a).x == a.x*5) && (f(a).y == a.y*3)) ? 0 : -1;
9292 }
9393
9494 static int ret_2float_test(void) {
@@ -116,7 +116,7 @@ static int ret_2double_test_callback(void *ptr) { · 21 unmodified lines
116116 ret_2double_test_type a = {10, 35};
117117 ret_2double_test_type r;
118118 r = f(a);
119− return ((r.x == a.x*5) && (r.y == a.y*3)) ? 0 : -1;
119+ return ((r.x == a.x*5) && (r.y == a.y*3) && (f(a).x == a.x*5) && (f(a).y == a.y*3)) ? 0 : -1;
120120 }
121121
122122 static int ret_2double_test(void) {
@@ -130,6 +130,52 @@ static int ret_2double_test(void) { · 7 unmodified lines
130130 return run_callback(src, ret_2double_test_callback);
131131 }
132132
133+typedef struct ret_longdouble_test_type_s2 {LONG_DOUBLE x;} ret_longdouble_test_type;
134+typedef ret_longdouble_test_type (*ret_longdouble_test_function_type) (ret_longdouble_test_type);
135+
136+static int ret_longdouble_test_callback2(void *ptr) {
137+ ret_longdouble_test_function_type f = (ret_longdouble_test_function_type)ptr;
138+ ret_longdouble_test_type a = {10};
139+ ret_longdouble_test_type r;
140+ r = f(a);
141+ printf("%Lf \n", a.x);
142+ printf("%Lf \n", r.x);
143+ return ((r.x == a.x*5) && (f(a).x == a.x*5)) ? 0 : -1;
144+}
145+
146+static int ret_longdouble_test2(void) {
147+ const char *src =
148+ "typedef struct ret_longdouble_test_type_s2 {long double x;} ret_longdouble_test_type;"
149+ "ret_longdouble_test_type f(ret_longdouble_test_type a) {\n"
150+ " ret_longdouble_test_type r = {a.x*5};\n"
151+ " return r;\n"
152+ "}\n";
153+
154+ return run_callback(src, ret_longdouble_test_callback2);
155+}
156+
157+typedef struct ret_longlong_test_type_s2 {int x[4];} ret_longlong_test_type;
158+typedef ret_longlong_test_type (*ret_longlong_test_function_type) (ret_longlong_test_type);
159+
160+static int ret_longlong_test_callback2(void *ptr) {
161+ ret_longlong_test_function_type f = (ret_longlong_test_function_type)ptr;
162+ ret_longlong_test_type a = {{10,11,12,13}};
163+ ret_longlong_test_type r;
164+ r = f(a);
165+ return ((r.x[2] == a.x[2]*5) && (f(a).x[2] == a.x[2]*5)) ? 0 : -1;
166+}
167+
168+static int ret_longlong_test2(void) {
169+ const char *src =
170+ "typedef struct ret_longlong_test_type_s2 {int x[4];} ret_longlong_test_type;"
171+ "ret_longlong_test_type f(ret_longlong_test_type a) {\n"
172+ " ret_longlong_test_type r = {.x[2] = a.x[2]*5};\n"
173+ " return r;\n"
174+ "}\n";
175+
176+ return run_callback(src, ret_longlong_test_callback2);
177+}
178+
133179 /*
134180 * reg_pack_test: return a small struct which should be packed into
135181 * registers (Win32) during return.
@@ -142,7 +188,7 @@ static int reg_pack_test_callback(void *ptr) { · 6 unmodified lines
142188 reg_pack_test_type a = {10, 35};
143189 reg_pack_test_type r;
144190 r = f(a);
145− return ((r.x == a.x*5) && (r.y == a.y*3)) ? 0 : -1;
191+ return ((r.x == a.x*5) && (r.y == a.y*3) && (f(a).x == a.x*5) && (f(a).y == a.y*3)) ? 0 : -1;
146192 }
147193
148194 static int reg_pack_test(void) {
@@ -168,7 +214,7 @@ static int reg_pack_longlong_test_callback(void *ptr) { · 19 unmodified lines
168214 reg_pack_longlong_test_type a = {10, 35};
169215 reg_pack_longlong_test_type r;
170216 r = f(a);
171− return ((r.x == a.x*5) && (r.y == a.y*3)) ? 0 : -1;
217+ return ((r.x == a.x*5) && (r.y == a.y*3) && (f(a).x == a.x*5) && (f(a).y == a.y*3)) ? 0 : -1;
172218 }
173219
174220 static int reg_pack_longlong_test(void) {
@@ -248,7 +294,7 @@ static int two_member_union_test_callback(void *ptr) { · 73 unmodified lines
248294 two_member_union_test_type a, b;
249295 a.x = 34;
250296 b = f(a);
251− return (b.x == a.x*2) ? 0 : -1;
297+ return ((b.x == a.x*2) && (f(a).x == a.x*2)) ? 0 : -1;
252298 }
253299
254300 static int two_member_union_test(void) {
@@ -441,6 +487,8 @@ int main(int argc, char **argv) { · 186 unmodified lines
441487 RUN_TEST(ret_longdouble_test);
442488 RUN_TEST(ret_2float_test);
443489 RUN_TEST(ret_2double_test);
490+ RUN_TEST(ret_longlong_test2);
491+ RUN_TEST(ret_longdouble_test2);
444492 RUN_TEST(reg_pack_test);
445493 RUN_TEST(reg_pack_longlong_test);
446494 RUN_TEST(sret_test);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t