Skip to content
Newer
Older
100644 77 lines (67 sloc) 1.68 KB
41aaf3d @jnthn Various tests related to passing integer arguments.
authored Jan 13, 2012
1 #include <stdio.h>
2
3 #ifdef WIN32
4 #define DLLEXPORT __declspec(dllexport)
5 #else
6 #define DLLEXPORT extern
7 #endif
8
9 DLLEXPORT void TakeInt(int x)
10 {
11 if (x == 42)
12 printf("ok 1 - got passed int 42\n", x);
13 else
14 printf("not ok 1 - got passed int 42\n", x);
15 fflush(stdout);
16 }
17
18 DLLEXPORT void TakeTwoShorts(short x, short y)
19 {
20 if (x == 10)
21 printf("ok 2 - got passed short 10\n", x);
22 else
23 printf("not ok 2 - got passed short 10\n", x);
24 if (y == 20)
25 printf("ok 3 - got passed short 20\n", x);
26 else
27 printf("not ok 3 - got passed short 20\n", x);
28 fflush(stdout);
29 }
30
31 DLLEXPORT void AssortedIntArgs(int x, short y, char z)
32 {
33 if (x == 101)
34 printf("ok 4 - got passed int 101\n", x);
35 else
36 printf("not ok 4 - got passed int 101\n", x);
37 if (y == 102)
38 printf("ok 5 - got passed short 102\n", x);
39 else
40 printf("not ok 5 - got passed short 102\n", x);
41 if (z == 103)
42 printf("ok 6 - got passed char 103\n", x);
43 else
44 printf("not ok 6 - got passed char 103\n", x);
45 fflush(stdout);
46 }
bee23d5 @jnthn Test file 2 will just be for args; add tests for float, double and st…
authored Jan 13, 2012
47
48 DLLEXPORT void TakeADouble(double x)
49 {
50 if (-6.9 - x < 0.001)
51 printf("ok 7 - got passed double -6.9\n", x);
52 else
53 printf("not ok 7 - got passed double -6.9\n", x);
54 }
55
56 DLLEXPORT void TakeAFloat(float x)
57 {
58 if (4.2 - x < 0.001)
59 printf("ok 8 - got passed float 4.2\n", x);
60 else
61 printf("not ok 8 - got passed float 4.2\n", x);
62 }
63
64 DLLEXPORT void TakeAString(char *pass_msg)
65 {
66 printf("%s\n", pass_msg);
67 }
68
e94f45c @arnsholt Tests and support functions for explicitly managing strings.
arnsholt authored May 1, 2012
69 static char *cached_str = NULL;
70 DLLEXPORT void SetString(char *str) {
71 cached_str = str;
72 }
bee23d5 @jnthn Test file 2 will just be for args; add tests for float, double and st…
authored Jan 13, 2012
73
e94f45c @arnsholt Tests and support functions for explicitly managing strings.
arnsholt authored May 1, 2012
74 DLLEXPORT void PrintString() {
75 printf("%s\n", cached_str);
76 }
Something went wrong with that request. Please try again.