* utest_assert - assert function * * @param value - assert value * @param file - file name * @param line - line number * @param func - function name * @param msg - assert message * * @return - RT_TRUE: assert success; RT_FALSE: assert failed */
| 442 | * @return - RT_TRUE: assert success; RT_FALSE: assert failed |
| 443 | */ |
| 444 | rt_bool_t utest_assert(int value, const char *file, int line, const char *func, const char *msg) |
| 445 | { |
| 446 | rt_bool_t rst = RT_FALSE; |
| 447 | |
| 448 | if (!(value)) |
| 449 | { |
| 450 | local_utest.error = UTEST_FAILED; |
| 451 | local_utest.failed_num ++; |
| 452 | LOG_E("[ ASSERT ] [ unit ] at (%s); func: (%s:%d); msg: (%s)", file_basename(file), func, line, msg); |
| 453 | rst = RT_FALSE; |
| 454 | } |
| 455 | else |
| 456 | { |
| 457 | if (utest_log_lv == UTEST_LOG_ALL) |
| 458 | { |
| 459 | LOG_D("[ OK ] [ unit ] (%s:%d) is passed", func, line); |
| 460 | } |
| 461 | local_utest.error = UTEST_PASSED; |
| 462 | local_utest.passed_num ++; |
| 463 | rst = RT_TRUE; |
| 464 | } |
| 465 | |
| 466 | return rst; |
| 467 | } |
| 468 | |
| 469 | void utest_assert_string(const char *a, const char *b, rt_bool_t equal, const char *file, int line, const char *func, const char *msg) |
| 470 | { |
no test coverage detected