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