Mercurial > pub > dyncall > dyncall
comparison test/suite2/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 | 0f40e13a2f0a |
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/suite2/main.cc | 5 File: test/suite2/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. |
86 | 86 |
87 const DCsigchar* sig = &fi->sig[2]; | 87 const DCsigchar* sig = &fi->sig[2]; |
88 const DCsigchar* ptr = sig; | 88 const DCsigchar* ptr = sig; |
89 DCsigchar ch; | 89 DCsigchar ch; |
90 int pos; | 90 int pos; |
91 | 91 |
92 pos = 0; | 92 pos = 0; |
93 | 93 |
94 pCall = dcNewCallVM(4096); | 94 pCall = dcNewCallVM(4096); |
95 dcReset(pCall); | 95 dcReset(pCall); |
96 | 96 |
97 while ( (ch=*ptr++) != '\0' ) { | 97 while ( (ch=*ptr++) != '\0' ) { |
98 switch(ch) { | 98 switch(ch) { |
99 case DC_SIGCHAR_BOOL: dcArgBool ( pCall, valueBool [pos] ); break; | 99 case DC_SIGCHAR_BOOL: dcArgBool ( pCall, valueBool [pos] ); break; |
100 case DC_SIGCHAR_CHAR: dcArgChar ( pCall, valueChar [pos] ); break; | 100 case DC_SIGCHAR_CHAR: dcArgChar ( pCall, valueChar [pos] ); break; |
101 case DC_SIGCHAR_SHORT: dcArgShort ( pCall, valueShort [pos] ); break; | 101 case DC_SIGCHAR_SHORT: dcArgShort ( pCall, valueShort [pos] ); break; |
109 ++pos; | 109 ++pos; |
110 } | 110 } |
111 | 111 |
112 dcCallVoid( pCall, fi->funcptr ); | 112 dcCallVoid( pCall, fi->funcptr ); |
113 | 113 |
114 | 114 |
115 if ( getId() == x ) { | 115 if ( getId() == x ) { |
116 | 116 |
117 ptr = sig; | 117 ptr = sig; |
118 pos = 0; | 118 pos = 0; |
119 while( ( ch=*ptr++ ) != '\0' ) { | 119 while( ( ch=*ptr++ ) != '\0' ) { |
120 | 120 |
135 } else { | 135 } else { |
136 r = false; | 136 r = false; |
137 } | 137 } |
138 | 138 |
139 printf("%d-%s:%d\n", x, sig, r); | 139 printf("%d-%s:%d\n", x, sig, r); |
140 | 140 |
141 dcFree(pCall); | 141 dcFree(pCall); |
142 | 142 |
143 return r; | 143 return r; |
144 } | 144 } |
145 | 145 |
160 | 160 |
161 bool success = false; | 161 bool success = false; |
162 init(); | 162 init(); |
163 if (argc == 2) { | 163 if (argc == 2) { |
164 int index = atoi(argv[1]); | 164 int index = atoi(argv[1]); |
165 success = run_range( index, index+1 ); | 165 success = run_range( index, index+1 ); |
166 } else if (argc == 3) { | 166 } else if (argc == 3) { |
167 int from = atoi(argv[1]); | 167 int from = atoi(argv[1]); |
168 int to = atoi(argv[2])+1; | 168 int to = atoi(argv[2])+1; |
169 success = run_range(from,to); | 169 success = run_range(from,to); |
170 } else { | 170 } else { |
171 success = run_range(0,NCASES); | 171 success = run_range(0,NCASES); |
172 } | 172 } |
173 | 173 |
174 printf("result: suite2: %s\n", success ? "1" : "0"); | 174 printf("result: suite2: %d\n", success); |
175 | 175 |
176 dcTest_deInitPlatform(); | 176 dcTest_deInitPlatform(); |
177 | 177 |
178 return (success) ? 0 : -1; | 178 return !success; |
179 } | 179 } |
180 | 180 |
181 } // extern "C" | 181 } // extern "C" |
182 | 182 |