Mercurial > pub > dyncall > dyncall
comparison test/suite_x86win32fast/main.cc @ 410:7608e34098b0
- cleanups, simplifications, some api clarification, ...
- test cases consistency:
* return status code depending on test results (for actual conformance tests, not stuff that is not an example or hack to check something, ..)
* platform init helper added for some
author | Tassilo Philipp |
---|---|
date | Tue, 05 Oct 2021 21:53:04 +0200 |
parents | f5577f6bf97a |
children | d73dc7ad37e4 |
comparison
equal
deleted
inserted
replaced
409:15698dc0cba3 | 410:7608e34098b0 |
---|---|
1 /* | 1 /* |
2 | 2 |
3 Package: dyncall | 3 Package: dyncall |
4 Library: test | 4 Library: test |
5 File: test/suite_x86win32fast/main.cc | 5 File: test/suite_x86win32fast/main.cc |
6 Description: | 6 Description: |
7 License: | 7 License: |
8 | 8 |
9 Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>, | 9 Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>, |
10 Tassilo Philipp <tphilipp@potion-studios.com> | 10 Tassilo Philipp <tphilipp@potion-studios.com> |
11 | 11 |
12 Permission to use, copy, modify, and distribute this software for any | 12 Permission to use, copy, modify, and distribute this software for any |
13 purpose with or without fee is hereby granted, provided that the above | 13 purpose with or without fee is hereby granted, provided that the above |
14 copyright notice and this permission notice appear in all copies. | 14 copyright notice and this permission notice appear in all copies. |
78 valueInt[i] = DCint(i); | 78 valueInt[i] = DCint(i); |
79 valueLongLong[i] = DClonglong(i); | 79 valueLongLong[i] = DClonglong(i); |
80 valueDouble[i] = DCdouble(i); | 80 valueDouble[i] = DCdouble(i); |
81 valuePointer[i] = DCpointer(i); | 81 valuePointer[i] = DCpointer(i); |
82 valueFloat[i] = DCfloat(i); | 82 valueFloat[i] = DCfloat(i); |
83 } | 83 } |
84 } | 84 } |
85 | 85 |
86 | 86 |
87 void push(DCCallVM* pCall, int select, int pos) | 87 void push(DCCallVM* pCall, int select, int pos) |
88 { | 88 { |
89 switch(select) | 89 switch(select) |
90 { | 90 { |
91 case 0: dcArgBool( pCall, valueBool[pos] ); break; | 91 case 0: dcArgBool( pCall, valueBool[pos] ); break; |
92 case 1: dcArgInt( pCall, valueInt[pos] ); break; | 92 case 1: dcArgInt( pCall, valueInt[pos] ); break; |
93 case 2: dcArgLongLong( pCall, valueLongLong[pos] ); break; | 93 case 2: dcArgLongLong( pCall, valueLongLong[pos] ); break; |
94 case 3: dcArgDouble( pCall, valueDouble[pos] ); break; | 94 case 3: dcArgDouble( pCall, valueDouble[pos] ); break; |
96 case 5: dcArgFloat( pCall, valueFloat[pos] ); break; | 96 case 5: dcArgFloat( pCall, valueFloat[pos] ); break; |
97 } | 97 } |
98 } | 98 } |
99 | 99 |
100 | 100 |
101 #define assert(x) if (!(x)) return false | 101 #define test(x) if (!(x)) return false |
102 | 102 |
103 | 103 |
104 bool test(int x) | 104 bool test(int x) |
105 { | 105 { |
106 clearValues(); | 106 clearValues(); |
114 dcReset(pCall); | 114 dcReset(pCall); |
115 | 115 |
116 int y = x; | 116 int y = x; |
117 int selects[NARGS] = { 0, }; | 117 int selects[NARGS] = { 0, }; |
118 int pos = 0; | 118 int pos = 0; |
119 for(pos = 0;y>0;++pos) | 119 for(pos = 0;y>0;++pos) |
120 { | 120 { |
121 int select = (y-1) % NTYPES; | 121 int select = (y-1) % NTYPES; |
122 selects[pos] = select; | 122 selects[pos] = select; |
123 push(pCall,select,pos); | 123 push(pCall,select,pos); |
124 y = (y-1) / NTYPES; | 124 y = (y-1) / NTYPES; |
125 } | 125 } |
126 dcCallVoid(pCall,getFunc(x)); | 126 dcCallVoid(pCall,getFunc(x)); |
127 | 127 |
128 assert( getId() == x ); | 128 test( getId() == x ); |
129 | 129 |
130 for(int i = 0;i<pos;++i) { | 130 for(int i = 0;i<pos;++i) { |
131 assert( equals( selects[i], i, getArg(i) ) ); | 131 test( equals( selects[i], i, getArg(i) ) ); |
132 } | 132 } |
133 | 133 |
134 dcFree(pCall); | 134 dcFree(pCall); |
135 return true; | 135 return true; |
136 } | 136 } |
137 | 137 |
138 | 138 |
165 | 165 |
166 bool success = false; | 166 bool success = false; |
167 init(); | 167 init(); |
168 if (argc == 2) { | 168 if (argc == 2) { |
169 int index = atoi(argv[1]); | 169 int index = atoi(argv[1]); |
170 success = run_range( index, index+1 ); | 170 success = run_range( index, index+1 ); |
171 } else if (argc == 3) { | 171 } else if (argc == 3) { |
172 int from = atoi(argv[1]); | 172 int from = atoi(argv[1]); |
173 int to = atoi(argv[2])+1; | 173 int to = atoi(argv[2])+1; |
174 success = run_range(from,to); | 174 success = run_range(from,to); |
175 } else { | 175 } else { |
176 int ncalls = powerfact(NTYPES,NARGS)+1; | 176 int ncalls = powerfact(NTYPES,NARGS)+1; |
177 success = run_range(0,ncalls); | 177 success = run_range(0,ncalls); |
178 } | 178 } |
179 | 179 |
180 printf("result: suite_x86win32fast: %s\n", success ? "1" : "0"); | 180 printf("result: suite_x86win32fast: %d\n", success); |
181 | 181 |
182 dcTest_deInitPlatform(); | 182 dcTest_deInitPlatform(); |
183 | 183 |
184 return (success) ? 0 : -1; | 184 return !success; |
185 } | 185 } |
186 | 186 |
187 } // extern "C" | 187 } // extern "C" |
188 | 188 |