1 #include "test_ccapi_check.h"
2
_check_if(int expression,const char * file,int line,const char * expression_string,const char * format,...)3 int _check_if(int expression, const char *file, int line, const char *expression_string, const char *format, ...) {
4 if (expression) {
5 failure_count++;
6 // call with NULL format to get a generic error message
7 if (format == NULL) {
8 _log_error(file, line, expression_string);
9 }
10 // call with format and varargs for a more useful error message
11 else {
12 va_list ap;
13 va_start(ap, format);
14 _log_error_v(file, line, format, ap);
15 va_end(ap);
16 }
17
18 if (current_test_activity) {
19 fprintf(stdout, " (%s)", current_test_activity);
20 }
21 }
22
23 return (expression != 0);
24 }
25
array_contains_int(cc_int32 * array,int size,cc_int32 value)26 int array_contains_int(cc_int32 *array, int size, cc_int32 value) {
27 if (array != NULL && size > 0) {
28 int i = 0;
29 while (i < size && array[i] != value) {
30 i++;
31 }
32 if (i < size) {
33 return 1;
34 }
35 }
36 return 0;
37 }
38