62 #define TEST_SUCCESS 0  
   63 #define TEST_FAILURE 1  
   64 #define MESSAGE_OK "OK"  
   65 #define TEST_PASS_FLAG "\x1B[92m[PASS]\x1B[39m "  
   66 #define TEST_FAIL_FLAG "\x1B[31m<FAIL>\x1B[39m "  
   67 #define TEST_MESSAGE_BUFF_SIZE 500 
   68 #define TEST_ERROR_MESSAGE_SIZE 100 
   72 #define FAIL_WITH_MESSAGE(str, message)\ 
   73         *str = (char*)(message);\ 
   77 #define ASSERT_TRUE_OR_FAIL(p, str, message)\ 
   78     number_of_assertions++;\ 
   80         FAIL_WITH_MESSAGE((str), (message));\ 
   86 #define ASSERT_EQUAL_INT_OR_FAIL(val, expected, str, message)\ 
   87         number_of_assertions++;\ 
   88         if (!scs_assert_equals_int((val),(expected))) { \ 
   90            char buff[TEST_MESSAGE_BUFF_SIZE];\ 
   91            char error_msg[TEST_ERROR_MESSAGE_SIZE];\ 
   92            sprintf(error_msg, "\n\tExpected: %d, Actual %d", expected, val);\ 
   93            strncpy(buff, message, TEST_ERROR_MESSAGE_SIZE);\ 
   94            strncat(buff, error_msg, TEST_ERROR_MESSAGE_SIZE);\ 
   95            FAIL_WITH_MESSAGE((str), (buff)); \ 
  102 #define ASSERT_EQUAL_FLOAT_OR_FAIL(val, expected, tol, str, message)\ 
  103         number_of_assertions++;\ 
  104         if (!scs_assert_equals_float((val), (expected), (tol))) {\ 
  105            char buff[TEST_MESSAGE_BUFF_SIZE];\ 
  106            char error_msg[TEST_ERROR_MESSAGE_SIZE];\ 
  107            sprintf(error_msg, "\n\tExpected: %g, Actual %g (tol=%g)", expected, val, tol);\ 
  108            strncpy(buff, message, TEST_ERROR_MESSAGE_SIZE);\ 
  109            strncat(buff, error_msg, TEST_ERROR_MESSAGE_SIZE);\ 
  110            FAIL_WITH_MESSAGE((str), (buff)); \ 
  116 #define ASSERT_EQUAL_ARRAY_OR_FAIL(val,expected,len,tol,str,message)\ 
  117     number_of_assertions++;\ 
  118     if (!scs_assert_equals_array((val),(expected),(len),(tol))){\ 
  119       FAIL_WITH_MESSAGE((str), (message));\ 
  125 #define ASSERT_EQUAL_ARRAY_INT_OR_FAIL(val,expected,len,str,message)\ 
  126     number_of_assertions++;\ 
  127     if (!scs_assert_equals_array_int((val),(expected),(len))){\ 
  128       FAIL_WITH_MESSAGE((str), (message));\ 
  134 #define SUCCEED(str)\ 
  135         *str = (char*) MESSAGE_OK;\ 
bool scs_test(const unitTest_t ut, const char *name)
 
bool(* unitTest_t)(char **)
Definition: unit_test_util.h:147
 
bool scs_assert_equals_array(const scs_float *a, const scs_float *b, scs_int n, const scs_float tol)
 
bool scs_assert_equals_float(const scs_float a, const scs_float b, const scs_float tol)
 
bool scs_assert_equals_array_int(const scs_int *a, const scs_int *b, scs_int n)
 
int scs_int
Definition: glbopts.h:96
 
int bool
Definition: unit_test_util.h:55
 
int number_of_assertions
Definition: unit_test_util.h:60
 
double scs_float
Definition: glbopts.h:100
 
bool scs_assert_equals_int(const scs_int a, const scs_int b)