-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8c762b4
commit 627bc40
Showing
8 changed files
with
434 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include <rtthread.h> | ||
#include "utest.h" | ||
|
||
static void TC_uassert_true_false(void) | ||
{ | ||
uassert_true(1); | ||
uassert_false(0); | ||
} | ||
|
||
static void TC_uassert_null_not_null(void) | ||
{ | ||
int *ptr = RT_NULL; | ||
int value = 10; | ||
int *ptr2 = &value; | ||
|
||
uassert_null(ptr); | ||
uassert_not_null(ptr2); | ||
} | ||
|
||
static void TC_uassert_int_op(void) | ||
{ | ||
int a = 5; | ||
int b = 10; | ||
|
||
uassert_int_equal(a, a); | ||
uassert_int_not_equal(a, b); | ||
uassert_int_less(a, b); | ||
uassert_int_less_equal(a, b); | ||
uassert_int_less_equal(a, a); | ||
uassert_int_greater(b, a); | ||
uassert_int_greater_equal(b, a); | ||
uassert_int_greater_equal(b, b); | ||
} | ||
|
||
static void TC_uassert_ptr_op(void) | ||
{ | ||
int a = 5; | ||
int b = 10; | ||
int *ptr_a = &a; | ||
int *ptr_b = &b; | ||
|
||
uassert_ptr_equal(ptr_a, ptr_a); | ||
uassert_ptr_not_equal(ptr_a, ptr_b); | ||
} | ||
|
||
static void TC_uassert_str_op(void) | ||
{ | ||
const char *str1 = "Hello"; | ||
const char *str2 = "Hello"; | ||
const char *str3 = "World"; | ||
|
||
uassert_str_equal(str1, str2); | ||
uassert_str_not_equal(str1, str3); | ||
} | ||
|
||
static void TC_uassert_in_range(void) | ||
{ | ||
int value = 5; | ||
uassert_in_range(value, 1, 10); | ||
uassert_not_in_range(value, 10, 20); | ||
} | ||
|
||
static void utest_do_tc(void) | ||
{ | ||
UTEST_UNIT_RUN(TC_uassert_true_false); | ||
UTEST_UNIT_RUN(TC_uassert_null_not_null); | ||
UTEST_UNIT_RUN(TC_uassert_int_op); | ||
UTEST_UNIT_RUN(TC_uassert_ptr_op); | ||
UTEST_UNIT_RUN(TC_uassert_str_op); | ||
UTEST_UNIT_RUN(TC_uassert_in_range); | ||
} | ||
|
||
UTEST_TC_EXPORT(utest_do_tc, "utest.uassert", RT_NULL, RT_NULL, 10); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.