From 6c6fddb9a3cbcd3f2f50f8f8093397f368a9da3b Mon Sep 17 00:00:00 2001 From: yinjiaming Date: Mon, 20 Mar 2023 20:11:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E7=BB=9F=E4=B8=80M=E6=A0=B8unittest=20?= =?UTF-8?q?=E5=92=8C=20sample=E6=89=80=E4=BD=BF=E7=94=A8=E7=9A=84=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E6=A1=86=E6=9E=B6=20liteos=5Fm=20=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E5=A5=97=E4=B8=AD=20unittest=20=E5=92=8C=20sample=20=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E6=89=80=E4=BD=BF=E7=94=A8=E7=9A=84=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E6=A1=86=E6=9E=B6=E4=B8=8D=E5=90=8C=EF=BC=8C=20=E7=8E=B0?= =?UTF-8?q?=E5=B0=86=E5=85=B6=E7=BB=9F=E4=B8=80=EF=BC=8C=E4=BE=BF=E4=BA=8E?= =?UTF-8?q?=E7=BB=B4=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yinjiaming Change-Id: I4b690b621d754725c4d6a93772a043140de0bce1 --- .../posix/src/ctype/ctype_func_test.c | 52 +-- .../unittest/posix/src/ctype/isdigit_test.c | 13 +- .../unittest/posix/src/ctype/islower_test.c | 14 +- .../unittest/posix/src/ctype/isxdigit_test.c | 22 +- .../unittest/posix/src/ctype/tolower_test.c | 12 +- .../unittest/posix/src/ctype/toupper_test.c | 12 +- .../unittest/posix/src/errno/strerror_test.c | 18 +- .../posix/src/fs/posix_fs_func_test.c | 427 +++++++++--------- .../unittest/posix/src/math/math_func_test.c | 18 +- testsuites/unittest/posix/src/posix_test.h | 26 +- .../posix/src/regex/regex_func_test.c | 8 +- .../posix/src/semaphore/semaphore_func_test.c | 52 +-- .../posix/src/stdarg/stdarg_func_test.c | 14 +- .../unittest/posix/src/stdlib/atoi_test.c | 20 +- .../unittest/posix/src/stdlib/atol_test.c | 18 +- .../unittest/posix/src/stdlib/atoll_test.c | 18 +- .../unittest/posix/src/stdlib/strtol_test.c | 52 +-- .../unittest/posix/src/stdlib/strtoul_test.c | 40 +- .../unittest/posix/src/stdlib/strtoull_test.c | 42 +- .../posix/src/string/memory_func_test.c | 60 +-- .../unittest/posix/src/string/strchr_test.c | 12 +- .../posix/src/string/string_func_test_01.c | 48 +- .../posix/src/string/string_func_test_02.c | 10 +- .../posix/src/string/string_func_test_03.c | 44 +- .../unittest/posix/src/string/strstr_test.c | 26 +- .../posix/src/time/time_func_test_01.c | 116 ++--- 26 files changed, 577 insertions(+), 617 deletions(-) diff --git a/testsuites/unittest/posix/src/ctype/ctype_func_test.c b/testsuites/unittest/posix/src/ctype/ctype_func_test.c index 6e808b0b..7332f729 100644 --- a/testsuites/unittest/posix/src/ctype/ctype_func_test.c +++ b/testsuites/unittest/posix/src/ctype/ctype_func_test.c @@ -75,7 +75,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsalnum001, Function | MediumTe { int src = 'A'; int ret = isalnum(src); - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; } @@ -88,7 +88,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsalnum002, Function | MediumTe { int src = '1'; int ret = isalnum(src); - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; } @@ -101,7 +101,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsalnum003, Function | MediumTe { int src = '@'; int ret = isalnum(src); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -114,7 +114,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsalnum004, Function | MediumTe { int src = ' '; int ret = isalnum(src); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -127,7 +127,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsalnum005, Function | MediumTe { int src = '\f'; // 0x0c 14 int ret = isalnum(src); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -141,7 +141,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsascii001, Function | MediumTe { const int src = -1; int ret = isascii(src); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -154,7 +154,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsascii002, Function | MediumTe { const int src = 0; int ret = isascii(src); - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; } @@ -167,7 +167,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsascii003, Function | MediumTe { const int src = 127; int ret = isascii(src); - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; } @@ -180,7 +180,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsascii004, Function | MediumTe { const int src = 128; int ret = isascii(src); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -193,7 +193,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsascii005, Function | MediumTe { int src = '\f'; // 0x0c 14 int ret = isascii(src); - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; } @@ -206,7 +206,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsprint001, Function | MediumTe { int src = 'A'; int ret = isprint(src); - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; } @@ -219,7 +219,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsprint002, Function | MediumTe { int src = '1'; int ret = isprint(src); - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; } @@ -232,7 +232,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsprint003, Function | MediumTe { int src = '@'; int ret = isprint(src); - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; } @@ -245,7 +245,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsprint004, Function | MediumTe { int src = ' '; int ret = isprint(src); - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; } @@ -258,7 +258,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsprint005, Function | MediumTe { int src = '\f'; // 0x0c int ret = isprint(src); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -272,7 +272,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsspace001, Function | MediumTe { int src = 'A'; int ret = isspace(src); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -285,7 +285,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsspace002, Function | MediumTe { int src = '1'; int ret = isspace(src); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -298,7 +298,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsspace003, Function | MediumTe { int src = '@'; int ret = isspace(src); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -311,7 +311,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsspace004, Function | MediumTe { int src = ' '; int ret = isspace(src); - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; } @@ -324,7 +324,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsspace005, Function | MediumTe { int src = '\t'; int ret = isspace(src); - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; } @@ -338,7 +338,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsupper001, Function | MediumTe { int src = 'A'; int ret = isupper(src); - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; } @@ -351,7 +351,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsupper002, Function | MediumTe { int src = 'a'; int ret = isupper(src); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -364,7 +364,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsupper003, Function | MediumTe { const int src = 0x45; int ret = isupper(src); - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; } @@ -377,7 +377,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsupper004, Function | MediumTe { int src = ' '; int ret = isupper(src); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -390,12 +390,10 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsupper005, Function | MediumTe { int src = '\t'; int ret = isupper(src); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } -RUN_TEST_SUITE(PosixCtypeFuncTestSuite); - void PosixCtypeFuncTest() { LOG("begin PosixCtypeFuncTest...."); diff --git a/testsuites/unittest/posix/src/ctype/isdigit_test.c b/testsuites/unittest/posix/src/ctype/isdigit_test.c index a2291e59..d21dcd4b 100644 --- a/testsuites/unittest/posix/src/ctype/isdigit_test.c +++ b/testsuites/unittest/posix/src/ctype/isdigit_test.c @@ -79,7 +79,7 @@ LITE_TEST_CASE(PosixCTypeIsdigitTest, testCTypeIsdigit001, Function | MediumTest else { LOG("[DEMO] posix ctype test case 1:isdigit(%c) fail.\n", a); } - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; } @@ -98,7 +98,7 @@ LITE_TEST_CASE(PosixCTypeIsdigitTest, testCTypeIsdigit002, Function | MediumTest else { LOG("[DEMO] posix ctype test case 2:isdigit(%c) fail.\n", a); } - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; } @@ -117,7 +117,7 @@ LITE_TEST_CASE(PosixCTypeIsdigitTest, testCTypeIsdigit003, Function | MediumTest else { LOG("[DEMO] posix ctype test case 3:isdigit(%c) fail.\n", a); } - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; } @@ -136,7 +136,7 @@ LITE_TEST_CASE(PosixCTypeIsdigitTest, testCTypeIsdigit004, Function | MediumTest else { LOG("[DEMO] posix ctype test case 4(except):isdigit(%c) fail.\n", a); } - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -155,13 +155,10 @@ LITE_TEST_CASE(PosixCTypeIsdigitTest, testCTypeIsdigit005, Function | MediumTest else { LOG("[DEMO] posix ctype test case 5(except):isdigit(%c) fail.\n", a); } - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } -RUN_TEST_SUITE(PosixCTypeIsdigitTest); - - void PosixIsdigitFuncTest() { LOG("begin PosixIsdigitFuncTest...."); diff --git a/testsuites/unittest/posix/src/ctype/islower_test.c b/testsuites/unittest/posix/src/ctype/islower_test.c index 44605102..60e48783 100644 --- a/testsuites/unittest/posix/src/ctype/islower_test.c +++ b/testsuites/unittest/posix/src/ctype/islower_test.c @@ -78,7 +78,7 @@ LITE_TEST_CASE(PosixCTypeIslowerTest, testCTypeIslower001, Function | MediumTest } else { LOG("[DEMO] posix ctype test case 1:islower(%c) fail.\n", a); } - TEST_ASSERT_EQUAL_INT(1, ret); + ICUNIT_ASSERT_EQUAL(ret, 1, ret); return 0; } @@ -96,7 +96,7 @@ LITE_TEST_CASE(PosixCTypeIslowerTest, testCTypeIslower002, Function | MediumTest } else { LOG("[DEMO] posix ctype test case 2:islower(%c) fail.\n", a); } - TEST_ASSERT_EQUAL_INT(1, ret); + ICUNIT_ASSERT_EQUAL(ret, 1, ret); return 0; } @@ -114,7 +114,7 @@ LITE_TEST_CASE(PosixCTypeIslowerTest, testCTypeIslower003, Function | MediumTest } else { LOG("[DEMO] posix ctype test case 3:islower(%c) fail.\n", a); } - TEST_ASSERT_EQUAL_INT(1, ret); + ICUNIT_ASSERT_EQUAL(ret, 1, ret); return 0; } @@ -132,7 +132,7 @@ LITE_TEST_CASE(PosixCTypeIslowerTest, testCTypeIslower004, Function | MediumTest } else { LOG("[DEMO] posix ctype test case 4(except):islower(%c) fail.\n", a); } - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -150,7 +150,7 @@ LITE_TEST_CASE(PosixCTypeIslowerTest, testCTypeIslower005, Function | MediumTest } else { LOG("[DEMO] posix ctype test case 5(except):islower(%c) fail.\n", a); } - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -168,12 +168,10 @@ LITE_TEST_CASE(PosixCTypeIslowerTest, testCTypeIslower006, Function | MediumTest } else { LOG("[DEMO] posix ctype test case 6(except):islower(%c) fail.\n", a); } - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } -RUN_TEST_SUITE(PosixCTypeIslowerTest); - void PosixIslowerFuncTest() { LOG("begin PosixIslowerFuncTest...."); diff --git a/testsuites/unittest/posix/src/ctype/isxdigit_test.c b/testsuites/unittest/posix/src/ctype/isxdigit_test.c index 924973ea..af1b48c5 100644 --- a/testsuites/unittest/posix/src/ctype/isxdigit_test.c +++ b/testsuites/unittest/posix/src/ctype/isxdigit_test.c @@ -78,7 +78,7 @@ LITE_TEST_CASE(PosixCTypeIsxdigitTest, testCTypeIsxdigit001, Function | MediumTe } else { LOG("[DEMO] posix ctype test case 1:isxdigit(%c) fail.\n", a); } - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; } @@ -96,7 +96,7 @@ LITE_TEST_CASE(PosixCTypeIsxdigitTest, testCTypeIsxdigit002, Function | MediumTe } else { LOG("[DEMO] posix ctype test case 2:isxdigit(%c) fail.\n", a); } - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; } @@ -114,7 +114,7 @@ LITE_TEST_CASE(PosixCTypeIsxdigitTest, testCTypeIsxdigit003, Function | MediumTe } else { LOG("[DEMO] posix ctype test case 3:isxdigit(%c) fail.\n", a); } - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; } @@ -132,7 +132,7 @@ LITE_TEST_CASE(PosixCTypeIsxdigitTest, testCTypeIsxdigit004, Function | MediumTe } else { LOG("[DEMO] posix ctype test case 1:isxdigit(%c) fail.\n", a); } - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; } @@ -150,7 +150,7 @@ LITE_TEST_CASE(PosixCTypeIsxdigitTest, testCTypeIsxdigit005, Function | MediumTe } else { LOG("[DEMO] posix ctype test case 1:isxdigit(%c) fail.\n", a); } - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; } @@ -168,7 +168,7 @@ LITE_TEST_CASE(PosixCTypeIsxdigitTest, testCTypeIsxdigit006, Function | MediumTe } else { LOG("[DEMO] posix ctype test case 1:isxdigit(%c) fail.\n", a); } - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; } @@ -186,7 +186,7 @@ LITE_TEST_CASE(PosixCTypeIsxdigitTest, testCTypeIsxdigit007, Function | MediumTe } else { LOG("[DEMO] posix ctype test case 1:isxdigit(%c) fail.\n", a); } - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; } @@ -204,7 +204,7 @@ LITE_TEST_CASE(PosixCTypeIsxdigitTest, testCTypeIsxdigit008, Function | MediumTe } else { LOG("[DEMO] posix ctype test case 5(except):isxdigit(%c) fail.\n", a); } - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -222,7 +222,7 @@ LITE_TEST_CASE(PosixCTypeIsxdigitTest, testCTypeIsxdigit009, Function | MediumTe } else { LOG("[DEMO] posix ctype test case 4(except):isxdigit(%c) fail.\n", a); } - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -240,12 +240,10 @@ LITE_TEST_CASE(PosixCTypeIsxdigitTest, testCTypeIsxdigit010, Function | MediumTe } else { LOG("[DEMO] posix ctype test case 5(except):isxdigit(%c) fail.\n", a); } - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } -RUN_TEST_SUITE(PosixCTypeIsxdigitTest); - void PosixIsxdigitFuncTest() { LOG("begin PosixIsxdigitFuncTest...."); diff --git a/testsuites/unittest/posix/src/ctype/tolower_test.c b/testsuites/unittest/posix/src/ctype/tolower_test.c index a5037492..405c5a92 100644 --- a/testsuites/unittest/posix/src/ctype/tolower_test.c +++ b/testsuites/unittest/posix/src/ctype/tolower_test.c @@ -78,7 +78,7 @@ LITE_TEST_CASE(PosixCTypeTolowerTest, testCTypeTolower001, Function | MediumTest } else { LOG("[DEMO] posix ctype test case 1:tolower(%c)!=%c fail.\n", a, ret); } - TEST_ASSERT_TRUE(ret == 'a'); + ICUNIT_ASSERT_EQUAL(ret, 'a', ret); return 0; } @@ -96,7 +96,7 @@ LITE_TEST_CASE(PosixCTypeTolowerTest, testCTypeTolower002, Function | MediumTest } else { LOG("[DEMO] posix ctype test case 2:tolower(%c)!=%c fail.\n", a, ret); } - TEST_ASSERT_TRUE(ret == 'a'); + ICUNIT_ASSERT_EQUAL(ret, 'a', ret); return 0; } @@ -114,7 +114,7 @@ LITE_TEST_CASE(PosixCTypeTolowerTest, testCTypeTolower003, Function | MediumTest } else { LOG("[DEMO] posix ctype test case 3:tolower(%c)!=%c fail.\n", a, ret); } - TEST_ASSERT_TRUE(ret == 'z'); + ICUNIT_ASSERT_EQUAL(ret, 'z', ret); return 0; } @@ -132,7 +132,7 @@ LITE_TEST_CASE(PosixCTypeTolowerTest, testCTypeTolower004, Function | MediumTest } else { LOG("[DEMO] posix ctype test case 4:tolower(%c)!=%c fail.\n", a, ret); } - TEST_ASSERT_TRUE(ret == 'z'); + ICUNIT_ASSERT_EQUAL(ret, 'z', ret); return 0; } @@ -150,12 +150,10 @@ LITE_TEST_CASE(PosixCTypeTolowerTest, testCTypeTolower005, Function | MediumTest } else { LOG("[DEMO] posix ctype test case 5(except):tolower(%c)!=%c fail.\n", a, ret); } - TEST_ASSERT_TRUE(ret == '1'); + ICUNIT_ASSERT_EQUAL(ret, '1', ret); return 0; } -RUN_TEST_SUITE(PosixCTypeTolowerTest); - void PosixTolowerFuncTest() { LOG("begin PosixTolowerFuncTest...."); diff --git a/testsuites/unittest/posix/src/ctype/toupper_test.c b/testsuites/unittest/posix/src/ctype/toupper_test.c index 38da04b6..01952268 100644 --- a/testsuites/unittest/posix/src/ctype/toupper_test.c +++ b/testsuites/unittest/posix/src/ctype/toupper_test.c @@ -78,7 +78,7 @@ LITE_TEST_CASE(PosixCTypeToupperTest, testCTypeToupper001, Function | MediumTest } else { LOG("[DEMO] posix ctype test case 1:toupper(%c)!=%c fail.\n", a, ret); } - TEST_ASSERT_TRUE(ret == 'A'); + ICUNIT_ASSERT_EQUAL(ret, 'A', ret); return 0; } @@ -96,7 +96,7 @@ LITE_TEST_CASE(PosixCTypeToupperTest, testCTypeToupper002, Function | MediumTest } else { LOG("[DEMO] posix ctype test case 2:toupper(%c)!=%c fail.\n", a, ret); } - TEST_ASSERT_TRUE(ret == 'A'); + ICUNIT_ASSERT_EQUAL(ret, 'A', ret); return 0; } @@ -114,7 +114,7 @@ LITE_TEST_CASE(PosixCTypeToupperTest, testCTypeToupper003, Function | MediumTest } else { LOG("[DEMO] posix ctype test case 3:toupper(%c)!=%c fail.\n", a, ret); } - TEST_ASSERT_TRUE(ret == 'Z'); + ICUNIT_ASSERT_EQUAL(ret, 'Z', ret); return 0; } @@ -132,7 +132,7 @@ LITE_TEST_CASE(PosixCTypeToupperTest, testCTypeToupper004, Function | MediumTest } else { LOG("[DEMO] posix ctype test case 4:toupper(%c)!=%c fail.\n", a, ret); } - TEST_ASSERT_TRUE(ret == 'Z'); + ICUNIT_ASSERT_EQUAL(ret, 'Z', ret); return 0; } @@ -150,12 +150,10 @@ LITE_TEST_CASE(PosixCTypeToupperTest, testCTypeToupper005, Function | MediumTest } else { LOG("[DEMO] posix ctype test case 5(except):toupper(%c)!=%c fail.\n", a, ret); } - TEST_ASSERT_TRUE(ret == '1'); + ICUNIT_ASSERT_EQUAL(ret, '1', ret); return 0; } -RUN_TEST_SUITE(PosixCTypeToupperTest); - void PosixToupperFuncTest() { LOG("begin PosixToupperFuncTest...."); diff --git a/testsuites/unittest/posix/src/errno/strerror_test.c b/testsuites/unittest/posix/src/errno/strerror_test.c index ca3ae043..b46584a2 100644 --- a/testsuites/unittest/posix/src/errno/strerror_test.c +++ b/testsuites/unittest/posix/src/errno/strerror_test.c @@ -75,32 +75,30 @@ LITE_TEST_CASE(PosixSysFuncTestSuite, testOsSysStrerror001, Function | MediumTes #if (LOSCFG_LIBC_MUSL == 1) for (int i = EPERM; i < EHWPOISON; i++) { char *s = strerror(i); - TEST_ASSERT_NOT_NULL(s); + ICUNIT_ASSERT_NOT_EQUAL(s, NULL, s); } LOG("strerror(-1) = %s\n", strerror(-1)); - TEST_ASSERT_EQUAL_STRING("No error information", strerror(-1)); + ICUNIT_ASSERT_STRING_EQUAL(strerror(-1), "No error information", -1); LOG("strerror(0) = %s\n", strerror(0)); - TEST_ASSERT_EQUAL_STRING("No error information", strerror(0)); + ICUNIT_ASSERT_STRING_EQUAL(strerror(0), "No error information", 0); LOG("strerror(2) = %s\n", strerror(2)); - TEST_ASSERT_EQUAL_STRING("No such file or directory", strerror(2)); + ICUNIT_ASSERT_STRING_EQUAL(strerror(2), "No such file or directory", 2); LOG("strerror(10) = %s\n", strerror(10)); - TEST_ASSERT_EQUAL_STRING("No child process", strerror(10)); + ICUNIT_ASSERT_STRING_EQUAL(strerror(10), "No child process", 10); #endif #if (LOSCFG_LIBC_NEWLIB == 1) LOG("strerror(0) = %s\n", strerror(0)); - TEST_ASSERT_EQUAL_STRING("Success", strerror(0)); + ICUNIT_ASSERT_STRING_EQUAL(strerror(0), "Success", 0); LOG("strerror(2) = %s\n", strerror(2)); - TEST_ASSERT_EQUAL_STRING("No such file or directory", strerror(2)); + ICUNIT_ASSERT_STRING_EQUAL(strerror(2), "No such file or directory", 2); LOG("strerror(10) = %s\n", strerror(10)); - TEST_ASSERT_EQUAL_STRING("No children", strerror(10)); + ICUNIT_ASSERT_STRING_EQUAL(strerror(10), "No children", 10); #endif return LOS_OK; }; -RUN_TEST_SUITE(PosixSysFuncTestSuite); - void PosixStrerrorTest() { LOG("begin PosixStrerrorTest...."); diff --git a/testsuites/unittest/posix/src/fs/posix_fs_func_test.c b/testsuites/unittest/posix/src/fs/posix_fs_func_test.c index 69b9a470..8f973a81 100644 --- a/testsuites/unittest/posix/src/fs/posix_fs_func_test.c +++ b/testsuites/unittest/posix/src/fs/posix_fs_func_test.c @@ -72,10 +72,10 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFopenFclose001, Function | MediumTest int ret = 0; FILE *fp = NULL; fp = fopen(TEST_FILE_PTAH_RIGHT, "w"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fclose(fp); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -89,10 +89,10 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFopenFclose002, Function | MediumTest int ret = 0; FILE *fp = NULL; fp = fopen(TEST_FILE_PTAH_RIGHT, "w+"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fclose(fp); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -106,10 +106,10 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFopenFclose003, Function | MediumTest int ret = 0; FILE *fp = NULL; fp = fopen(TEST_FILE_PTAH_RIGHT, "r"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fclose(fp); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -123,10 +123,10 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFopenFclose004, Function | MediumTest int ret = 0; FILE *fp = NULL; fp = fopen(TEST_FILE_PTAH_RIGHT, "a"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fclose(fp); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -139,10 +139,10 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFopenFclose005, Function | MediumTest { FILE *fp = NULL; fp = fopen(TEST_FILE_PTAH_RIGHT, "c"); - TEST_ASSERT_NULL(fp); + ICUNIT_ASSERT_EQUAL(fp, NULL, 0); return 0; } - + /* * * @tc.number SUB_KERNEL_FS_FOPEN_FCLOSE_006 * @tc.name remove the path before fopen and fclose @@ -155,10 +155,10 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFopenFclose006, Function | MediumTest (void)remove(TEST_FILE_PTAH_RIGHT); fp = fopen(TEST_FILE_PTAH_RIGHT, "w"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fclose(fp); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -174,10 +174,10 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFopenFclose007, Function | MediumTest (void)remove(TEST_FILE_PTAH_RIGHT); fp = fopen(TEST_FILE_PTAH_RIGHT, "w+"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fclose(fp); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -193,10 +193,10 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFopenFclose008, Function | MediumTest (void)remove(TEST_FILE_PTAH_RIGHT); fp = fopen(TEST_FILE_PTAH_RIGHT, "a+"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fclose(fp); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -212,10 +212,10 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFopenFclose009, Function | MediumTest (void)remove(TEST_FILE_PTAH_RIGHT); fp = fopen(TEST_FILE_PTAH_RIGHT, "a"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fclose(fp); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -231,10 +231,10 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFopenFclose010, Function | MediumTest (void)remove(TEST_FILE_PTAH_RIGHT); fp = fopen(TEST_FILE_PTAH_RIGHT, "wr"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fclose(fp); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -248,7 +248,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFopenFclose011, Function | MediumTest FILE *fp = NULL; fp = fopen(TEST_FILE_PTAH_RIGHT, NULL); - TEST_ASSERT_NULL(fp); + ICUNIT_ASSERT_EQUAL(fp, NULL, 0); return 0; } @@ -265,13 +265,13 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFdopen001, Function | MediumTest | Le (void)remove(TEST_FILE_PTAH_RIGHT); fd = open(TEST_FILE_PTAH_RIGHT, O_CREAT | O_RDWR, TEST_MODE_NORMAL); - TEST_ASSERT_TRUE(fd >= 0); + ICUNIT_ASSERT_WITHIN_EQUAL(fd, 0, fd, 0); fp = fdopen(fd, "w"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fclose(fp); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -288,13 +288,13 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFdopen002, Function | MediumTest | Le (void)remove(TEST_FILE_PTAH_RIGHT); fd = open(TEST_FILE_PTAH_RIGHT, O_CREAT | O_RDWR, TEST_MODE_NORMAL); - TEST_ASSERT_TRUE(fd >= 0); + ICUNIT_ASSERT_WITHIN_EQUAL(fd, 0, fd, -1); fp = fdopen(fd, "w+"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fclose(fp); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -311,13 +311,13 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFdopen003, Function | MediumTest | Le (void)remove(TEST_FILE_PTAH_RIGHT); fd = open(TEST_FILE_PTAH_RIGHT, O_CREAT | O_RDWR, TEST_MODE_NORMAL); - TEST_ASSERT_TRUE(fd >= 0); + ICUNIT_ASSERT_WITHIN_EQUAL(fd, 0, fd, -1); fp = fdopen(fd, "a"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fclose(fp); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -335,7 +335,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFdopen004, Function | MediumTest | Le (void)remove(TEST_FILE_PTAH_RIGHT); fd = open(TEST_FILE_PTAH_RIGHT, O_CREAT | O_RDWR, TEST_MODE_NORMAL); - TEST_ASSERT_TRUE(fd >= 0); + ICUNIT_ASSERT_WITHIN_EQUAL(fd, 0, fd, -1); fp = fdopen(500, "w"); /* 500 is a wrong fd */ // in some fs, may return ok, so return null or not is pass. @@ -346,7 +346,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFdopen004, Function | MediumTest | Le fp->fd = fd; ret = fclose(fp); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } #endif @@ -361,7 +361,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFtellFseek001, Function | MediumTest long off = 0; fp = fopen(TEST_FILE_PTAH_RIGHT, "w"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); off = ftell(fp); ICUNIT_GOTO_EQUAL((int)off, 0, (int)off, EXIT); @@ -383,10 +383,10 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFtellFseek002, Function | MediumTest long off = 0; fp = fopen(TEST_FILE_PTAH_RIGHT, "w"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fseek(fp, 0L, SEEK_SET); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); off = ftell(fp); ICUNIT_GOTO_EQUAL((int)off, 0, (int)off, EXIT); @@ -402,16 +402,16 @@ EXIT: * @tc.desc [C- SOFTWARE -0200] */ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFtellFseek003, Function | MediumTest | Level1) -{ +{ int ret = 0; FILE *fp = NULL; long off = 0; fp = fopen(TEST_FILE_PTAH_RIGHT, "w"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fseek(fp, TEST_SEEK_SIZE, SEEK_SET); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); off = ftell(fp); ICUNIT_GOTO_EQUAL((int)off, TEST_SEEK_SIZE, (int)off, EXIT); @@ -433,10 +433,10 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFtellFseek004, Function | MediumTest long off = 0; fp = fopen(TEST_FILE_PTAH_RIGHT, "w"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fseek(fp, TEST_SEEK_SIZE, SEEK_END); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); off = ftell(fp); ICUNIT_GOTO_EQUAL((int)off, TEST_SEEK_SIZE, (int)off, EXIT); @@ -458,10 +458,10 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFtellFseek005, Function | MediumTest long off = 0; fp = fopen(TEST_FILE_PTAH_RIGHT, "w"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fseek(fp, TEST_SEEK_SIZE, SEEK_CUR); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); off = ftell(fp); ICUNIT_GOTO_EQUAL((int)off, TEST_SEEK_SIZE, (int)off, EXIT); @@ -484,10 +484,10 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFtellFseek006, Function | MediumTest long off = 0; fp = fopen(TEST_FILE_PTAH_RIGHT, "w"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fseek(fp, -1L, SEEK_SET); - TEST_ASSERT_EQUAL_INT(-1, ret); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); off = ftell(fp); ICUNIT_GOTO_EQUAL((int)off, 0, (int)off, EXIT); @@ -510,10 +510,10 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFtellFseek007, Function | MediumTest remove(TEST_FILE_PTAH_RIGHT); fp = fopen(TEST_FILE_PTAH_RIGHT, "w+"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fseek(fp, -1L, SEEK_CUR); - TEST_ASSERT_EQUAL_INT(-1, ret); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); off = ftell(fp); ICUNIT_GOTO_EQUAL((int)off, 0, (int)off, EXIT); @@ -536,10 +536,10 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFtellFseek008, Function | MediumTest remove(TEST_FILE_PTAH_RIGHT); fp = fopen(TEST_FILE_PTAH_RIGHT, "w+"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fseek(fp, -1L, SEEK_END); - TEST_ASSERT_EQUAL_INT(-1, ret); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); off = ftell(fp); ICUNIT_GOTO_EQUAL((int)off, 0, (int)off, EXIT); @@ -561,7 +561,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFtellFseek009, Function | MediumTest long off = 0; fp = fopen(TEST_FILE_PTAH_RIGHT, "w"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); /* wrong input, fs may return not error, no need to check return value */ (void)fseek(fp, TEST_SEEK_SIZE, 5); /* 5, a wrong input */ @@ -587,19 +587,19 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFtellFseek010, Function | MediumTest int fd; fp = fopen(TEST_FILE_PTAH_RIGHT, "w"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); fd = fp->fd; fp->fd = 500; /* 500 is a wrong fd */ ret = fseek(fp, TEST_SEEK_SIZE, SEEK_SET); - TEST_ASSERT_EQUAL_INT(-1, ret); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); fp->fd = fd; ret = fclose(fp); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } #endif @@ -615,13 +615,13 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFtellFseek011, Function | MediumTest long off = 0; fp = fopen(TEST_FILE_PTAH_RIGHT, "w"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fseek(fp, TEST_SEEK_SIZE, SEEK_SET); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); ret = fseek(fp, TEST_SEEK_SIZE, SEEK_CUR); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); off = ftell(fp); ICUNIT_GOTO_EQUAL((int)off, (TEST_SEEK_SIZE + TEST_SEEK_SIZE), (int)off, EXIT); @@ -644,13 +644,13 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFtellFseek012, Function | MediumTest long off = 0; fp = fopen(TEST_FILE_PTAH_RIGHT, "w"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fseek(fp, (TEST_SEEK_SIZE + TEST_SEEK_SIZE), SEEK_SET); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); ret = fseek(fp, TEST_SEEK_SIZE, SEEK_SET); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); off = ftell(fp); ICUNIT_GOTO_EQUAL((int)off, TEST_SEEK_SIZE, (int)off, EXIT); @@ -673,12 +673,13 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFtellFseek013, Function | MediumTest long off = 0; fp = fopen(TEST_FILE_PTAH_RIGHT, "w"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fseek(fp, TEST_SEEK_SIZE, SEEK_SET); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); ret = fseek(fp, TEST_SEEK_SIZE, SEEK_END); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); off = ftell(fp); ICUNIT_GOTO_EQUAL((int)off, TEST_SEEK_SIZE, (int)off, EXIT); @@ -701,10 +702,10 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFtellFseek014, Function | MediumTest long off = 0; fp = fopen(TEST_FILE_PTAH_RIGHT, "w"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fseek(fp, TEST_SEEK_SIZE, SEEK_SET); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); rewind(fp); @@ -718,7 +719,7 @@ EXIT: /* * * @tc.number SUB_KERNEL_FS_FTELL_FSEEK_015 - * @tc.name ftell and fseek + * @tc.name ftell and fseek * @tc.desc [C- SOFTWARE -0200] */ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFtellFseek015, Function | MediumTest | Level1) @@ -728,10 +729,10 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFtellFseek015, Function | MediumTest long off = 0; fp = fopen(TEST_FILE_PTAH_RIGHT, "w"); - TEST_ASSERT_NOT_NULL(fp); - + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); + ret = fseek(fp, TEST_SEEK_SIZE, SEEK_CUR); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); rewind(fp); @@ -756,10 +757,10 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFtellFseek016, Function | MediumTest long off = 0; fp = fopen(TEST_FILE_PTAH_RIGHT, "w"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fseek(fp, TEST_SEEK_SIZE, SEEK_END); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); rewind(fp); @@ -783,13 +784,13 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFputs001, Function | MediumTest | Lev const char chr1[TEST_BUF_SIZE] = "hello"; fp = fopen(TEST_FILE_PTAH_RIGHT, "w"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fputs(chr1, fp); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); ret = fclose(fp); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -805,13 +806,13 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFputs002, Function | MediumTest | Lev const char chr1[TEST_BUF_SIZE] = "hello"; fp = fopen(TEST_FILE_PTAH_RIGHT, "a"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fputs(chr1, fp); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); ret = fclose(fp); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -827,13 +828,13 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFputs003, Function | MediumTest | Lev const char chr1[TEST_BUF_SIZE] = "hello"; fp = fopen(TEST_FILE_PTAH_RIGHT, "w+"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fputs(chr1, fp); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); ret = fclose(fp); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -850,20 +851,20 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFputs004, Function | MediumTest | Lev char str[TEST_BUF_SIZE] = {0}; fp = fopen(TEST_FILE_PTAH_RIGHT, "w+"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fputs(chr1, fp); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); (void)fseek (fp, 0L, SEEK_SET); ret = fread(str, strlen(chr1) + 1, 1, fp); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); ret = strcmp(str, "hello"); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); ret = fclose(fp); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -880,18 +881,18 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFputs005, Function | MediumTest | Lev int i; fp = fopen(TEST_FILE_PTAH_RIGHT, "w+"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); for (i = 0; i < TEST_LOOPUP_TIME; i++) { ret = fputs(chr1, fp); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); } ret = ftell(fp); - TEST_ASSERT_EQUAL_INT(TEST_LOOPUP_TIME * strlen(chr1), ret); + ICUNIT_ASSERT_EQUAL(ret, TEST_LOOPUP_TIME * strlen(chr1), ret); ret = fclose(fp); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -908,13 +909,13 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFreadFwrite001, Function | MediumTest const char chr1[TEST_BUF_SIZE] = "hello"; fp = fopen(TEST_FILE_PTAH_RIGHT, "w"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fwrite(chr1, strlen(chr1) + 1, 1, fp); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); ret = fclose(fp); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -929,13 +930,13 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFreadFwrite002, Function | MediumTest FILE *fp = NULL; fp = fopen(TEST_FILE_PTAH_RIGHT, "w"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fwrite(0, 0, 1, fp); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); ret = fclose(fp); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -951,13 +952,13 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFreadFwrite003, Function | MediumTest const char chr1[TEST_BUF_SIZE] = "hello"; fp = fopen(TEST_FILE_PTAH_RIGHT, "r"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fread((void *)chr1, strlen(chr1) + 1, 1, fp); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); ret = fclose(fp); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -972,13 +973,13 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFreadFwrite004, Function | MediumTest FILE *fp = NULL; fp = fopen(TEST_FILE_PTAH_RIGHT, "r"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fread(0, 0, 1, fp); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); ret = fclose(fp); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -994,13 +995,13 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFreadFwrite005, Function | MediumTest const char chr1[TEST_BUF_SIZE] = "hello"; fp = fopen(TEST_FILE_PTAH_RIGHT, "a"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fwrite(chr1, strlen(chr1) + 1, 1, fp); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); ret = fclose(fp); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -1020,28 +1021,28 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFreadFwrite006, Function | MediumTest char str[TEST_BUF_SIZE] = {0}; fp = fopen(TEST_FILE_PTAH_RIGHT, "w+"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fwrite(chr1, strlen(chr1), 1, fp); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); (void)fseek(fp, 0L, SEEK_SET); ret = fread(str, TEST_RW_SIZE, 1, fp); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); ret = fwrite(chr2, strlen(chr2), 1, fp); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); (void)fseek(fp, 0L, SEEK_SET); ret = fread(str, TEST_RW_SIZE, 1, fp); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); ret = strcmp(str, "helloworld"); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); ret = fclose(fp); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -1062,24 +1063,24 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFreadFwrite007, Function | MediumTest char str[TEST_BUF_SIZE] = {0}; fp = fopen(TEST_FILE_PTAH_RIGHT, "w+"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); ret = fwrite(chr1, strlen(chr1), 1, fp); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); ret = fwrite(chr2, strlen(chr2), 1, fp); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); (void)fseek(fp, 0L, SEEK_SET); ret = fread(str, TEST_RW_SIZE, 1, fp); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); ret = strcmp(str, "helloworld"); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); ret = fclose(fp); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -1100,28 +1101,28 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFreadFwrite008, Function | MediumTest char str[TEST_BUF_SIZE] = {0}; fp = fopen(TEST_FILE_PTAH_RIGHT, "w+"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); for (i = 0; i < TEST_LOOPUP_TIME; i++) { ret = fwrite(chr1, strlen(chr1), 1, fp); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); } for (i = 0; i < TEST_LOOPUP_TIME; i++) { ret = fwrite(chr2, strlen(chr2), 1, fp); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); } (void)fseek(fp, (TEST_LOOPUP_TIME - 2) * strlen(chr1), SEEK_SET); /* 2, means will read chr1 2times */ ret = fread(str, TEST_RW_SIZE, 1, fp); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); ret = strncmp(str, "hellohelloworldworld", TEST_RW_SIZE); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); ret = fclose(fp); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -1140,23 +1141,23 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFreadFwrite009, Function | MediumTest char str[TEST_BUF_SIZE] = {0}; fp = fopen(TEST_FILE_PTAH_RIGHT, "w+"); - TEST_ASSERT_NOT_NULL(fp); + ICUNIT_ASSERT_NOT_EQUAL(fp, NULL, 0); for (i = 0; i < TEST_LOOPUP_TIME; i++) { ret = fwrite(chr1, strlen(chr1), 1, fp); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); } (void)fseek(fp, TEST_SEEK_SIZE, SEEK_SET); ret = fread(str, TEST_RW_SIZE, 1, fp); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); ret = strncmp(str, "1234512345123451234512345", TEST_RW_SIZE); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); ret = fclose(fp); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -1170,7 +1171,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsOpendir001, Function | MediumTest | L DIR *dir = NULL; dir = opendir(TEST_ROOT); - TEST_ASSERT_NOT_NULL(dir); + ICUNIT_ASSERT_NOT_EQUAL(dir, NULL, 0); (void)closedir(dir); @@ -1188,7 +1189,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsOpendir002, Function | MediumTest | L remove(DIRA); dir = opendir(DIRA); - TEST_ASSERT_NULL(dir); + ICUNIT_ASSERT_EQUAL(dir, NULL, 0); return 0; } @@ -1202,7 +1203,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsOpendir003, Function | MediumTest | L DIR *dir = NULL; dir = opendir(NULL); - TEST_ASSERT_NULL(dir); + ICUNIT_ASSERT_EQUAL(dir, NULL, 0); return 0; } @@ -1222,13 +1223,13 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsReaddir001, Function | MediumTest | L (void)mkdir(DIRAB, TEST_MODE_NORMAL); dirp = opendir(DIRA); - TEST_ASSERT_NOT_NULL(dirp); + ICUNIT_ASSERT_NOT_EQUAL(dirp, NULL, 0); dResult = readdir(dirp); - TEST_ASSERT_NOT_NULL(dResult); + ICUNIT_ASSERT_NOT_EQUAL(dResult, NULL, 0); ret = closedir(dirp); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); (void)rmdir(DIRAB); (void)rmdir(DIRA); @@ -1252,16 +1253,16 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsReaddir002, Function | MediumTest | L (void)mkdir(DIRAC, TEST_MODE_NORMAL); dirp = opendir(DIRA); - TEST_ASSERT_NOT_NULL(dirp); + ICUNIT_ASSERT_NOT_EQUAL(dirp, NULL, 0); dResult = readdir(dirp); - TEST_ASSERT_NOT_NULL(dResult); + ICUNIT_ASSERT_NOT_EQUAL(dResult, NULL, 0); tellDir0 = dResult->d_off; dResult = readdir(dirp); - TEST_ASSERT_NOT_NULL(dResult); + ICUNIT_ASSERT_NOT_EQUAL(dResult, NULL, 0); tellDir1 = dResult->d_off; - TEST_ASSERT_TRUE(tellDir0 == tellDir1); + ICUNIT_ASSERT_EQUAL(tellDir0, tellDir1, -1); (void)rmdir(DIRAC); (void)rmdir(DIRAB); @@ -1280,10 +1281,10 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsReaddir003, Function | MediumTest | L struct dirent *dResult; dirp = opendir(NULL); - TEST_ASSERT_NULL(dirp); + ICUNIT_ASSERT_EQUAL(dirp, NULL, 0); dResult = readdir(dirp); - TEST_ASSERT_NULL(dResult); + ICUNIT_ASSERT_EQUAL(dResult, NULL, 0); return 0; } @@ -1301,7 +1302,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsRemove001, Function | MediumTest | Le fd = open(TEST_FILE_PTAH_RIGHT, O_CREAT | O_RDWR, TEST_MODE_NORMAL); close(fd); ret = remove(TEST_FILE_PTAH_RIGHT); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -1315,9 +1316,9 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsRemove002, Function | MediumTest | Le int ret = 0; ret = mkdir(DIRA, TEST_MODE_NORMAL); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); ret = remove(DIRA); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -1330,7 +1331,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsRemove003, Function | MediumTest | Le { int ret = 0; ret = remove(DIRA); - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; } @@ -1346,16 +1347,16 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsRemove004, Function | MediumTest | Le (void)mkdir(DIRA, TEST_MODE_NORMAL); ret = mkdir(DIRAC, TEST_MODE_NORMAL); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); ret = remove(DIRA); - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); ret = remove(DIRAC); - TEST_ASSERT_EQUAL(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); ret = remove(DIRA); - TEST_ASSERT_EQUAL(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -1372,13 +1373,13 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsRmdir001, Function | MediumTest | Lev (void)mkdir(DIRA, TEST_MODE_NORMAL); ret = mkdir(DIRAB, TEST_MODE_NORMAL); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); ret = rmdir(DIRAB); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); ret = rmdir(DIRA); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -1394,19 +1395,19 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsRmdir002, Function | MediumTest | Lev (void)mkdir(DIRA, TEST_MODE_NORMAL); ret = mkdir(DIRAB, TEST_MODE_NORMAL); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); ret = mkdir(DIRAC, TEST_MODE_NORMAL); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); ret = rmdir(DIRAB); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); ret = rmdir(DIRAC); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); ret = rmdir(DIRA); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -1422,16 +1423,16 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsRmdir003, Function | MediumTest | Lev (void)mkdir(DIRA, TEST_MODE_NORMAL); ret = mkdir(DIRAB, TEST_MODE_NORMAL); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); ret = rmdir(DIRA); - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); ret = rmdir(DIRAB); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); ret = rmdir(DIRA); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -1445,7 +1446,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsRmdir004, Function | MediumTest | Lev int ret; ret = rmdir(NULL); - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; } @@ -1461,12 +1462,12 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsUnlink001, Function | MediumTest | Le char tmpFileName[]= FILE1; fd = open(tmpFileName, O_CREAT | O_RDWR, TEST_MODE_NORMAL); - TEST_ASSERT_TRUE(fd != -1); + ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd); (void)close(fd); ret = unlink(tmpFileName); - TEST_ASSERT_EQUAL(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -1480,7 +1481,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsUnlink002, Function | MediumTest | Le int ret; ret = unlink(NULL); - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; } @@ -1498,12 +1499,12 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsStat001, Function | MediumTest | Leve remove(FILE1); fd = open(tmpFileName, O_CREAT | O_RDWR, TEST_MODE_NORMAL); - TEST_ASSERT_TRUE(fd != -1); + ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd); (void)close(fd); ret = stat(tmpFileName, &buf); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); return 0; } @@ -1523,15 +1524,15 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsStat002, Function | MediumTest | Leve remove(FILE1); fd = open(tmpFileName, O_CREAT | O_RDWR, TEST_MODE_NORMAL); - TEST_ASSERT_TRUE(fd != -1); + ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd); size = write(fd, writeBuf, sizeof(writeBuf)); (void)close(fd); - TEST_ASSERT_TRUE(size != -1); + ICUNIT_ASSERT_NOT_EQUAL(size, -1, size); ret = stat(tmpFileName, &buf); - TEST_ASSERT_TRUE(ret != -1); - TEST_ASSERT_TRUE(buf.st_size == sizeof(writeBuf)); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); + ICUNIT_ASSERT_EQUAL(buf.st_size, sizeof(writeBuf), -1); return 0; } @@ -1551,16 +1552,16 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsStat003, Function | MediumTest | Leve (void)memset_s(&buf, sizeof(buf), 0, sizeof(buf)); fd = open(tmpFileName, O_CREAT | O_RDWR, TEST_MODE_NORMAL); - TEST_ASSERT_TRUE(fd != -1); + ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd); size = write(fd, writeBuf, sizeof(writeBuf)); (void)close(fd); - TEST_ASSERT_TRUE(size != -1); + ICUNIT_ASSERT_NOT_EQUAL(size, -1, size); ret = stat(tmpFileName, &buf); - TEST_ASSERT_TRUE(ret != -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); - TEST_ASSERT_EQUAL_INT(0, buf.st_rdev); + ICUNIT_ASSERT_EQUAL(buf.st_rdev, 0, buf.st_rdev); return 0; } @@ -1578,17 +1579,17 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsRename001, Function | MediumTest | Le (void)remove(FILE2); fd = open(FILE1, O_CREAT | O_RDWR, TEST_MODE_NORMAL); - TEST_ASSERT_TRUE(fd != -1); + ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd); (void)close(fd); ret = rename(FILE1, FILE2); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); ret = remove(FILE1); - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); ret = remove(FILE2); - TEST_ASSERT_EQUAL(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -1605,11 +1606,11 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsRename002, Function | MediumTest | Le (void)remove(FILE1); fd = open(FILE1, O_CREAT | O_RDWR, TEST_MODE_NORMAL); - TEST_ASSERT_TRUE(fd != -1); + ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd); (void)close(fd); ret = rename(FILE1, NULL); - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; } @@ -1626,7 +1627,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsRename003, Function | MediumTest | Le (void)remove(FILE1); ret = rename(NULL, FILE1); - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; } @@ -1643,7 +1644,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsOpen001, Function | MediumTest | Leve (void)remove(FILE1); fd = open(FILE1, O_RDWR, TEST_MODE_NORMAL); - TEST_ASSERT_EQUAL(-1, fd); + ICUNIT_ASSERT_EQUAL(fd, -1, fd); return 0; } @@ -1661,7 +1662,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsOpen002, Function | MediumTest | Leve (void)mkdir(DIRA, TEST_MODE_NORMAL); fd = open(FILE_IN_DIRA, O_CREAT | O_RDWR, TEST_MODE_HIGH); - TEST_ASSERT_TRUE(fd != -1); + ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd); (void)close(fd); return 0; @@ -1681,9 +1682,9 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsOpen003, Function | MediumTest | Leve (void)remove(FILE1); fd = open(FILE1, O_CREAT | O_RDONLY, TEST_MODE_NORMAL); - TEST_ASSERT_TRUE(fd != -1); + ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd); size = write(fd, writeBuf, sizeof(writeBuf)); - TEST_ASSERT_TRUE(size <= 0); + ICUNIT_ASSERT_WITHIN_EQUAL(size, size, 0, -1); (void)close(fd); return 0; @@ -1700,7 +1701,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsOpen004, Function | MediumTest | Leve (void)rmdir(DIRA); fd = open(FILE_IN_DIRA, O_CREAT | O_RDWR, TEST_MODE_NORMAL); - TEST_ASSERT_TRUE(fd != -1); + ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd); return 0; } @@ -1716,7 +1717,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsOpen005, Function | MediumTest | Leve (void)rmdir(DIRA); fd = open(NULL, O_CREAT | O_RDWR, TEST_MODE_NORMAL); - TEST_ASSERT_TRUE(fd == -1); + ICUNIT_ASSERT_EQUAL(fd, -1, fd); return 0; } @@ -1734,11 +1735,11 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsClose001, Function | MediumTest | Lev (void)remove(FILE1); fd = open(FILE1, O_CREAT | O_RDWR, TEST_MODE_NORMAL); - TEST_ASSERT_TRUE(fd != -1); + ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd); (void)close(fd); ret = close(fd); - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; } @@ -1765,7 +1766,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsWrite001, Function | MediumTest | Lev } fd = open(FILE1, O_CREAT | O_RDWR, TEST_MODE_NORMAL); - TEST_ASSERT_TRUE(fd != -1); + ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd); ret = write(fd, writeBuf, TEST_RW_SIZE); ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT); @@ -1798,7 +1799,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsWrite002, Function | MediumTest | Lev remove(FILE1); fd = open(FILE1, O_CREAT | O_RDWR, TEST_MODE_NORMAL); - TEST_ASSERT_TRUE(fd != -1); + ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd); for (i = 0; i < TEST_LOOPUP_TIME; i++) { ret = write(fd, writeBuf, sizeof(writeBuf)); @@ -1807,8 +1808,8 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsWrite002, Function | MediumTest | Lev (void)close(fd); ret = stat(FILE1, &statbuf); - TEST_ASSERT_TRUE(ret != -1); - TEST_ASSERT_TRUE(statbuf.st_size == sizeof(writeBuf) * TEST_LOOPUP_TIME); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); + ICUNIT_ASSERT_EQUAL(statbuf.st_size, sizeof(writeBuf) * TEST_LOOPUP_TIME, -1); return 0; EXIT: (void)close(fd); @@ -1832,7 +1833,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsWrite003, Function | MediumTest | Lev } fd = open(FILE1, O_CREAT | O_RDWR, TEST_MODE_NORMAL); - TEST_ASSERT_TRUE(fd != -1); + ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd); ret = write(fd, writeBuf, TEST_RW_SIZE); ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT); @@ -1845,7 +1846,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsWrite003, Function | MediumTest | Lev (void)close(fd); ret = strncmp(writeBuf, readBuf, TEST_RW_SIZE); - TEST_ASSERT_NOT_EQUAL(0, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); return 0; EXIT: @@ -1864,8 +1865,8 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsDirname001, Function | MediumTest | L { char path[] = FILE0; char *workDir = dirname((char *)path); - TEST_ASSERT_NOT_NULL(workDir); - TEST_ASSERT_EQUAL_STRING(".", workDir); + ICUNIT_ASSERT_NOT_EQUAL(workDir, NULL, 0); + ICUNIT_ASSERT_STRING_EQUAL(workDir, ".", 0); return 0; } @@ -1878,8 +1879,8 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsDirname002, Function | MediumTest | L { char path[] = FILE1; char *workDir = dirname((char *)path); - TEST_ASSERT_NOT_NULL(workDir); - TEST_ASSERT_EQUAL_STRING(TEST_ROOT, workDir); + ICUNIT_ASSERT_NOT_EQUAL(workDir, NULL, 0); + ICUNIT_ASSERT_STRING_EQUAL(workDir, TEST_ROOT, -1); return 0; } @@ -1893,8 +1894,8 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsDirname003, Function | MediumTest | L // get dir char path[] = DIRA; char *workDir = dirname((char *)path); - TEST_ASSERT_NOT_NULL(workDir); - TEST_ASSERT_EQUAL_STRING(TEST_ROOT, workDir); + ICUNIT_ASSERT_NOT_EQUAL(workDir, NULL, 0); + ICUNIT_ASSERT_STRING_EQUAL(workDir, TEST_ROOT, -1); return 0; } @@ -1907,24 +1908,24 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsDirname004, Function | MediumTest | L { // get dir char *workDir = dirname(""); - TEST_ASSERT_NOT_NULL(workDir); - TEST_ASSERT_EQUAL_STRING(".", workDir); + ICUNIT_ASSERT_NOT_EQUAL(workDir, NULL, 0); + ICUNIT_ASSERT_STRING_EQUAL(workDir ,".", 0); workDir = dirname(NULL); - TEST_ASSERT_NOT_NULL(workDir); - TEST_ASSERT_EQUAL_STRING(".", workDir); + ICUNIT_ASSERT_NOT_EQUAL(workDir, NULL, 0); + ICUNIT_ASSERT_STRING_EQUAL(workDir, ".", 0); workDir = dirname("/"); - TEST_ASSERT_NOT_NULL(workDir); - TEST_ASSERT_EQUAL_STRING("/", workDir); + ICUNIT_ASSERT_NOT_EQUAL(workDir, NULL, 0); + ICUNIT_ASSERT_STRING_EQUAL(workDir, "/", 0); workDir = dirname(".."); - TEST_ASSERT_NOT_NULL(workDir); - TEST_ASSERT_EQUAL_STRING(".", workDir); + ICUNIT_ASSERT_NOT_EQUAL(workDir, NULL, 0); + ICUNIT_ASSERT_STRING_EQUAL(workDir, ".", 0); workDir = dirname("."); - TEST_ASSERT_NOT_NULL(workDir); - TEST_ASSERT_EQUAL_STRING(".", workDir); + ICUNIT_ASSERT_NOT_EQUAL(workDir, NULL, 0); + ICUNIT_ASSERT_STRING_EQUAL(workDir, ".", 0); return 0; } @@ -1940,10 +1941,10 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFcntl001, Function | MediumTest | Lev char tmpFileName[]= FILE1; fd = open(tmpFileName, O_CREAT | O_RDWR, TEST_MODE_NORMAL); - TEST_ASSERT_TRUE(fd != -1); + ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd); flags = fcntl(fd, F_GETFL); - TEST_ASSERT_TRUE(flags == (O_CREAT | O_RDWR)); + ICUNIT_TRACK_EQUAL(flags, O_CREAT | O_RDWR, 0); (void)close(fd); @@ -1962,11 +1963,11 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsFcntl002, Function | MediumTest | Lev char tmpFileName[]= FILE1; fd = open(tmpFileName, O_CREAT | O_RDWR, TEST_MODE_NORMAL); - TEST_ASSERT_TRUE(fd != -1); + ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd); (void)fcntl(fd, F_SETFL, flags | O_APPEND); flags = fcntl(fd, F_GETFL); - TEST_ASSERT_TRUE(flags == (O_CREAT | O_RDWR | O_APPEND)); + ICUNIT_TRACK_EQUAL(flags, O_CREAT | O_RDWR | O_APPEND, 0); (void)close(fd); diff --git a/testsuites/unittest/posix/src/math/math_func_test.c b/testsuites/unittest/posix/src/math/math_func_test.c index 425ccc14..d57420d4 100644 --- a/testsuites/unittest/posix/src/math/math_func_test.c +++ b/testsuites/unittest/posix/src/math/math_func_test.c @@ -107,7 +107,7 @@ LITE_TEST_CASE(PosixMathFuncTestSuite, testMathAbs001, Function | MediumTest | L for (int i = 0; i < testCount; ++i) { ret = abs(testValues[i]); LOG("\n [POSIXTEST][abs]abs(%d) = %d, expected is %d", testValues[i], ret, expected[i]); - TEST_ASSERT_EQUAL_INT(expected[i], ret); + ICUNIT_ASSERT_EQUAL(ret, expected[i], ret); } return 0; }; @@ -126,7 +126,7 @@ LITE_TEST_CASE(PosixMathFuncTestSuite, testMathAbs002, Function | MediumTest | L for (int i = 0; i < testCount; ++i) { ret = abs(testValues[i]); LOG("\n [POSIXTEST][abs]abs(%d) = %d, expected is %d", testValues[i], ret, expected[i]); - TEST_ASSERT_EQUAL_INT(expected[i], ret); + ICUNIT_ASSERT_EQUAL(ret, expected[i], ret); } return 0; }; @@ -148,7 +148,7 @@ LITE_TEST_CASE(PosixMathFuncTestSuite, testMathLog001, Function | MediumTest | L ret = log(testValues[i]); LOG("\n [POSIXTEST][log]log(%lf) = %lf, expected is %lf", testValues[i], ret, expected[i]); TEST_ASSERT_EQUAL_FLOAT(expected[i], ret); - TEST_ASSERT_TRUE(DoubleEquals(expected[i], ret)); + ICUNIT_ASSERT_EQUAL(DoubleEquals(expected[i], ret), TRUE, 0); } return 0; }; @@ -191,7 +191,7 @@ LITE_TEST_CASE(PosixMathFuncTestSuite, testMathSqrt001, Function | MediumTest | ret = sqrt(testValues[i]); LOG("\n [POSIXTEST][sqrt]sqrt(%lf) = %lf, expected is %lf", testValues[i], ret, expected[i]); TEST_ASSERT_EQUAL_FLOAT(expected[i], ret); - TEST_ASSERT_TRUE(DoubleEquals(expected[i], ret)); + ICUNIT_ASSERT_EQUAL(DoubleEquals(expected[i], ret), TRUE, 0); } return 0; }; @@ -236,7 +236,7 @@ LITE_TEST_CASE(PosixMathFuncTestSuite, testMathPow001, Function | MediumTest | L LOG("\n [POSIXTEST][pow]pow1(%lf,%lf) = %lf, expected is %lf", testValues[i][TEST_VALUE_X], testValues[i][TEST_VALUE_Y], ret, testValues[i][TEST_EXPECTED]); TEST_ASSERT_EQUAL_FLOAT(testValues[i][TEST_EXPECTED], ret); - TEST_ASSERT_TRUE(DoubleEquals(testValues[i][TEST_EXPECTED], ret)); + ICUNIT_ASSERT_EQUAL(DoubleEquals(testValues[i][TEST_EXPECTED], ret), TRUE, 0); } return 0; }; @@ -269,7 +269,7 @@ LITE_TEST_CASE(PosixMathFuncTestSuite, testMathPow002, Function | MediumTest | L for (int i = 0; i < testCount; ++i) { ret = pow(testValues[i][TEST_VALUE_X], testValues[i][TEST_VALUE_Y]); TEST_ASSERT_EQUAL_FLOAT(testValues[i][TEST_EXPECTED], ret); - TEST_ASSERT_TRUE(DoubleEquals(testValues[i][TEST_EXPECTED], ret)); + ICUNIT_ASSERT_EQUAL(DoubleEquals(testValues[i][TEST_EXPECTED], ret), TRUE, 0); LOG("\n [POSIXTEST][pow]pow1(%lf,%lf) = %lf, expected is %lf", testValues[i][TEST_VALUE_X], testValues[i][TEST_VALUE_Y], ret, testValues[i][TEST_EXPECTED]); } @@ -297,7 +297,7 @@ LITE_TEST_CASE(PosixMathFuncTestSuite, testMathPow003, Function | MediumTest | L TEST_ASSERT_EQUAL_FLOAT(testValues[i][TEST_EXPECTED], ret); LOG("\n [POSIXTEST][pow]pow1(%lf,%lf) = %lf, expected is %lf", testValues[i][TEST_VALUE_X], testValues[i][TEST_VALUE_Y], ret, testValues[i][TEST_EXPECTED]); - TEST_ASSERT_TRUE(DoubleEquals(testValues[i][TEST_EXPECTED], ret)); + ICUNIT_ASSERT_EQUAL(DoubleEquals(testValues[i][TEST_EXPECTED], ret), TRUE, 0); } return 0; }; @@ -318,7 +318,7 @@ LITE_TEST_CASE(PosixMathFuncTestSuite, testMathRound001, Function | MediumTest | ret = round(testValues[i]); LOG("\n [POSIXTEST][round]round1(%lf) = %lf, expected is %lf", testValues[i], ret, expected[i]); TEST_ASSERT_EQUAL_FLOAT(expected[i], ret); - TEST_ASSERT_TRUE(DoubleEquals(expected[i], ret)); + ICUNIT_ASSERT_EQUAL(DoubleEquals(expected[i], ret), TRUE, 0); } return 0; }; @@ -338,7 +338,7 @@ LITE_TEST_CASE(PosixMathFuncTestSuite, testMathRound002, Function | MediumTest | ret = round(testValues[i]); LOG("\n [POSIXTEST][round]round1(%lf) = %lf, expected is %lf", testValues[i], ret, expected[i]); TEST_ASSERT_EQUAL_FLOAT(expected[i], ret); - TEST_ASSERT_TRUE(DoubleEquals(expected[i], ret)); + ICUNIT_ASSERT_EQUAL(DoubleEquals(expected[i], ret), TRUE, 0); } return 0; }; diff --git a/testsuites/unittest/posix/src/posix_test.h b/testsuites/unittest/posix/src/posix_test.h index d66e1592..56777d75 100644 --- a/testsuites/unittest/posix/src/posix_test.h +++ b/testsuites/unittest/posix/src/posix_test.h @@ -48,32 +48,8 @@ #define LITE_TEST_CASE(module, function, flag) static int function(void) #define RUN_TEST_SUITE(testsuit) -#define TEST_ASSERT_EQUAL(expected, actual) ICUNIT_ASSERT_EQUAL(expected, actual, actual) -#define TEST_ASSERT_EQUAL_INT(expected, actual) TEST_ASSERT_EQUAL(expected, actual) -#define TEST_ASSERT_EQUAL_INT32(expected, actual) TEST_ASSERT_EQUAL(expected, actual) -#define TEST_ASSERT_EQUAL_INT64(expected, actual) TEST_ASSERT_EQUAL(expected, actual) -#define TEST_ASSERT_EQUAL_UINT32(expected, actual) TEST_ASSERT_EQUAL(expected, actual) -#define TEST_ASSERT_EQUAL_UINT64(expected, actual) TEST_ASSERT_EQUAL(expected, actual) -#define TEST_ASSERT_NULL(ptr) TEST_ASSERT_EQUAL(NULL, ptr) -#define TEST_ASSERT_EQUAL_PTR(expected, actual) TEST_ASSERT_EQUAL(expected, actual) - -#define TEST_ASSERT_NOT_EQUAL(expected, actual) ICUNIT_ASSERT_NOT_EQUAL(expected, actual, actual) -#define TEST_ASSERT_NOT_NULL(ptr) TEST_ASSERT_NOT_EQUAL(NULL, ptr) - -#define TEST_ASSERT_EQUAL_STRING(str1, str2) ICUNIT_ASSERT_STRING_EQUAL(str1, str2, 1) - -#define TEST_ASSERT_TRUE(condition) TEST_ASSERT_NOT_EQUAL(0, condition) -#define TEST_ASSERT_LESS_THAN(threshold, actual) TEST_ASSERT_TRUE((actual) < (threshold)) -#define TEST_ASSERT_LESS_THAN_INT(threshold, actual) TEST_ASSERT_LESS_THAN(threshold, actual) -#define TEST_ASSERT_GREATER_THAN(threshold, actual) TEST_ASSERT_TRUE((actual) > (threshold)) -#define TEST_ASSERT_GREATER_THAN_INT(threshold, actual) TEST_ASSERT_GREATER_THAN(threshold, actual) -#define TEST_ASSERT_GREATER_OR_EQUAL(threshold, actual) TEST_ASSERT_TRUE((actual) >= (threshold)) -#define TEST_ASSERT_LESS_OR_EQUAL_INT64(threshold, actual) TEST_ASSERT_TRUE((actual) <= (threshold)) -#define TEST_ASSERT_INT32_WITHIN(a, b, c) ICUNIT_ASSERT_WITHIN_EQUAL(c, (b) - (a), (b) + (a), c) -#define TEST_FAIL() TEST_ASSERT_TRUE(0) -#define TEST_ASSERT_EQUAL_CHAR_ARRAY(expected, actual, num) ICUNIT_ASSERT_SIZE_STRING_EQUAL(expected, actual, num, 1) #define TEST_ASSERT_EQUAL_FLOAT(expected, actual) \ - TEST_ASSERT_TRUE(((expected) == (actual)) || (isnan(expected) && isnan(actual))) + ICUNIT_ASSERT_EQUAL(((expected) == (actual)) || (isnan(expected) && isnan(actual)), TRUE, 0) void ItSuitePosix(void); diff --git a/testsuites/unittest/posix/src/regex/regex_func_test.c b/testsuites/unittest/posix/src/regex/regex_func_test.c index a3384a8c..2b2c43dd 100644 --- a/testsuites/unittest/posix/src/regex/regex_func_test.c +++ b/testsuites/unittest/posix/src/regex/regex_func_test.c @@ -82,7 +82,7 @@ int TestRegex(int flag, const char *pattern, const char *buf, const int expected int j = 0; regcomp(®, pattern, flag); int status = regexec(®, buf, nmatch, pmatch, 0); - TEST_ASSERT_EQUAL_INT(expectedStatus, status); + ICUNIT_ASSERT_EQUAL(status, expectedStatus, status); if (status == REG_NOMATCH) { LOG("no match"); } else if (status == 0) { @@ -94,7 +94,7 @@ int TestRegex(int flag, const char *pattern, const char *buf, const int expected } res[j] = 0; LOG("\n"); - TEST_ASSERT_EQUAL_STRING(res, expectedRes); + ICUNIT_ASSERT_STRING_EQUAL(res, expectedRes, 0); } regfree(®); return 0; @@ -105,7 +105,7 @@ int TestRegcomp(int flag, const char *pattern, const int expectedStatus) regex_t reg; int status = regcomp(®, pattern, flag); LOG("pattern : %s ,real status : %d \n", pattern, status); - TEST_ASSERT_EQUAL_INT(expectedStatus, status); + ICUNIT_ASSERT_EQUAL(status, expectedStatus, status); regfree(®); return 0; } @@ -166,7 +166,7 @@ LITE_TEST_CASE(PosixRegexFuncTestSuite, testRegexNosub001, Function | MediumTest const char *pattern2 = "HARMONY[1-9]"; regcomp(®, pattern2, cflags); int status = regexec(®, buf, (size_t)0, NULL, 0); - TEST_ASSERT_EQUAL_INT(0, status); + ICUNIT_ASSERT_EQUAL(status, 0, status); regfree(®); return 0; } diff --git a/testsuites/unittest/posix/src/semaphore/semaphore_func_test.c b/testsuites/unittest/posix/src/semaphore/semaphore_func_test.c index e4ea69c2..0128f115 100644 --- a/testsuites/unittest/posix/src/semaphore/semaphore_func_test.c +++ b/testsuites/unittest/posix/src/semaphore/semaphore_func_test.c @@ -106,12 +106,12 @@ LITE_TEST_CASE(PosixSemaphoreFuncTestSuite, testIpcSem_Timedwait001, Function | struct timespec tsNow = { 0 }; sem_t sem; - TEST_ASSERT_EQUAL_INT(0, sem_init((sem_t *)&sem, 0, 0)); + ICUNIT_ASSERT_EQUAL(sem_init((sem_t *)&sem, 0, 0), 0, 0); ts = GetDelayedTime(100); LOG("predicted time:%lld, %ld", ts.tv_sec, ts.tv_nsec); if (sem_timedwait((sem_t *)&sem, &ts) == -1) { - TEST_ASSERT_EQUAL_INT(ETIMEDOUT, errno); + ICUNIT_ASSERT_EQUAL(errno, ETIMEDOUT, errno); } else { LOG("\n> sem_timedwait return unexpected"); } @@ -120,9 +120,9 @@ LITE_TEST_CASE(PosixSemaphoreFuncTestSuite, testIpcSem_Timedwait001, Function | LOG("tsNow %lld, %ld", tsNow.tv_sec, tsNow.tv_nsec); int timeDiff = GetTimeDiff(tsNow, ts); // calculate time different LOG("timeDiff %d", timeDiff); - TEST_ASSERT_LESS_THAN_INT(20, abs(timeDiff)); + ICUNIT_ASSERT_EQUAL(abs(timeDiff) < 20, TRUE, 0); - TEST_ASSERT_EQUAL_INT(0, sem_destroy((sem_t *)&sem)); + ICUNIT_ASSERT_EQUAL(sem_destroy((sem_t *)&sem), 0, 0); return 0; } @@ -138,7 +138,7 @@ LITE_TEST_CASE(PosixSemaphoreFuncTestSuite, testIpcSem_Timedwait002, Function | struct timespec tsBegin = { 0 }; sem_t sem; - TEST_ASSERT_EQUAL_INT(0, sem_init((sem_t *)&sem, 0, 1)); + ICUNIT_ASSERT_EQUAL(sem_init((sem_t *)&sem, 0, 1), 0, 0); ts = GetDelayedTime(100); LOG("\n ts %lld, %ld", ts.tv_sec, ts.tv_nsec); @@ -146,25 +146,25 @@ LITE_TEST_CASE(PosixSemaphoreFuncTestSuite, testIpcSem_Timedwait002, Function | int ret = sem_timedwait((sem_t *)&sem, &ts); clock_gettime(CLOCK_REALTIME, &tsNow); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); LOG("\n tsBegin %lld, %ld, tsNow %lld, %ld", tsBegin.tv_sec, tsBegin.tv_nsec, tsNow.tv_sec, tsNow.tv_nsec); int timeDiff = GetTimeDiff(tsNow, tsBegin); // calculate time different LOG("\n timeDiff %d", timeDiff); - TEST_ASSERT_LESS_THAN_INT(20, timeDiff); + ICUNIT_ASSERT_WITHIN_EQUAL(timeDiff, timeDiff, 19, 0); // try get semaphore again ts = GetDelayedTime(100); LOG("\n ts %lld, %ld", ts.tv_sec, ts.tv_nsec); ret = sem_timedwait((sem_t *)&sem, &ts); clock_gettime(CLOCK_REALTIME, &tsNow); - TEST_ASSERT_EQUAL_INT(-1, ret); - TEST_ASSERT_EQUAL_INT(ETIMEDOUT, errno); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); + ICUNIT_ASSERT_EQUAL(errno, ETIMEDOUT, errno); LOG("\n tsNow %lld, %ld", tsNow.tv_sec, tsNow.tv_nsec); timeDiff = GetTimeDiff(tsNow, tsBegin); // calculate time different LOG("\n wait timeDiff %d", timeDiff); - TEST_ASSERT_EQUAL_INT(0, sem_destroy((sem_t *)&sem)); + ICUNIT_ASSERT_EQUAL(sem_destroy((sem_t *)&sem), 0, 0); return 0; } @@ -182,36 +182,36 @@ LITE_TEST_CASE(PosixSemaphoreFuncTestSuite, testIpcSem_Timedwait003, Function | ts.tv_sec = 0; ts.tv_nsec = 200000; ret = sem_timedwait((sem_t *)&sem, &ts); - TEST_ASSERT_EQUAL_INT(-1, ret); - TEST_ASSERT_EQUAL_INT(EINVAL, errno); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); + ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno); ret = sem_init((sem_t *)&sem, 0, 0); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); ts.tv_sec = time(NULL); ts.tv_nsec = -2; ret = sem_timedwait((sem_t *)&sem, &ts); - TEST_ASSERT_EQUAL_INT(-1, ret); - TEST_ASSERT_EQUAL_INT(EINVAL, errno); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); + ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno); ts.tv_sec = time(NULL); ts.tv_nsec = NANO_S; ret = sem_timedwait((sem_t *)&sem, &ts); - TEST_ASSERT_EQUAL_INT(-1, ret); - TEST_ASSERT_EQUAL_INT(EINVAL, errno); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); + ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno); ret = sem_timedwait((sem_t *)&sem, NULL); - TEST_ASSERT_EQUAL_INT(-1, ret); - TEST_ASSERT_EQUAL_INT(EINVAL, errno); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); + ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno); ret = sem_destroy((sem_t *)&sem); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); ts.tv_sec = time(NULL); ts.tv_nsec = 2000000; ret = sem_timedwait(NULL, &ts); - TEST_ASSERT_EQUAL_INT(-1, ret); - TEST_ASSERT_EQUAL_INT(EINVAL, errno); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); + ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno); return 0; } @@ -227,19 +227,19 @@ LITE_TEST_CASE(PosixSemaphoreFuncTestSuite, testIpcSem_Trywait004, Function | Me int ret; ret = sem_init(&sem, 0, 1); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); ret = sem_trywait(&sem); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); ret = sem_getvalue(&sem, &val); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); if (val <= 0) { sem_destroy(&sem); return LOS_OK; } else { - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); } return 0; } diff --git a/testsuites/unittest/posix/src/stdarg/stdarg_func_test.c b/testsuites/unittest/posix/src/stdarg/stdarg_func_test.c index 2e142904..989f8629 100644 --- a/testsuites/unittest/posix/src/stdarg/stdarg_func_test.c +++ b/testsuites/unittest/posix/src/stdarg/stdarg_func_test.c @@ -78,15 +78,15 @@ int VaFunc(int argsNum, ...) for (int i = 0; i < argsNum; i++) { if (i < 1) { - TEST_ASSERT_EQUAL_INT(10, va_arg(vaP2, int)); + ICUNIT_ASSERT_EQUAL(va_arg(vaP2, int), 10, 0); } if (i == 1) { - TEST_ASSERT_EQUAL_INT(65, va_arg(vaP2, int)); + ICUNIT_ASSERT_EQUAL(va_arg(vaP2, int), 65, 0); } if (i > 1) { - TEST_ASSERT_EQUAL_STRING("hello world", va_arg(vaP2, char *)); + ICUNIT_ASSERT_STRING_EQUAL(va_arg(vaP2, char *), "hello world", 0); } } @@ -104,7 +104,7 @@ int VaFunc(int argsNum, ...) LITE_TEST_CASE(PosixStdargFuncTestSuite, testStdarg001, Function | MediumTest | Level1) { int ret = VaFunc(1, 10); - TEST_ASSERT_EQUAL_INT(RET_OK, ret); + ICUNIT_ASSERT_EQUAL(ret, RET_OK, ret); return 0; } @@ -116,7 +116,7 @@ LITE_TEST_CASE(PosixStdargFuncTestSuite, testStdarg001, Function | MediumTest | LITE_TEST_CASE(PosixStdargFuncTestSuite, testStdarg002, Function | MediumTest | Level1) { int ret = VaFunc(2, 10, 'A'); - TEST_ASSERT_EQUAL_INT(RET_OK, ret); + ICUNIT_ASSERT_EQUAL(ret, RET_OK, ret); return 0; } @@ -128,7 +128,7 @@ LITE_TEST_CASE(PosixStdargFuncTestSuite, testStdarg002, Function | MediumTest | LITE_TEST_CASE(PosixStdargFuncTestSuite, testStdarg003, Function | MediumTest | Level1) { int ret = VaFunc(3, 10, 'A', "hello world"); - TEST_ASSERT_EQUAL_INT(RET_OK, ret); + ICUNIT_ASSERT_EQUAL(ret, RET_OK, ret); return 0; } @@ -140,7 +140,7 @@ LITE_TEST_CASE(PosixStdargFuncTestSuite, testStdarg003, Function | MediumTest | LITE_TEST_CASE(PosixStdargFuncTestSuite, testStdarg004, Function | MediumTest | Level1) { int ret = VaFunc(3, 10, 'A', "hello world", '\0'); - TEST_ASSERT_EQUAL_INT(RET_OK, ret); + ICUNIT_ASSERT_EQUAL(ret, RET_OK, ret); return 0; } diff --git a/testsuites/unittest/posix/src/stdlib/atoi_test.c b/testsuites/unittest/posix/src/stdlib/atoi_test.c index 913b20a5..b2db2654 100644 --- a/testsuites/unittest/posix/src/stdlib/atoi_test.c +++ b/testsuites/unittest/posix/src/stdlib/atoi_test.c @@ -78,7 +78,7 @@ LITE_TEST_CASE(PosixStdlibAtoiTest, testStdlibAtoi001, Function | MediumTest | L } else { LOG("[DEMO] posix stdlib test case 1:atoi(%d) fail.\n", value); } - TEST_ASSERT_EQUAL_INT(2147483647, value); + ICUNIT_ASSERT_EQUAL(value, 2147483647, value); return 0; } @@ -95,7 +95,7 @@ LITE_TEST_CASE(PosixStdlibAtoiTest, testStdlibAtoi002, Function | MediumTest | L } else { LOG("[DEMO] posix stdlib test case 2:atoi(%d) fail.\n", value); } - TEST_ASSERT_EQUAL_INT(-2147483648, value); + ICUNIT_ASSERT_EQUAL(value, -2147483648, value); return 0; } @@ -112,7 +112,7 @@ LITE_TEST_CASE(PosixStdlibAtoiTest, testStdlibAtoi003, Function | MediumTest | L } else { LOG("[DEMO] posix stdlib test case 3:atoi(%d) fail.\n", value); } - TEST_ASSERT_EQUAL_INT(100, value); + ICUNIT_ASSERT_EQUAL(value, 100, value); return 0; } @@ -130,7 +130,7 @@ LITE_TEST_CASE(PosixStdlibAtoiTest, testStdlibAtoi004, Function | MediumTest | L } else { LOG("[DEMO] posix stdlib test case 4(except):atoi(%d) fail.\n", value); } - TEST_ASSERT_EQUAL_INT(-2147483648, value); + ICUNIT_ASSERT_EQUAL(value, -2147483648, value); return 0; } @@ -147,7 +147,7 @@ LITE_TEST_CASE(PosixStdlibAtoiTest, testStdlibAtoi005, Function | MediumTest | L } else { LOG("[DEMO] posix stdlib test case 5(except):atoi(%d) fail.\n", value); } - TEST_ASSERT_EQUAL_INT(2147483647, value); + ICUNIT_ASSERT_EQUAL(value, 2147483647, value); return 0; } #endif @@ -165,7 +165,7 @@ LITE_TEST_CASE(PosixStdlibAtoiTest, testStdlibAtoi006, Function | MediumTest | L } else { LOG("[DEMO] posix stdlib test case 6:atoi(%d) fail.\n", value); } - TEST_ASSERT_EQUAL_INT(100, value); + ICUNIT_ASSERT_EQUAL(value, 100, value); return 0; } @@ -182,7 +182,7 @@ LITE_TEST_CASE(PosixStdlibAtoiTest, testStdlibAtoi007, Function | MediumTest | L } else { LOG("[DEMO] posix stdlib test case 7:atoi(%d) fail.\n", value); } - TEST_ASSERT_EQUAL_INT(-100, value); + ICUNIT_ASSERT_EQUAL(value, -100, value); return 0; } @@ -199,7 +199,7 @@ LITE_TEST_CASE(PosixStdlibAtoiTest, testStdlibAtoi008, Function | MediumTest | L } else { LOG("[DEMO] posix stdlib test case 8(except):atoi(%d) fail.\n", value); } - TEST_ASSERT_EQUAL_INT(0, value); + ICUNIT_ASSERT_EQUAL(value, 0, value); return 0; } @@ -216,7 +216,7 @@ LITE_TEST_CASE(PosixStdlibAtoiTest, testStdlibAtoi009, Function | MediumTest | L } else { LOG("[DEMO] posix stdlib test case 9(except):atoi(%d) fail.\n", value); } - TEST_ASSERT_EQUAL_INT(12, value); + ICUNIT_ASSERT_EQUAL(value, 12, value); return 0; } @@ -234,7 +234,7 @@ LITE_TEST_CASE(PosixStdlibAtoiTest, testStdlibAtoi010, Function | MediumTest | L } else { LOG("[DEMO] posix stdlib test case 10(except):atoi(%d) fail.\n", value); } - TEST_ASSERT_EQUAL_INT(-10, value); + ICUNIT_ASSERT_EQUAL(value, -10, value); return 0; } #endif diff --git a/testsuites/unittest/posix/src/stdlib/atol_test.c b/testsuites/unittest/posix/src/stdlib/atol_test.c index 1568fd55..51229eef 100644 --- a/testsuites/unittest/posix/src/stdlib/atol_test.c +++ b/testsuites/unittest/posix/src/stdlib/atol_test.c @@ -78,7 +78,7 @@ LITE_TEST_CASE(PosixStdlibAtolTest, testStdlibAtol001, Function | MediumTest | L } else { LOG("[DEMO] posix stdlib test case 1:atol(%ld) fail.\n", value); } - TEST_ASSERT_EQUAL_INT32(2147483647, value); + ICUNIT_ASSERT_EQUAL(value, 2147483647, value); return 0; } @@ -95,7 +95,7 @@ LITE_TEST_CASE(PosixStdlibAtolTest, testStdlibAtol002, Function | MediumTest | L } else { LOG("[DEMO] posix stdlib test case 2:atol(%ld) fail.\n", value); } - TEST_ASSERT_EQUAL_INT32(-2147483648, value); + ICUNIT_ASSERT_EQUAL(value, -2147483648, value); return 0; } @@ -112,7 +112,7 @@ LITE_TEST_CASE(PosixStdlibAtolTest, testStdlibAtol003, Function | MediumTest | L } else { LOG("[DEMO] posix stdlib test case 3:atol(%ld) fail.\n", value); } - TEST_ASSERT_EQUAL_INT32(100, value); + ICUNIT_ASSERT_EQUAL(value, 100, value); return 0; } @@ -130,7 +130,7 @@ LITE_TEST_CASE(PosixStdlibAtolTest, testStdlibAtol004, Function | MediumTest | L } else { LOG("[DEMO] posix stdlib test case 4(except):atol(%ld) fail.\n", value); } - TEST_ASSERT_EQUAL_INT32(-2147483648, value); + ICUNIT_ASSERT_EQUAL(value, -2147483648, value); return 0; } @@ -147,7 +147,7 @@ LITE_TEST_CASE(PosixStdlibAtolTest, testStdlibAtol005, Function | MediumTest | L } else { LOG("[DEMO] posix stdlib test case 5(except):atoi(%d) fail.\n", value); } - TEST_ASSERT_EQUAL_INT32(2147483647, value); + ICUNIT_ASSERT_EQUAL(value, 2147483647, value); return 0; } #endif @@ -165,7 +165,7 @@ LITE_TEST_CASE(PosixStdlibAtolTest, testStdlibAtol006, Function | MediumTest | L } else { LOG("[DEMO] posix stdlib test case 6:atol(%ld) fail.\n", value); } - TEST_ASSERT_EQUAL_INT32(100, value); + ICUNIT_ASSERT_EQUAL(value, 100, value); return 0; } @@ -182,7 +182,7 @@ LITE_TEST_CASE(PosixStdlibAtolTest, testStdlibAtol007, Function | MediumTest | L } else { LOG("[DEMO] posix stdlib test case 7:atoi(%ld) fail.\n", value); } - TEST_ASSERT_EQUAL_INT32(-100, value); + ICUNIT_ASSERT_EQUAL(value, -100, value); return 0; } @@ -199,7 +199,7 @@ LITE_TEST_CASE(PosixStdlibAtolTest, testStdlibAtol008, Function | MediumTest | L } else { LOG("[DEMO] posix stdlib test case 8(except):atol(%ld) fail.\n", value); } - TEST_ASSERT_EQUAL_INT32(0, value); + ICUNIT_ASSERT_EQUAL(value, 0, value); return 0; } @@ -216,7 +216,7 @@ LITE_TEST_CASE(PosixStdlibAtolTest, testStdlibAtol009, Function | MediumTest | L } else { LOG("[DEMO] posix stdlib test case 9(except):atol(%ld) fail.\n", value); } - TEST_ASSERT_EQUAL_INT32(12, value); + ICUNIT_ASSERT_EQUAL(value, 12, value); return 0; } diff --git a/testsuites/unittest/posix/src/stdlib/atoll_test.c b/testsuites/unittest/posix/src/stdlib/atoll_test.c index a87b02c1..857e276c 100644 --- a/testsuites/unittest/posix/src/stdlib/atoll_test.c +++ b/testsuites/unittest/posix/src/stdlib/atoll_test.c @@ -79,7 +79,7 @@ LITE_TEST_CASE(PosixStdlibAtollTest, testStdlibAtoll001, Function | MediumTest | } else { LOG("[DEMO] posix stdlib test case 1:atoll(%lld) fail.\n", value); } - TEST_ASSERT_TRUE(value == 9223372036854775807LL); + ICUNIT_ASSERT_EQUAL(value, 9223372036854775807LL, 0); return 0; } @@ -96,7 +96,7 @@ LITE_TEST_CASE(PosixStdlibAtollTest, testStdlibAtoll002, Function | MediumTest | } else { LOG("[DEMO] posix stdlib test case 2:atoll(%lld) fail.\n", value); } - TEST_ASSERT_TRUE(value == -9223372036854775808ULL); + ICUNIT_ASSERT_EQUAL(value, -9223372036854775808ULL, 0); return 0; } @@ -113,7 +113,7 @@ LITE_TEST_CASE(PosixStdlibAtollTest, testStdlibAtoll003, Function | MediumTest | } else { LOG("[DEMO] posix stdlib test case 3:atoll(%lld) fail.\n", value); } - TEST_ASSERT_TRUE(value == 100LL); + ICUNIT_ASSERT_EQUAL(value, 100LL, 0); return 0; } @@ -131,7 +131,7 @@ LITE_TEST_CASE(PosixStdlibAtollTest, testStdlibAtoll004, Function | MediumTest | } else { LOG("[DEMO] posix stdlib test case 4(except):atoll(%lld) fail.\n", value); } - TEST_ASSERT_EQUAL_INT64(LLONG_MIN, value); + ICUNIT_ASSERT_EQUAL(value, LLONG_MIN, 0); return 0; } @@ -149,7 +149,7 @@ LITE_TEST_CASE(PosixStdlibAtollTest, testStdlibAtoll005, Function | MediumTest | LOG("[DEMO] posix stdlib test case 5(except):atoll(%lld) fail.\n", value); } - TEST_ASSERT_EQUAL_INT64(LLONG_MAX, value); + ICUNIT_ASSERT_EQUAL(value, LLONG_MAX, 0); return 0; } #endif @@ -167,7 +167,7 @@ LITE_TEST_CASE(PosixStdlibAtollTest, testStdlibAtoll006, Function | MediumTest | } else { LOG("[DEMO] posix stdlib test case 6:atoll(%lld) fail.\n", value); } - TEST_ASSERT_TRUE(value == 100LL); + ICUNIT_ASSERT_EQUAL(value, 100LL, 0); return 0; } @@ -184,7 +184,7 @@ LITE_TEST_CASE(PosixStdlibAtollTest, testStdlibAtoll007, Function | MediumTest | } else { LOG("[DEMO] posix stdlib test case 7:atoll(%lld) fail.\n", value); } - TEST_ASSERT_TRUE(value == -100LL); + ICUNIT_ASSERT_EQUAL(value, -100LL, 0); return 0; } @@ -201,7 +201,7 @@ LITE_TEST_CASE(PosixStdlibAtollTest, testStdlibAtoll008, Function | MediumTest | } else { LOG("[DEMO] posix stdlib test case 8(except):atoll(%lld) fail.\n", value); } - TEST_ASSERT_TRUE(value == 0LL); + ICUNIT_ASSERT_EQUAL(value, 0LL, 0); return 0; } @@ -218,7 +218,7 @@ LITE_TEST_CASE(PosixStdlibAtollTest, testStdlibAtoll009, Function | MediumTest | } else { LOG("[DEMO] posix stdlib test case 9(except):atoll(%lld) fail.\n", value); } - TEST_ASSERT_TRUE(value == 12LL); + ICUNIT_ASSERT_EQUAL(value, 12LL, 0); return 0; } diff --git a/testsuites/unittest/posix/src/stdlib/strtol_test.c b/testsuites/unittest/posix/src/stdlib/strtol_test.c index b921a77d..28d81b15 100644 --- a/testsuites/unittest/posix/src/stdlib/strtol_test.c +++ b/testsuites/unittest/posix/src/stdlib/strtol_test.c @@ -80,8 +80,8 @@ LITE_TEST_CASE(PosixStdlibStrtolTest, testStdlibStrtol001, Function | MediumTest } else { LOG("[DEMO] posix stdlib test case 1:strtol(base=16) ret:%ld,%s fail.\n", ret, nPtr16); } - TEST_ASSERT_EQUAL_INT32(16, ret); - TEST_ASSERT_EQUAL_STRING(endPtr16, ""); + ICUNIT_ASSERT_EQUAL(ret, 16, ret); + ICUNIT_ASSERT_STRING_EQUAL(endPtr16, "", 0); return 0; } @@ -100,8 +100,8 @@ LITE_TEST_CASE(PosixStdlibStrtolTest, testStdlibStrtol002, Function | MediumTest } else { LOG("[DEMO] posix stdlib test case 2:strtol(base=16) ret:%ld,%s fail.\n", ret, nPtr16); } - TEST_ASSERT_EQUAL_INT32(16, ret); - TEST_ASSERT_EQUAL_STRING(endPtr16, ""); + ICUNIT_ASSERT_EQUAL(ret, 16, ret); + ICUNIT_ASSERT_STRING_EQUAL(endPtr16, "", 0); return 0; } @@ -120,8 +120,8 @@ LITE_TEST_CASE(PosixStdlibStrtolTest, testStdlibStrtol003, Function | MediumTest } else { LOG("[DEMO] posix stdlib test case 3:strtol(base=10) ret:%ld,%s fail.\n", ret, nPtr10); } - TEST_ASSERT_EQUAL_INT32(10, ret); - TEST_ASSERT_EQUAL_STRING(endPtr10, ""); + ICUNIT_ASSERT_EQUAL(ret, 10, ret); + ICUNIT_ASSERT_STRING_EQUAL(endPtr10, "", 0); return 0; } @@ -140,8 +140,8 @@ LITE_TEST_CASE(PosixStdlibStrtolTest, testStdlibStrtol004, Function | MediumTest } else { LOG("[DEMO] posix stdlib test case 4:strtol(base=10) ret:%ld,%s fail.\n", ret, nPtr10); } - TEST_ASSERT_EQUAL_INT32(-10, ret); - TEST_ASSERT_EQUAL_STRING(endPtr10, ""); + ICUNIT_ASSERT_EQUAL(ret, -10, ret); + ICUNIT_ASSERT_STRING_EQUAL(endPtr10, "", 0); return 0; } @@ -160,8 +160,8 @@ LITE_TEST_CASE(PosixStdlibStrtolTest, testStdlibStrtol005, Function | MediumTest } else { LOG("[DEMO] posix stdlib test case 5:strtol(base=0) ret:%ld,%s fail.\n", ret, nPtr10_3); } - TEST_ASSERT_EQUAL_INT32(10, ret); - TEST_ASSERT_EQUAL_STRING(endPtr10_3, ""); + ICUNIT_ASSERT_EQUAL(ret, 10, ret); + ICUNIT_ASSERT_STRING_EQUAL(endPtr10_3, "", 0); return 0; } @@ -180,8 +180,8 @@ LITE_TEST_CASE(PosixStdlibStrtolTest, testStdlibStrtol006, Function | MediumTest } else { LOG("[DEMO] posix stdlib test case 6:strtol(base=8) ret:%ld,%s fail.\n", ret, nPtr8); } - TEST_ASSERT_EQUAL_INT32(8, ret); - TEST_ASSERT_EQUAL_STRING(endPtr8, ""); + ICUNIT_ASSERT_EQUAL(ret, 8, ret); + ICUNIT_ASSERT_STRING_EQUAL(endPtr8, "", 0); return 0; } @@ -200,8 +200,8 @@ LITE_TEST_CASE(PosixStdlibStrtolTest, testStdlibStrtol007, Function | MediumTest } else { LOG("[DEMO] posix stdlib test case 7:strtol(base=8) ret:%ld,%s fail.\n", ret, nPtr8_2); } - TEST_ASSERT_EQUAL_INT32(8, ret); - TEST_ASSERT_EQUAL_STRING(endPtr8_2, ""); + ICUNIT_ASSERT_EQUAL(ret, 8, ret); + ICUNIT_ASSERT_STRING_EQUAL(endPtr8_2, "", 0); return 0; } @@ -220,8 +220,8 @@ LITE_TEST_CASE(PosixStdlibStrtolTest, testStdlibStrtol008, Function | MediumTest } else { LOG("[DEMO] posix stdlib test case 8:strtol(base=8) ret:%ld,%s fail.\n", ret, nPtr8_3); } - TEST_ASSERT_EQUAL_INT32(8, ret); - TEST_ASSERT_EQUAL_STRING(endPtr8_3, ""); + ICUNIT_ASSERT_EQUAL(ret, 8, ret); + ICUNIT_ASSERT_STRING_EQUAL(endPtr8_3, "", 0); return 0; } @@ -240,8 +240,8 @@ LITE_TEST_CASE(PosixStdlibStrtolTest, testStdlibStrtol009, Function | MediumTest } else { LOG("[DEMO] posix stdlib test case 9:strtol(base=2) ret:%ld,%s fail.\n", ret, nPtr2); } - TEST_ASSERT_EQUAL_INT32(2, ret); - TEST_ASSERT_EQUAL_STRING(endPtr2, ""); + ICUNIT_ASSERT_EQUAL(ret, 2, ret); + ICUNIT_ASSERT_STRING_EQUAL(endPtr2, "", 0); return 0; } @@ -260,8 +260,8 @@ LITE_TEST_CASE(PosixStdlibStrtolTest, testStdlibStrtol010, Function | MediumTest } else { LOG("[DEMO] posix stdlib test case 10:strtol(base=10) ret:%ld, %s fail.\n", ret, endPtr); } - TEST_ASSERT_EQUAL_INT32(12, ret); - TEST_ASSERT_EQUAL_STRING(endPtr, " 0110 0XDEFE 0666 -1.6"); + ICUNIT_ASSERT_EQUAL(ret, 12, ret); + ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 0110 0XDEFE 0666 -1.6", 0); return 0; } @@ -281,8 +281,8 @@ LITE_TEST_CASE(PosixStdlibStrtolTest, testStdlibStrtol011, Function | MediumTest } else { LOG("[DEMO] posix stdlib test case 11:strtol(base=65) ret:%ld, %s fail.\n", ret, endPtr); } - TEST_ASSERT_EQUAL_INT32(0, ret); - TEST_ASSERT_EQUAL_STRING(endPtr, "12 1.5"); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ICUNIT_ASSERT_STRING_EQUAL(endPtr, "12 1.5", 0); return 0; } #endif @@ -297,8 +297,8 @@ LITE_TEST_CASE(PosixStdlibStrtolTest, testStdlibStrtol012, Function | MediumTest } else { LOG("[DEMO] posix stdlib test case 12:strtol(base=10) ret:%ld, %s fail.\n", ret, endPtr); } - TEST_ASSERT_EQUAL_INT32(2147483647, ret); - TEST_ASSERT_EQUAL_STRING(endPtr, " -2147483648"); + ICUNIT_ASSERT_EQUAL(ret, 2147483647, ret); + ICUNIT_ASSERT_STRING_EQUAL(endPtr, " -2147483648", 0); return 0; } @@ -317,8 +317,8 @@ LITE_TEST_CASE(PosixStdlibStrtolTest, testStdlibStrtol013, Function | MediumTest } else { LOG("[DEMO] posix stdlib test case 13:strtol(base=10) ret:%ld, %s fail.\n", ret, endPtr); } - TEST_ASSERT_EQUAL_INT32(-2147483648, ret); - TEST_ASSERT_EQUAL_STRING(endPtr, ""); + ICUNIT_ASSERT_EQUAL(ret, -2147483648, ret); + ICUNIT_ASSERT_STRING_EQUAL(endPtr, "", 0); return 0; } diff --git a/testsuites/unittest/posix/src/stdlib/strtoul_test.c b/testsuites/unittest/posix/src/stdlib/strtoul_test.c index a99aa1b9..30341222 100644 --- a/testsuites/unittest/posix/src/stdlib/strtoul_test.c +++ b/testsuites/unittest/posix/src/stdlib/strtoul_test.c @@ -81,8 +81,8 @@ LITE_TEST_CASE(PosixStdlibStrtoulTest, testStdlibStrtoul001, Function | MediumTe } else { LOG("[DEMO] posix stdlib test case 1:strtoul(base=10) ret:%lu,%s fail.\n", ret, nPtr); } - TEST_ASSERT_EQUAL_UINT32(12UL, ret); - TEST_ASSERT_EQUAL_STRING(endPtr, " 0110 0XDEFE 0666 4294967295 4294967296 12.34"); + ICUNIT_ASSERT_EQUAL(ret, 12UL, ret); + ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 0110 0XDEFE 0666 4294967295 4294967296 12.34", 0); return 0; } @@ -101,8 +101,8 @@ LITE_TEST_CASE(PosixStdlibStrtoulTest, testStdlibStrtoul002, Function | MediumTe } else { LOG("[DEMO] posix stdlib test case 2:strtoul(base=2) ret:%lu,%s fail.\n", ret, endPtr); } - TEST_ASSERT_EQUAL_UINT32(6UL, ret); - TEST_ASSERT_EQUAL_STRING(endPtr, " 0XDEFE 0666 4294967295 4294967296 12.34"); + ICUNIT_ASSERT_EQUAL(ret, 6UL, ret); + ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 0XDEFE 0666 4294967295 4294967296 12.34", 0); return 0; } @@ -121,8 +121,8 @@ LITE_TEST_CASE(PosixStdlibStrtoulTest, testStdlibStrtoul003, Function | MediumTe } else { LOG("[DEMO] posix stdlib test case 3:strtoul(base=16) ret:%lu,%s fail.\n", ret, endPtr); } - TEST_ASSERT_EQUAL_UINT32(0XDEFEUL, ret); - TEST_ASSERT_EQUAL_STRING(endPtr, " 0666 4294967295 4294967296 12.34"); + ICUNIT_ASSERT_EQUAL(ret, 0XDEFEUL, ret); + ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 0666 4294967295 4294967296 12.34", 0); return 0; } @@ -141,8 +141,8 @@ LITE_TEST_CASE(PosixStdlibStrtoulTest, testStdlibStrtoul004, Function | MediumTe } else { LOG("[DEMO] posix stdlib test case 4:strtoul(base=8) ret:%lu,%s fail.\n", ret, endPtr); } - TEST_ASSERT_EQUAL_UINT32(0666UL, ret); - TEST_ASSERT_EQUAL_STRING(endPtr, " 4294967295 4294967296 12.34"); + ICUNIT_ASSERT_EQUAL(ret, 0666UL, ret); + ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 4294967295 4294967296 12.34", 0); return 0; } @@ -161,8 +161,8 @@ LITE_TEST_CASE(PosixStdlibStrtoulTest, testStdlibStrtoul005, Function | MediumTe } else { LOG("[DEMO] posix stdlib test case 5:strtoul(base=0) ret:%lu,%s fail.\n", ret, endPtr); } - TEST_ASSERT_EQUAL_UINT32(4294967295UL, ret); - TEST_ASSERT_EQUAL_STRING(endPtr, " 4294967296 12.34"); + ICUNIT_ASSERT_EQUAL(ret, 4294967295UL, ret); + ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 4294967296 12.34", 0); return 0; } @@ -182,8 +182,8 @@ LITE_TEST_CASE(PosixStdlibStrtoulTest, testStdlibStrtoul006, Function | MediumTe LOG("[DEMO] posix stdlib test case 6:strtoul(base=0) ret:%lu,%s fail.\n", ret, endPtr); } - TEST_ASSERT_EQUAL_UINT32(ULONG_MAX, ret); - TEST_ASSERT_EQUAL_STRING(endPtr, " 12.34"); + ICUNIT_ASSERT_EQUAL(ret, ULONG_MAX, ret); + ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 12.34", 0); return 0; } @@ -203,8 +203,8 @@ LITE_TEST_CASE(PosixStdlibStrtoulTest, testStdlibStrtoul007, Function | MediumTe } else { LOG("[DEMO] posix stdlib test case 7:strtoul(base=65) ret:%lu,%s fail.\n", ret, endPtr); } - TEST_ASSERT_EQUAL_UINT32(0UL, ret); - TEST_ASSERT_EQUAL_STRING(endPtr, " 12.34"); + ICUNIT_ASSERT_EQUAL(ret, 0UL, ret); + ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 12.34", 0); return 0; } #endif @@ -224,8 +224,8 @@ LITE_TEST_CASE(PosixStdlibStrtoulTest, testStdlibStrtoul008, Function | MediumTe } else { LOG("[DEMO] posix stdlib test case 8:strtoul(base=0) ret:%lu,%s fail.\n", ret, endPtr); } - TEST_ASSERT_EQUAL_UINT32(0UL, ret); - TEST_ASSERT_EQUAL_STRING(endPtr, ".34"); + ICUNIT_ASSERT_EQUAL(ret, 0UL, ret); + ICUNIT_ASSERT_STRING_EQUAL(endPtr, ".34", 0); return 0; } @@ -244,8 +244,8 @@ LITE_TEST_CASE(PosixStdlibStrtoulTest, testStdlibStrtoul009, Function | MediumTe } else { LOG("[DEMO] posix stdlib test case 9:strtoul(base=0) ret:%lu,%s fail.\n", ret, endPtr); } - TEST_ASSERT_EQUAL_UINT32(0XDEFE, ret); - TEST_ASSERT_EQUAL_STRING(endPtr, " 0666"); + ICUNIT_ASSERT_EQUAL(ret, 0XDEFE, ret); + ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 0666", 0); return 0; } @@ -264,8 +264,8 @@ LITE_TEST_CASE(PosixStdlibStrtoulTest, testStdlibStrtoul010, Function | MediumTe } else { LOG("[DEMO] posix stdlib test case 9:strtoul(base=0) ret:%lu,%s fail.\n", ret, endPtr); } - TEST_ASSERT_EQUAL_UINT32(0666, ret); - TEST_ASSERT_EQUAL_STRING(endPtr, ""); + ICUNIT_ASSERT_EQUAL(ret, 0666, ret); + ICUNIT_ASSERT_STRING_EQUAL(endPtr, "", 0); return 0; } diff --git a/testsuites/unittest/posix/src/stdlib/strtoull_test.c b/testsuites/unittest/posix/src/stdlib/strtoull_test.c index 7c545b61..da7beaaf 100644 --- a/testsuites/unittest/posix/src/stdlib/strtoull_test.c +++ b/testsuites/unittest/posix/src/stdlib/strtoull_test.c @@ -82,8 +82,8 @@ LITE_TEST_CASE(PosixStdlibStrtoullTest, testStdlibStrtoull001, Function | Medium } else { LOG("[DEMO] posix stdlib test case 1:strtoull(base=10) ret:%llu,%s fail.\n", ret, nPtr); } - TEST_ASSERT_TRUE(ret == 12ULL); - TEST_ASSERT_EQUAL_STRING(endPtr, " 0110 0XDEFE 0666 1.6"); + ICUNIT_ASSERT_EQUAL(ret, 12ULL, 0); + ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 0110 0XDEFE 0666 1.6", 0); return 0; } @@ -102,8 +102,8 @@ LITE_TEST_CASE(PosixStdlibStrtoullTest, testStdlibStrtoull002, Function | Medium } else { LOG("[DEMO] posix stdlib test case 2:strtoull(base=2) ret:%llu,%s fail.\n", ret, nPtr); } - TEST_ASSERT_TRUE(ret == 6ULL); - TEST_ASSERT_EQUAL_STRING(endPtr, " 0XDEFE 0666 1.6"); + ICUNIT_ASSERT_EQUAL(ret, 6ULL, 0); + ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 0XDEFE 0666 1.6", 0); return 0; } @@ -122,8 +122,8 @@ LITE_TEST_CASE(PosixStdlibStrtoullTest, testStdlibStrtoull003, Function | Medium } else { LOG("[DEMO] posix stdlib test case 3:strtoull(base=16) ret:%llu,%s fail.\n", ret, nPtr); } - TEST_ASSERT_TRUE(ret == 0XDEFEULL); - TEST_ASSERT_EQUAL_STRING(endPtr, " 0666 1.6"); + ICUNIT_ASSERT_EQUAL(ret, 0XDEFEULL, 0); + ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 0666 1.6", 0); return 0; } @@ -142,8 +142,8 @@ LITE_TEST_CASE(PosixStdlibStrtoullTest, testStdlibStrtoull004, Function | Medium } else { LOG("[DEMO] posix stdlib test case 4:strtoull(base=8) ret:%llu,%s fail.\n", ret, nPtr); } - TEST_ASSERT_TRUE(ret == 0666ULL); - TEST_ASSERT_EQUAL_STRING(endPtr, " 1.6"); + ICUNIT_ASSERT_EQUAL(ret, 0666ULL, 0); + ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 1.6", 0); return 0; } @@ -163,8 +163,8 @@ LITE_TEST_CASE(PosixStdlibStrtoullTest, testStdlibStrtoull005, Function | Medium } else { LOG("[DEMO] posix stdlib test case 5:strtoull(base=65) ret:%llu,%s fail.\n", ret, nPtr); } - TEST_ASSERT_TRUE(ret == 0ULL); - TEST_ASSERT_EQUAL_STRING(endPtr, " 1.6"); + ICUNIT_ASSERT_EQUAL(ret, 0ULL, ret); + ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 1.6", 0); return 0; } #endif @@ -184,8 +184,8 @@ LITE_TEST_CASE(PosixStdlibStrtoullTest, testStdlibStrtoull006, Function | Medium } else { LOG("[DEMO] posix stdlib test case 6:strtoull(base=0) ret:%llu,%s fail.\n", ret, nPtr); } - TEST_ASSERT_TRUE(ret == 0ULL); - TEST_ASSERT_EQUAL_STRING(endPtr, ".6"); + ICUNIT_ASSERT_EQUAL(ret, 0ULL, 0); + ICUNIT_ASSERT_STRING_EQUAL(endPtr, ".6", 0); return 0; } @@ -204,8 +204,8 @@ LITE_TEST_CASE(PosixStdlibStrtoullTest, testStdlibStrtoull007, Function | Medium } else { LOG("[DEMO] posix stdlib test case 7:strtoull(base=10) ret:%llu,%s fail.\n", ret, nPtr); } - TEST_ASSERT_TRUE(ret == 18446744073709551615ULL); - TEST_ASSERT_EQUAL_STRING(endPtr, " 18446744073709551616"); + ICUNIT_ASSERT_EQUAL(ret, 18446744073709551615ULL, 0); + ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 18446744073709551616", 0); return 0; } @@ -225,9 +225,9 @@ LITE_TEST_CASE(PosixStdlibStrtoullTest, testStdlibStrtoull008, Function | Medium LOG("[DEMO] posix stdlib test case 8:strtoull(base=10) ret:%llu,%s fail.\n", ret, nPtr); } - TEST_ASSERT_EQUAL_UINT64(ULLONG_MAX, ret); - TEST_ASSERT_EQUAL_INT(ERANGE, errno); - TEST_ASSERT_EQUAL_STRING(endPtr, ""); + ICUNIT_ASSERT_EQUAL(ret, ULLONG_MAX, ret); + ICUNIT_ASSERT_EQUAL(errno, ERANGE, errno); + ICUNIT_ASSERT_STRING_EQUAL(endPtr, "", 0); return 0; } @@ -246,8 +246,8 @@ LITE_TEST_CASE(PosixStdlibStrtoullTest, testStdlibStrtoull009, Function | Medium } else { LOG("[DEMO] posix stdlib test case 9:strtoull(base=0) ret:%llu,%s fail.\n", ret, nPtr); } - TEST_ASSERT_TRUE(ret == 0XDEFEULL); - TEST_ASSERT_EQUAL_STRING(endPtr, " 0666"); + ICUNIT_ASSERT_EQUAL(ret, 0XDEFEULL, ret); + ICUNIT_ASSERT_STRING_EQUAL(endPtr, " 0666", 0); return 0; } @@ -266,8 +266,8 @@ LITE_TEST_CASE(PosixStdlibStrtoullTest, testStdlibStrtoull010, Function | Medium } else { LOG("[DEMO] posix stdlib test case 10:strtoull(base=0) ret:%llu,%s fail.\n", ret, nPtr); } - TEST_ASSERT_TRUE(ret == 0666ULL); - TEST_ASSERT_EQUAL_STRING(endPtr, ""); + ICUNIT_ASSERT_EQUAL(ret, 0666ULL, ret); + ICUNIT_ASSERT_STRING_EQUAL(endPtr, "", 0); return 0; } diff --git a/testsuites/unittest/posix/src/string/memory_func_test.c b/testsuites/unittest/posix/src/string/memory_func_test.c index 81f1bb62..ce9d7e1c 100644 --- a/testsuites/unittest/posix/src/string/memory_func_test.c +++ b/testsuites/unittest/posix/src/string/memory_func_test.c @@ -77,12 +77,12 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemMemcpy001, Function | MediumTest char dest[1024] = {0}; retValue = memcpy(dest, source, sizeof(source) / sizeof(source[0])); - TEST_ASSERT_NOT_NULL(retValue); + ICUNIT_ASSERT_NOT_EQUAL(retValue, NULL, 0); retValue = memcpy(source, dest, sizeof(source) / sizeof(source[0])); - TEST_ASSERT_NOT_NULL(retValue); + ICUNIT_ASSERT_NOT_EQUAL(retValue, NULL, 0); - TEST_ASSERT_EQUAL_STRING(dest, source); + ICUNIT_ASSERT_STRING_EQUAL(dest, source, 0); int len; char chr = 'A'; @@ -95,7 +95,7 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemMemcpy001, Function | MediumTest memcpy(&buf[16], &buf[0], 16); for (int i = 0; i < 16; i++) { - TEST_ASSERT_EQUAL_INT((int)buf[i + 16], (int)buf[i]); + ICUNIT_ASSERT_EQUAL(buf[i + 16], buf[i], 0); if (buf[i + 16] != buf[i]) { printf("String Copy error \r\n"); break; @@ -118,11 +118,11 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemMemcpy002, Function | MediumTest " immediate use in a computer\r\n"}; char dest[1024] = {0}; retValue = memcpy(dest, source, sizeof(source) / sizeof(source[0])); - TEST_ASSERT_NOT_NULL(retValue); + ICUNIT_ASSERT_NOT_EQUAL(retValue, NULL, 0); retValue = memcpy(source, dest, sizeof(source) / sizeof(source[0])); - TEST_ASSERT_NOT_NULL(retValue); - TEST_ASSERT_EQUAL_STRING(source, dest); + ICUNIT_ASSERT_NOT_EQUAL(retValue, NULL, 0); + ICUNIT_ASSERT_STRING_EQUAL(dest, source, 0); char chr = 'A'; int i, len, failure; @@ -142,7 +142,7 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemMemcpy002, Function | MediumTest break; } } - TEST_ASSERT_EQUAL_INT(0, failure); + ICUNIT_ASSERT_EQUAL(failure, 0, failure); return 0; }; @@ -159,11 +159,11 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemMemset001, Function | MediumTest " immediate use in a computer\r\n"}; char ch = rand() % 26 + 'A'; retValue = memset(source, ch, sizeof(source) / sizeof(source[0])); - TEST_ASSERT_NOT_NULL(retValue); - TEST_ASSERT_EQUAL_PTR(source, retValue); + ICUNIT_ASSERT_NOT_EQUAL(retValue, NULL, 0); + ICUNIT_ASSERT_EQUAL(retValue, source, 0); for (int i = 0; i < (sizeof(source) / sizeof(source[0])); i++) { - TEST_ASSERT_EQUAL_INT((int)ch, (int)source[i]); + ICUNIT_ASSERT_EQUAL(source[i], ch, 0); } return 0; }; @@ -183,7 +183,7 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemMemcmp001, Function | MediumTest "immediate use in a computer\r\n"}; retValue = memcmp(source, dest, sizeof(source) / sizeof(source[0])); - TEST_ASSERT_EQUAL_INT(0, retValue); + ICUNIT_ASSERT_EQUAL(retValue, 0, retValue); char orign[8] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88}; @@ -195,16 +195,16 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemMemcmp001, Function | MediumTest int len = sizeof(orign); ret = memcmp(orign, lt, len); - TEST_ASSERT_GREATER_THAN(0, ret); + ICUNIT_ASSERT_WITHIN_EQUAL(ret, 1, ret, 0); ret = memcmp(eq, orign, len); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); ret = memcmp(orign, gt, len); - TEST_ASSERT_LESS_THAN(0, ret); + ICUNIT_ASSERT_WITHIN_EQUAL(ret, ret, -1, 0); ret = memcmp(gt, orign, 0); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; }; @@ -221,16 +221,16 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemMemcmp002, Function | MediumTest "immediate use in a computer\r\n"}; char dest[] = {"Hello, Richard, how are you?\r\n"}; retValue = memcmp(source, dest, sizeof(dest) / sizeof(dest[0])); - TEST_ASSERT_GREATER_THAN(0, retValue); + ICUNIT_ASSERT_WITHIN_EQUAL(retValue, 1, retValue, 0); int ret = memcmp(L"CBCDEFG", L"BBCDEFG", 7); - TEST_ASSERT_GREATER_THAN(0, ret); + ICUNIT_ASSERT_WITHIN_EQUAL(ret, 1, ret, 0); ret = memcmp(L"ABCDEFG", L"abcdefg", 2); - TEST_ASSERT_LESS_THAN(0, ret); + ICUNIT_ASSERT_WITHIN_EQUAL(ret, ret, -1, 0); ret = memcmp(L"ABCDEFG", L"ABCDEFG", 6); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; }; @@ -247,7 +247,7 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemMemcmp003, Function | MediumTest char dest[] = {"memory refers to the computer hardware devices used to store information for " "immediate use in a computer\r\n"}; retValue = memcmp(source, dest, sizeof(source) / sizeof(source[0])); - TEST_ASSERT_LESS_THAN(0, retValue); + ICUNIT_ASSERT_WITHIN_EQUAL(retValue, retValue, -1, 0); return 0; }; @@ -261,7 +261,7 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemRealloc001, Function | MediumTest { char *source = (char *)malloc(20); source = (char *)realloc(source, 0); - TEST_ASSERT_NULL(source); + ICUNIT_ASSERT_EQUAL(source, NULL, 0); size_t k, len, mlen, rlen; for (int i = 0; i < 5; i++) { @@ -272,7 +272,7 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemRealloc001, Function | MediumTest mlen = 10; mem = malloc(mlen); - TEST_ASSERT_NOT_NULL(mem); + ICUNIT_ASSERT_NOT_EQUAL(mem, NULL, 0); (void)memset_s(mem, mlen, testChar, mlen); rlen = rand() % (1024) + mlen; @@ -280,7 +280,7 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemRealloc001, Function | MediumTest if (mem1 == NULL) { free(mem); } - TEST_ASSERT_NOT_NULL(mem1); + ICUNIT_ASSERT_NOT_EQUAL(mem1, NULL, 0); len = mlen <= rlen ? mlen : rlen; @@ -292,7 +292,7 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemRealloc001, Function | MediumTest } free(mem1); - TEST_ASSERT_EQUAL_INT(0, failure); + ICUNIT_ASSERT_EQUAL(failure, 0, failure); } return 0; }; @@ -308,7 +308,7 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemRealloc002, Function | MediumTest char *source = (char *)malloc(20); char *newData = (char *)realloc(source, 40); - TEST_ASSERT_NOT_NULL(newData); + ICUNIT_ASSERT_NOT_EQUAL(newData, NULL, 0); if (newData != NULL) { source = newData; } @@ -318,10 +318,10 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemRealloc002, Function | MediumTest const size_t large = 4096; void *mem = malloc(len); - TEST_ASSERT_NOT_NULL(mem); + ICUNIT_ASSERT_NOT_EQUAL(mem, NULL, 0); void *reMem = realloc(mem, large); - TEST_ASSERT_NOT_NULL(reMem); + ICUNIT_ASSERT_NOT_EQUAL(reMem, NULL, 0); if (reMem != NULL) { mem = reMem; @@ -341,7 +341,7 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemRealloc003, Function | MediumTest char *retValue = NULL; retValue = (char *)realloc(retValue, 20); - TEST_ASSERT_NOT_NULL(retValue); + ICUNIT_ASSERT_NOT_EQUAL(retValue, NULL, 0); return 0; }; @@ -355,7 +355,7 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemRealloc004, Function | MediumTest char *source = (char *)malloc(20); char *newData = (char *)realloc(source, 10); - TEST_ASSERT_NOT_NULL(newData); + ICUNIT_ASSERT_NOT_EQUAL(newData, NULL, 0); if (newData != NULL) { source = newData; diff --git a/testsuites/unittest/posix/src/string/strchr_test.c b/testsuites/unittest/posix/src/string/strchr_test.c index f5a95eff..a089cf5b 100644 --- a/testsuites/unittest/posix/src/string/strchr_test.c +++ b/testsuites/unittest/posix/src/string/strchr_test.c @@ -79,7 +79,7 @@ LITE_TEST_CASE(PosixStringStrchrTest, testStringStrchr001, Function | MediumTest } else { LOG("[DEMO] posix string test case 1:strchr(!) %s fail.\n", src); } - TEST_ASSERT_EQUAL_STRING(ret, "!! world"); + ICUNIT_ASSERT_STRING_EQUAL(ret, "!! world", 0); return 0; } @@ -97,7 +97,7 @@ LITE_TEST_CASE(PosixStringStrchrTest, testStringStrchr002, Function | MediumTest } else { LOG("[DEMO] posix string test case 2:strchr(l) %s fail.\n", src); } - TEST_ASSERT_EQUAL_STRING(ret, "llo !! world"); + ICUNIT_ASSERT_STRING_EQUAL(ret, "llo !! world", 0); return 0; } @@ -115,7 +115,7 @@ LITE_TEST_CASE(PosixStringStrchrTest, testStringStrchr003, Function | MediumTest } else { LOG("[DEMO] posix string test case 3:strchr(\'\\0\') %s fail.\n", src); } - TEST_ASSERT_NOT_NULL(ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, NULL, 0); return 0; } @@ -133,7 +133,7 @@ LITE_TEST_CASE(PosixStringStrchrTest, testStringStrchr004, Function | MediumTest } else { LOG("[DEMO] posix string test case 4(except):strchr(?) %s fail.\n", src); } - TEST_ASSERT_NULL(ret); + ICUNIT_ASSERT_EQUAL(ret, NULL, 0); return 0; } @@ -151,7 +151,7 @@ LITE_TEST_CASE(PosixStringStrchrTest, testStringStrchr005, Function | MediumTest } else { LOG("[DEMO] posix string test case 5(except):strchr(m) %s fail.\n", src); } - TEST_ASSERT_NULL(ret); + ICUNIT_ASSERT_EQUAL(ret, NULL, 0); return 0; } @@ -169,7 +169,7 @@ LITE_TEST_CASE(PosixStringStrchrTest, testStringStrchr006, Function | MediumTest } else { LOG("[DEMO] posix string test case 6(except):strchr(0) %s fail.\n", src); } - TEST_ASSERT_NOT_NULL(ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, NULL, 0); return 0; } diff --git a/testsuites/unittest/posix/src/string/string_func_test_01.c b/testsuites/unittest/posix/src/string/string_func_test_01.c index 0e69a53b..586c1fa0 100644 --- a/testsuites/unittest/posix/src/string/string_func_test_01.c +++ b/testsuites/unittest/posix/src/string/string_func_test_01.c @@ -76,7 +76,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrlen001, Function | MediumT { char src[] = "helloworld"; int ret = strlen(src); - TEST_ASSERT_EQUAL_INT(10, ret); + ICUNIT_ASSERT_EQUAL(ret, 10, ret); return 0; } @@ -89,7 +89,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrlen002, Function | MediumT { char src[] = "hello world"; int ret = strlen(src); - TEST_ASSERT_EQUAL_INT(11, ret); + ICUNIT_ASSERT_EQUAL(ret, 11, ret); return 0; } @@ -101,7 +101,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrlen002, Function | MediumT LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrlen003, Function | MediumTest | Level1) { int ret = strlen(""); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -114,7 +114,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrlen004, Function | MediumT { char src[] = "hello\0world"; int ret = strlen(src); - TEST_ASSERT_EQUAL_INT(5, ret); + ICUNIT_ASSERT_EQUAL(ret, 5, ret); return 0; } @@ -127,7 +127,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrlen005, Function | MediumT { char src[] = "\0helloworld"; int ret = strlen(src); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); return 0; } @@ -141,7 +141,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrncasecmp001, Function | Me { char *src[] = {"helloworld", "HElloworld"}; int ret = strncasecmp(src[0], src[1], 2); - TEST_ASSERT_EQUAL_INT(RET_OK, ret); + ICUNIT_ASSERT_EQUAL(ret, RET_OK, ret); return 0; } @@ -154,7 +154,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrncasecmp002, Function | Me { char *src[] = {"helloworld", "he\0lloworld"}; int ret = strncasecmp(src[0], src[1], 3); - TEST_ASSERT_GREATER_THAN(RET_OK, ret); + ICUNIT_ASSERT_WITHIN_EQUAL(ret, RET_OK + 1, ret, 0); return 0; } @@ -167,7 +167,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrncasecmp003, Function | Me { char *src[] = {"helloworld", "he lloworld"}; int ret = strncasecmp(src[0], src[1], 3); - TEST_ASSERT_GREATER_THAN(RET_OK, ret); + ICUNIT_ASSERT_WITHIN_EQUAL(ret, RET_OK + 1, ret, 0); return 0; } @@ -180,7 +180,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrncasecmp004, Function | Me { char *src[] = {"helloworld", "hello World"}; int ret = strncasecmp(src[0], src[1], 3); - TEST_ASSERT_EQUAL_INT(RET_OK, ret); + ICUNIT_ASSERT_EQUAL(ret, RET_OK, ret); return 0; } @@ -193,7 +193,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrncasecmp005, Function | Me { char *src[] = {"helloworld", "\0"}; int ret = strncasecmp(src[0], src[1], 1); - TEST_ASSERT_GREATER_THAN(RET_OK, ret); + ICUNIT_ASSERT_WITHIN_EQUAL(ret, RET_OK + 1, ret, 0); return 0; } @@ -206,7 +206,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrncmp001, Function | Medium { char *src[] = {"helloworld", "HELloworld"}; int ret = strncmp(src[0], src[1], 3); - TEST_ASSERT_GREATER_THAN(RET_OK, ret); + ICUNIT_ASSERT_WITHIN_EQUAL(ret, RET_OK + 1, ret, 0); return 0; } @@ -219,7 +219,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrncmp002, Function | Medium { char *src[] = {"helloworld", "he\0lloworld"}; int ret = strncmp(src[0], src[1], 3); - TEST_ASSERT_GREATER_THAN(RET_OK, ret); + ICUNIT_ASSERT_WITHIN_EQUAL(ret, RET_OK + 1, ret, 0); return 0; } @@ -232,7 +232,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrncmp003, Function | Medium { char *src[] = {"helloworld", "he lloworld"}; int ret = strncmp(src[0], src[1], 3); - TEST_ASSERT_GREATER_THAN(RET_OK, ret); + ICUNIT_ASSERT_WITHIN_EQUAL(ret, RET_OK + 1, ret, 0); return 0; } @@ -245,7 +245,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrncmp004, Function | Medium { char *src[] = {"helloworld", "hello World"}; int ret = strncmp(src[0], src[1], 3); - TEST_ASSERT_EQUAL_INT(RET_OK, ret); + ICUNIT_ASSERT_EQUAL(ret, RET_OK, ret); return 0; } @@ -258,7 +258,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrncmp005, Function | Medium { char *src[] = {"helloworld", "\0"}; int ret = strncmp(src[0], src[1], 3); - TEST_ASSERT_GREATER_THAN(RET_OK, ret); + ICUNIT_ASSERT_WITHIN_EQUAL(ret, RET_OK + 1, ret, 0); return 0; } @@ -272,8 +272,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrrchr001, Function | Medium { char src[] = "hello world"; char *ret = strrchr(src, '!'); - TEST_ASSERT_EQUAL_PTR(NULL, ret); - TEST_ASSERT_NULL(ret); + ICUNIT_ASSERT_EQUAL(ret, NULL, 0); return 0; } @@ -286,8 +285,8 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrrchr002, Function | Medium { char src[] = "hello world"; char *ret = strrchr(src, '\0'); - TEST_ASSERT_EQUAL_PTR(src + 11, ret); - TEST_ASSERT_NOT_NULL(ret); + ICUNIT_ASSERT_EQUAL(ret, src + 11, 0); + ICUNIT_ASSERT_NOT_EQUAL(ret, NULL, 0); return 0; } @@ -300,8 +299,8 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrrchr003, Function | Medium { char src[] = "hello\0world"; char *ret = strrchr(src, '\0'); - TEST_ASSERT_EQUAL_PTR(src + 5, ret); - TEST_ASSERT_NOT_NULL(ret); + ICUNIT_ASSERT_EQUAL(ret, src + 5, 0); + ICUNIT_ASSERT_NOT_EQUAL(ret, NULL, 0); return 0; } @@ -314,8 +313,8 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrrchr004, Function | Medium { char src[] = "hello world"; char *ret = strrchr(src, ' '); - TEST_ASSERT_EQUAL_PTR(src + 5, ret); - TEST_ASSERT_NOT_NULL(ret); + ICUNIT_ASSERT_EQUAL(ret, src + 5, 0); + ICUNIT_ASSERT_NOT_EQUAL(ret, NULL, 0); return 0; } @@ -328,8 +327,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrrchr005, Function | Medium { char src[] = "hello\0world"; char *ret = strrchr(src, ' '); - TEST_ASSERT_EQUAL_PTR(NULL, ret); - TEST_ASSERT_NULL(ret); + ICUNIT_ASSERT_EQUAL(ret, NULL, 0); return 0; } diff --git a/testsuites/unittest/posix/src/string/string_func_test_02.c b/testsuites/unittest/posix/src/string/string_func_test_02.c index 51718e98..838f09d6 100644 --- a/testsuites/unittest/posix/src/string/string_func_test_02.c +++ b/testsuites/unittest/posix/src/string/string_func_test_02.c @@ -82,19 +82,19 @@ static BOOL PosixStringsFuncTestSuiteTearDown(void) LITE_TEST_CASE(PosixStringsFuncTestSuite, testStrCaseCmp001, Function | MediumTest | Level1) { int ret = strcasecmp("", ""); - TEST_ASSERT_EQUAL_INT(EQUAL, ret); + ICUNIT_ASSERT_EQUAL(ret, EQUAL, ret); ret = strcasecmp("abcdefg", "abcdefg"); - TEST_ASSERT_EQUAL_INT(EQUAL, ret); + ICUNIT_ASSERT_EQUAL(ret, EQUAL, ret); ret = strcasecmp("abcdefg", "abcdEFg"); - TEST_ASSERT_EQUAL_INT(EQUAL, ret); + ICUNIT_ASSERT_EQUAL(ret, EQUAL, ret); ret = strcasecmp("abcdefg", "abcdEF"); - TEST_ASSERT_NOT_EQUAL(EQUAL, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, EQUAL, ret); ret = strcasecmp("abcdef", "abcdEFg"); - TEST_ASSERT_NOT_EQUAL(EQUAL, ret); + ICUNIT_ASSERT_NOT_EQUAL(ret, EQUAL, ret); return 0; }; diff --git a/testsuites/unittest/posix/src/string/string_func_test_03.c b/testsuites/unittest/posix/src/string/string_func_test_03.c index b57737b6..141de680 100644 --- a/testsuites/unittest/posix/src/string/string_func_test_03.c +++ b/testsuites/unittest/posix/src/string/string_func_test_03.c @@ -78,14 +78,14 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStrstrcmp001, Function | MediumTest char dest[] = {"Compiler exited with error"}; retValue = strcmp(source, dest); - TEST_ASSERT_EQUAL_INT(0, retValue); + ICUNIT_ASSERT_EQUAL(retValue, 0, retValue); int ret = strcmp("abcdef", "ABCDEF"); - TEST_ASSERT_GREATER_THAN(0, ret); + ICUNIT_ASSERT_WITHIN_EQUAL(ret, 1, ret, 0); ret = strcmp("123456", "654321"); - TEST_ASSERT_LESS_THAN(0, ret); - TEST_ASSERT_EQUAL_INT(0, strcmp("~!@#$%^&*()_+", "~!@#$%^&*()_+")); + ICUNIT_ASSERT_WITHIN_EQUAL(ret, ret, -1, 0); + ICUNIT_ASSERT_EQUAL(strcmp("~!@#$%^&*()_+", "~!@#$%^&*()_+"), 0, 0); return 0; }; @@ -102,7 +102,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStrstrcmp002, Function | MediumTest char dest[] = {"00000000000"}; retValue = strcmp(source, dest); - TEST_ASSERT_GREATER_THAN(0, retValue); + ICUNIT_ASSERT_WITHIN_EQUAL(retValue, 1, retValue, 0); return 0; }; @@ -119,7 +119,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStrstrcmp003, Function | MediumTest char dest[] = {"Compiler exited with error"}; retValue = strcmp(source, dest); - TEST_ASSERT_LESS_THAN(0, retValue); + ICUNIT_ASSERT_WITHIN_EQUAL(retValue, retValue, -1, 0); return 0; }; @@ -135,18 +135,18 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStrStrdup001, Function | MediumTest char *dest; dest = strdup(source); - TEST_ASSERT_NOT_NULL(dest); + ICUNIT_ASSERT_NOT_EQUAL(dest, NULL, 0); printf("The Result Display :%s\r\n", dest); - TEST_ASSERT_EQUAL_CHAR_ARRAY(source, dest, sizeof(source) / sizeof(source[0])); + ICUNIT_ASSERT_SIZE_STRING_EQUAL(dest, source, sizeof(source) / sizeof(source[0]), 0); char src[] = "hello world !"; char *ret = strdup(src); - TEST_ASSERT_EQUAL_CHAR_ARRAY(src, ret, sizeof(src) / sizeof(src[0])); + ICUNIT_ASSERT_SIZE_STRING_EQUAL(ret, src, sizeof(src) / sizeof(src[0]), 0); free(ret); char srcS[] = "This is String1"; ret = strdup(srcS); - TEST_ASSERT_EQUAL_CHAR_ARRAY("This is String1", ret, sizeof(srcS) / sizeof(srcS[0])); + ICUNIT_ASSERT_SIZE_STRING_EQUAL(ret, "This is String1", sizeof(srcS) / sizeof(srcS[0]), 0); free(ret); return 0; }; @@ -163,9 +163,9 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStrStrdup002, Function | MediumTest char *dest; dest = strdup(source); - TEST_ASSERT_NOT_NULL(dest); + ICUNIT_ASSERT_NOT_EQUAL(dest, NULL, 0); printf("The Result Display :%s\r\n", dest); - TEST_ASSERT_EQUAL_CHAR_ARRAY(source, dest, sizeof(source) / sizeof(source[0])); + ICUNIT_ASSERT_SIZE_STRING_EQUAL(dest, source, sizeof(source) / sizeof(source[0]), 0); return 0; }; @@ -182,16 +182,16 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStrStrcspn001, Function | MediumTes char dest1[] = {"H"}; retValue = strcspn(source, dest1); - TEST_ASSERT_EQUAL_INT(18U, retValue); + ICUNIT_ASSERT_EQUAL(retValue, 18U, retValue); const char dest[] = "hello world !"; const char src[] = "!"; size_t ret = strcspn(dest, src); - TEST_ASSERT_EQUAL_INT(12U, ret); + ICUNIT_ASSERT_EQUAL(ret, 12U, ret); const char srcS[] = "a"; ret = strcspn(dest, srcS); - TEST_ASSERT_EQUAL_INT(13U, ret); + ICUNIT_ASSERT_EQUAL(ret, 13U, ret); return 0; }; @@ -207,7 +207,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStrStrcspn002, Function | MediumTes char dest[] = {"or"}; retValue = strcspn(source, dest); - TEST_ASSERT_EQUAL_INT(1, retValue); + ICUNIT_ASSERT_EQUAL(retValue, 1, retValue); return 0; }; @@ -222,12 +222,12 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStrStrptime001, Function | MediumTe struct tm tmData; (void)memset_s(&tmData, sizeof(struct tm), 0, sizeof(struct tm)); char *ret = strptime("2020-10-29 21:24:00abc", "%Y-%m-%d %H:%M:%S", &tmData); - TEST_ASSERT_EQUAL_CHAR_ARRAY("abc", ret, 3); - TEST_ASSERT_EQUAL_INT(120, tmData.tm_year); - TEST_ASSERT_EQUAL_INT(9, tmData.tm_mon); - TEST_ASSERT_EQUAL_INT(29, tmData.tm_mday); - TEST_ASSERT_EQUAL_INT(21, tmData.tm_hour); - TEST_ASSERT_EQUAL_INT(24, tmData.tm_min); + ICUNIT_ASSERT_SIZE_STRING_EQUAL(ret, "abc", 3, 0); + ICUNIT_ASSERT_EQUAL(tmData.tm_year, 120, tmData.tm_year); + ICUNIT_ASSERT_EQUAL(tmData.tm_mon, 9, tmData.tm_mon); + ICUNIT_ASSERT_EQUAL(tmData.tm_mday, 29, tmData.tm_mday); + ICUNIT_ASSERT_EQUAL(tmData.tm_hour, 21, tmData.tm_hour); + ICUNIT_ASSERT_EQUAL(tmData.tm_min, 24, tmData.tm_min); return 0; } #endif diff --git a/testsuites/unittest/posix/src/string/strstr_test.c b/testsuites/unittest/posix/src/string/strstr_test.c index ddc52e22..816b5267 100644 --- a/testsuites/unittest/posix/src/string/strstr_test.c +++ b/testsuites/unittest/posix/src/string/strstr_test.c @@ -80,7 +80,7 @@ LITE_TEST_CASE(PosixStringStrStrTest, testStringStrStr001, Function | MediumTest } else { LOG("[DEMO] posix string test case 1:strstr(%s) %s fail.\n", srcS, destS); } - TEST_ASSERT_EQUAL_STRING(ret, destS); + ICUNIT_ASSERT_STRING_EQUAL(ret, destS, 0); return 0; } @@ -100,7 +100,7 @@ LITE_TEST_CASE(PosixStringStrStrTest, testStringStrStr002, Function | MediumTest } else { LOG("[DEMO] posix string test case 2:strstr(%s) %s fail.\n", srcS, destS); } - TEST_ASSERT_EQUAL_STRING(ret, "this is string"); + ICUNIT_ASSERT_STRING_EQUAL(ret, "this is string", 0); return 0; } @@ -120,7 +120,7 @@ LITE_TEST_CASE(PosixStringStrStrTest, testStringStrStr003, Function | MediumTest } else { LOG("[DEMO] posix string test case 3:strstr(%s) %s fail.\n", srcT, dest); } - TEST_ASSERT_EQUAL_STRING(ret, dest); + ICUNIT_ASSERT_STRING_EQUAL(ret, dest, 0); return 0; } @@ -140,7 +140,7 @@ LITE_TEST_CASE(PosixStringStrStrTest, testStringStrStr004, Function | MediumTest } else { LOG("[DEMO] posix string test case 4(except):strstr(%s) %s fail.\n", src, dest); } - TEST_ASSERT_NULL(ret); + ICUNIT_ASSERT_EQUAL(ret, NULL, 0); return 0; } @@ -160,7 +160,7 @@ LITE_TEST_CASE(PosixStringStrStrTest, testStringStrStr005, Function | MediumTest } else { LOG("[DEMO] posix string test case 5(except):strstr(%s) %s fail.\n", src, dest); } - TEST_ASSERT_NULL(ret); + ICUNIT_ASSERT_EQUAL(ret, NULL, 0); return 0; } @@ -180,7 +180,7 @@ LITE_TEST_CASE(PosixStringStrStrTest, testStringStrStr006, Function | MediumTest } else { LOG("[DEMO] posix string test case 6:strstr(%s) %s fail.\n", srcOne, destS); } - TEST_ASSERT_EQUAL_STRING(ret, "tring this is string"); + ICUNIT_ASSERT_STRING_EQUAL(ret, "tring this is string", 0); return 0; } @@ -200,7 +200,7 @@ LITE_TEST_CASE(PosixStringStrStrTest, testStringStrStr007, Function | MediumTest } else { LOG("[DEMO] posix string test case 7(except):strstr(%s) %s fail.\n", srcOne, destS); } - TEST_ASSERT_NULL(ret); + ICUNIT_ASSERT_EQUAL(ret, NULL, 0); return 0; } @@ -220,7 +220,7 @@ LITE_TEST_CASE(PosixStringStrStrTest, testStringStrStr008, Function | MediumTest } else { LOG("[DEMO] posix string test case 8:strstr(%s) %s fail.\n", srcTwo, destS); } - TEST_ASSERT_EQUAL_STRING(ret, "this is string"); + ICUNIT_ASSERT_STRING_EQUAL(ret, "this is string", 0); return 0; } @@ -240,7 +240,7 @@ LITE_TEST_CASE(PosixStringStrStrTest, testStringStrStr009, Function | MediumTest } else { LOG("[DEMO] posix string test case 9(except):strstr(%s) %s fail.\n", srcTwo2, destS); } - TEST_ASSERT_NULL(ret); + ICUNIT_ASSERT_EQUAL(ret, NULL, 0); return 0; } @@ -260,7 +260,7 @@ LITE_TEST_CASE(PosixStringStrStrTest, testStringStrStr010, Function | MediumTest } else { LOG("[DEMO] posix string test case 10:strstr(%s) %s fail.\n", srcThree, destS); } - TEST_ASSERT_EQUAL_STRING(ret, "this is string"); + ICUNIT_ASSERT_STRING_EQUAL(ret, "this is string", 0); return 0; } @@ -280,7 +280,7 @@ LITE_TEST_CASE(PosixStringStrStrTest, testStringStrStr011, Function | MediumTest } else { LOG("[DEMO] posix string test case 11(except):strstr(%s) %s fail.\n", srcThree, destS); } - TEST_ASSERT_NULL(ret); + ICUNIT_ASSERT_EQUAL(ret, NULL, 0); return 0; } @@ -300,7 +300,7 @@ LITE_TEST_CASE(PosixStringStrStrTest, testStringStrStr012, Function | MediumTest } else { LOG("[DEMO] posix string test case 12:strstr(%s) %s fail.\n", srcFour, destS); } - TEST_ASSERT_EQUAL_STRING(ret, "this is string"); + ICUNIT_ASSERT_STRING_EQUAL(ret, "this is string", 0); return 0; } @@ -320,7 +320,7 @@ LITE_TEST_CASE(PosixStringStrStrTest, testStringStrStr013, Function | MediumTest } else { LOG("[DEMO] posix string test case 13(except):strstr(%s) %s fail.\n", srcFour, destS); } - TEST_ASSERT_NULL(ret); + ICUNIT_ASSERT_EQUAL(ret, NULL, 0); return 0; } diff --git a/testsuites/unittest/posix/src/time/time_func_test_01.c b/testsuites/unittest/posix/src/time/time_func_test_01.c index 7fbc0dee..d891bf1d 100644 --- a/testsuites/unittest/posix/src/time/time_func_test_01.c +++ b/testsuites/unittest/posix/src/time/time_func_test_01.c @@ -158,15 +158,15 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeUSleep001, Function | MediumTest clock_gettime(CLOCK_MONOTONIC, &time1); int rt = usleep(interval[j]); clock_gettime(CLOCK_MONOTONIC, &time2); - TEST_ASSERT_EQUAL_INT(RET_OK, rt); + ICUNIT_ASSERT_EQUAL(rt, RET_OK, rt); duration = (time2.tv_sec - time1.tv_sec) * 1000000 + (time2.tv_nsec - time1.tv_nsec) / 1000; LOG("testloop %d, actual usleep duration: %ld us\n", i, duration); d += duration; } d = d / ACCURACY_TEST_LOOPS; // average LOG("interval:%u, average duration: %.2f\n", interval[j], d); - TEST_ASSERT_GREATER_OR_EQUAL(interval[j], d); - TEST_ASSERT_INT32_WITHIN(SLEEP_ACCURACY, interval[j], d); + ICUNIT_ASSERT_WITHIN_EQUAL(d, interval[j], d, 0); + ICUNIT_ASSERT_WITHIN_EQUAL(d, interval[j] - SLEEP_ACCURACY, interval[j] + SLEEP_ACCURACY, d); } return 0; } @@ -183,10 +183,10 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeUSleep002, Function | MediumTest clock_gettime(CLOCK_MONOTONIC, &time1); int rt = usleep(0); clock_gettime(CLOCK_MONOTONIC, &time2); - TEST_ASSERT_EQUAL_INT(RET_OK, rt); + ICUNIT_ASSERT_EQUAL(rt, RET_OK, rt); long long duration = (time2.tv_sec - time1.tv_sec) * 1000000 + (time2.tv_nsec - time1.tv_nsec) / 1000; LOG("\n usleep(0), actual usleep duration: %lld us\n", duration); - TEST_ASSERT_LESS_OR_EQUAL_INT64(1000, duration); + ICUNIT_ASSERT_WITHIN_EQUAL(duration, duration, 1000, 0); return 0; } @@ -201,27 +201,27 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeGmtime001, Function | MediumTest char timeStr[TIME_STR_LEN] = {0}; LOG("\nsizeof(time_t) = %d, sizeof(struct tm) = %d", sizeof(time_t), sizeof(struct tm)); struct tm *timePtr = gmtime(&time1); - TEST_ASSERT_EQUAL_STRING("1970/1/1 05:14:40 WEEK(4)", TmToStr(timePtr, timeStr, TIME_STR_LEN)); + ICUNIT_ASSERT_STRING_EQUAL("1970/1/1 05:14:40 WEEK(4)", TmToStr(timePtr, timeStr, TIME_STR_LEN), 0); time1 = LONG_MAX; timePtr = gmtime(&time1); LOG("\n LONG_MAX = %lld, cvt result : %s", time1, TmToStr(timePtr, timeStr, TIME_STR_LEN)); - TEST_ASSERT_EQUAL_STRING("2038/1/19 03:14:07 WEEK(2)", TmToStr(timePtr, timeStr, TIME_STR_LEN)); + ICUNIT_ASSERT_STRING_EQUAL("2038/1/19 03:14:07 WEEK(2)", TmToStr(timePtr, timeStr, TIME_STR_LEN), 0); time1 = LONG_MAX - 1; timePtr = gmtime(&time1); LOG("\n LONG_MAX - 1 = %lld, cvt result : %s", time1, TmToStr(timePtr, timeStr, TIME_STR_LEN)); - TEST_ASSERT_EQUAL_STRING("2038/1/19 03:14:06 WEEK(2)", TmToStr(timePtr, timeStr, TIME_STR_LEN)); + ICUNIT_ASSERT_STRING_EQUAL("2038/1/19 03:14:06 WEEK(2)", TmToStr(timePtr, timeStr, TIME_STR_LEN), 0); time1 = LONG_MIN; timePtr = gmtime(&time1); LOG("\n LONG_MIN = %lld, cvt result : %s", time1, TmToStr(timePtr, timeStr, TIME_STR_LEN)); - TEST_ASSERT_EQUAL_STRING("1901/12/13 20:45:52 WEEK(5)", TmToStr(timePtr, timeStr, TIME_STR_LEN)); + ICUNIT_ASSERT_STRING_EQUAL("1901/12/13 20:45:52 WEEK(5)", TmToStr(timePtr, timeStr, TIME_STR_LEN), 0); time1 = LONG_MIN + 1; timePtr = gmtime(&time1); LOG("\n LONG_MIN + 1 = %lld, cvt result : %s", time1, TmToStr(timePtr, timeStr, TIME_STR_LEN)); - TEST_ASSERT_EQUAL_STRING("1901/12/13 20:45:53 WEEK(5)", TmToStr(timePtr, timeStr, TIME_STR_LEN)); + ICUNIT_ASSERT_STRING_EQUAL("1901/12/13 20:45:53 WEEK(5)", TmToStr(timePtr, timeStr, TIME_STR_LEN), 0); return 0; }; @@ -246,15 +246,15 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeLocaltime001, Function | MediumTe time(&tStart); sleep(2); time(&tEnd); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); struct tm *tmStart = localtime(&tStart); strftime(cTime, sizeof(cTime), "%H:%M:%S", tmStart); - TEST_ASSERT_EQUAL_STRING("07:59:59", cTime); + ICUNIT_ASSERT_STRING_EQUAL(cTime, "07:59:59", 0); LOG("\n time_t=%lld, first time:%s", tStart, cTime); struct tm *tmEnd = localtime(&tEnd); strftime(cTime, sizeof(cTime), "%H:%M:%S", tmEnd); - TEST_ASSERT_EQUAL_STRING("08:00:01", cTime); + ICUNIT_ASSERT_STRING_EQUAL(cTime, "08:00:01", 0); LOG("\n time_t=%lld, first time:%s", tEnd, cTime); return 0; } @@ -270,25 +270,25 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeLocaltime002, Function | MediumTe time_t tStart = LONG_MAX; struct tm *tmStart = localtime(&tStart); strftime(cTime, sizeof(cTime), "%y-%m-%d %H:%M:%S", tmStart); - TEST_ASSERT_EQUAL_STRING("38-01-19 11:14:07", cTime); + ICUNIT_ASSERT_STRING_EQUAL(cTime, "38-01-19 11:14:07", 0); LOG("\n time_t=%lld, first time:%s", tStart, cTime); tStart = LONG_MIN; tmStart = localtime(&tStart); strftime(cTime, sizeof(cTime), "%y-%m-%d %H:%M:%S", tmStart); - TEST_ASSERT_EQUAL_STRING("01-12-14 04:45:52", cTime); + ICUNIT_ASSERT_STRING_EQUAL(cTime, "01-12-14 04:45:52", 0); LOG("\n time_t=%lld, first time:%s", tStart, cTime); tStart = 0; tmStart = localtime(&tStart); strftime(cTime, sizeof(cTime), "%y-%m-%d %H:%M:%S", tmStart); - TEST_ASSERT_EQUAL_STRING("70-01-01 08:00:00", cTime); + ICUNIT_ASSERT_STRING_EQUAL(cTime, "70-01-01 08:00:00", 0); LOG("\n time_t=%lld, first time:%s", tStart, cTime); tStart = -1; tmStart = localtime(&tStart); strftime(cTime, sizeof(cTime), "%y-%m-%d %H:%M:%S", tmStart); - TEST_ASSERT_EQUAL_STRING("70-01-01 07:59:59", cTime); + ICUNIT_ASSERT_STRING_EQUAL(cTime, "70-01-01 07:59:59", 0); LOG("\n time_t=%lld, first time:%s", tStart, cTime); return 0; } @@ -314,19 +314,19 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeLocaltimer001, Function | MediumT time(&tStart); sleep(2); time(&tEnd); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); struct tm *tmrStartPtr = localtime_r(&tStart, &tmrStart); struct tm *tmrEndPtr = localtime_r(&tEnd, &tmrEnd); strftime(cTime, sizeof(cTime), "%H:%M:%S", &tmrStart); - TEST_ASSERT_EQUAL_STRING("07:59:59", cTime); + ICUNIT_ASSERT_STRING_EQUAL("07:59:59", cTime, 0); strftime(cTime, sizeof(cTime), "%H:%M:%S", tmrStartPtr); - TEST_ASSERT_EQUAL_STRING("07:59:59", cTime); + ICUNIT_ASSERT_STRING_EQUAL("07:59:59", cTime, 0); strftime(cTime, sizeof(cTime), "%H:%M:%S", &tmrEnd); - TEST_ASSERT_EQUAL_STRING("08:00:01", cTime); + ICUNIT_ASSERT_STRING_EQUAL("08:00:01", cTime, 0); strftime(cTime, sizeof(cTime), "%H:%M:%S", tmrEndPtr); - TEST_ASSERT_EQUAL_STRING("08:00:01", cTime); + ICUNIT_ASSERT_STRING_EQUAL("08:00:01", cTime, 0); return 0; } @@ -343,25 +343,25 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeLocaltimer002, Function | MediumT time_t tStart = LONG_MAX; struct tm *tmStart = localtime_r(&tStart, &tmrResult); strftime(cTime, sizeof(cTime), "%y-%m-%d %H:%M:%S", tmStart); - TEST_ASSERT_EQUAL_STRING("38-01-19 11:14:07", cTime); + ICUNIT_ASSERT_STRING_EQUAL("38-01-19 11:14:07", cTime, 0); LOG("\n time_t=%lld, first time:%s", tStart, cTime); tStart = LONG_MIN; tmStart = localtime_r(&tStart, &tmrResult); strftime(cTime, sizeof(cTime), "%y-%m-%d %H:%M:%S", tmStart); - TEST_ASSERT_EQUAL_STRING("01-12-14 04:45:52", cTime); + ICUNIT_ASSERT_STRING_EQUAL("01-12-14 04:45:52", cTime, 0); LOG("\n time_t=%lld, first time:%s", tStart, cTime); tStart = 0; tmStart = localtime_r(&tStart, &tmrResult); strftime(cTime, sizeof(cTime), "%y-%m-%d %H:%M:%S", tmStart); - TEST_ASSERT_EQUAL_STRING("70-01-01 08:00:00", cTime); + ICUNIT_ASSERT_STRING_EQUAL("70-01-01 08:00:00", cTime, 0); LOG("\n time_t=%lld, first time:%s", tStart, cTime); tStart = -1; tmStart = localtime_r(&tStart, &tmrResult); strftime(cTime, sizeof(cTime), "%y-%m-%d %H:%M:%S", tmStart); - TEST_ASSERT_EQUAL_STRING("70-01-01 07:59:59", cTime); + ICUNIT_ASSERT_STRING_EQUAL("70-01-01 07:59:59", cTime, 0); LOG("\n time_t=%lld, first time:%s", tStart, cTime); return 0; } @@ -382,40 +382,40 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeMktime001, Function | MediumTest // get system timezone int ret = gettimeofday(&tv, &tz); - TEST_ASSERT_EQUAL_INT(0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); long sysTimezone = (long)(-tz.tz_minuteswest) * SECS_PER_MIN; LOG("\n system timezone = %ld\n", sysTimezone); INIT_TM(testTM, 2020, 7, 9, 18, 10, 0, 7); time_t timeRet = mktime(&testTM); LOG("\n 2020-7-9 18:10:00, mktime Ret = %lld", timeRet); - TEST_ASSERT_EQUAL_INT(sysTimezone, testTM.__tm_gmtoff); - TEST_ASSERT_EQUAL_INT(1596996600 - testTM.__tm_gmtoff, timeRet); + ICUNIT_ASSERT_EQUAL(sysTimezone, testTM.__tm_gmtoff, 0); + ICUNIT_ASSERT_EQUAL(1596996600 - testTM.__tm_gmtoff, timeRet, 0); INIT_TM(testTM, 1970, 0, 1, 8, 0, 0, 0); timeRet = mktime(&testTM); LOG("\n 1970-1-1 08:00:00, mktime Ret = %lld", timeRet); - TEST_ASSERT_EQUAL_INT(sysTimezone, testTM.__tm_gmtoff); - TEST_ASSERT_EQUAL_INT(28800 - testTM.__tm_gmtoff, timeRet); + ICUNIT_ASSERT_EQUAL(sysTimezone, testTM.__tm_gmtoff, 0); + ICUNIT_ASSERT_EQUAL(28800 - testTM.__tm_gmtoff, timeRet, 0); struct tm *timePtr = localtime(&testTime); LOG("\n testTime 18880, tm : %s", TmToStr(timePtr, timeStr, TIME_STR_LEN)); timeRet = mktime(timePtr); - TEST_ASSERT_EQUAL_INT(18880, timeRet); + ICUNIT_ASSERT_EQUAL(timeRet, 18880, timeRet); LOG("\n input 18880, mktime Ret = %lld", timeRet); testTime = LONG_MAX; timePtr = localtime(&testTime); LOG("\n testTime LONG_MAX, tm : %s", TmToStr(timePtr, timeStr, TIME_STR_LEN)); timeRet = mktime(timePtr); - TEST_ASSERT_EQUAL_INT(LONG_MAX, timeRet); + ICUNIT_ASSERT_EQUAL(timeRet, LONG_MAX, timeRet); LOG("\n input LONG_MAX, mktime Ret = %lld", timeRet); testTime = 0; timePtr = localtime(&testTime); LOG("\n testTime 0, tm : %s", TmToStr(timePtr, timeStr, TIME_STR_LEN)); timeRet = mktime(timePtr); - TEST_ASSERT_EQUAL_INT(0, timeRet); + ICUNIT_ASSERT_EQUAL(timeRet, 0, timeRet); LOG("\n input 0, mktime Ret = %lld", timeRet); return 0; } @@ -433,10 +433,10 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeMktime002, Function | MediumTest time_t timeRet = mktime(&testTM); LOG("\n 1800-8-9 10:10:00, mktime Ret lld = %lld", timeRet); #if (LOSCFG_LIBC_MUSL == 1) - TEST_ASSERT_EQUAL_INT(-1, timeRet); + ICUNIT_ASSERT_EQUAL(timeRet, -1, timeRet); #endif #if (LOSCFG_LIBC_NEWLIB == 1) - TEST_ASSERT_LESS_THAN_INT(0, timeRet); + ICUNIT_ASSERT_WITHIN_EQUAL(timeRet, timeRet, -1, 0); #endif return 0; } @@ -455,26 +455,26 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeStrftime001, Function | MediumTes mtime = LONG_MAX; ftime = strftime(buffer, 80, "%y-%m-%d %H:%M:%S", localtime(&mtime)); - TEST_ASSERT_GREATER_THAN_INT(0, ftime); - TEST_ASSERT_EQUAL_STRING("38-01-19 11:14:07", buffer); + ICUNIT_ASSERT_WITHIN_EQUAL(ftime, 1, ftime, 0); + ICUNIT_ASSERT_STRING_EQUAL("38-01-19 11:14:07", buffer, 0); LOG("\nresult: %s, expected : %s", buffer, "38-01-19 11:14:07"); mtime = LONG_MIN; ftime = strftime(buffer, 80, "%Y-%m-%d %H:%M:%S", localtime(&mtime)); - TEST_ASSERT_GREATER_THAN_INT(0, ftime); - TEST_ASSERT_EQUAL_STRING("1901-12-14 04:45:52", buffer); + ICUNIT_ASSERT_WITHIN_EQUAL(ftime, 1, ftime, 0); + ICUNIT_ASSERT_STRING_EQUAL("1901-12-14 04:45:52", buffer, 0); LOG("\nresult: %s, expected : %s", buffer, "1901-12-14 04:45:52"); mtime = 18880; ftime = strftime(buffer, 80, "%F %T", localtime(&mtime)); - TEST_ASSERT_GREATER_THAN_INT(0, ftime); - TEST_ASSERT_EQUAL_STRING("1970-01-01 13:14:40", buffer); + ICUNIT_ASSERT_WITHIN_EQUAL(ftime, 1, ftime, 0); + ICUNIT_ASSERT_STRING_EQUAL("1970-01-01 13:14:40", buffer, 0); LOG("\nresult: %s, expected : %s", buffer, "1970-01-01 13:14:40"); mtime = 18880; ftime = strftime(buffer, 80, "%D %w %H:%M:%S", localtime(&mtime)); - TEST_ASSERT_GREATER_THAN_INT(0, ftime); - TEST_ASSERT_EQUAL_STRING("01/01/70 4 13:14:40", buffer); + ICUNIT_ASSERT_WITHIN_EQUAL(ftime, 1, ftime, 0); + ICUNIT_ASSERT_STRING_EQUAL("01/01/70 4 13:14:40", buffer, 0); LOG("\nresult: %s, expected : %s", buffer, "01/01/70 4 13:14:40"); return 0; }; @@ -492,18 +492,18 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeStrftime002, Function | MediumTes struct tm *tmTime = localtime(&mtime); ftime = strftime(buffer, 80, "%Ex %EX %A", tmTime); - TEST_ASSERT_GREATER_THAN_INT(0, ftime); - TEST_ASSERT_EQUAL_STRING("01/01/70 13:14:40 Thursday", buffer); + ICUNIT_ASSERT_WITHIN_EQUAL(ftime, 1, ftime, 0); + ICUNIT_ASSERT_STRING_EQUAL("01/01/70 13:14:40 Thursday", buffer, 0); LOG("\nresult: %s, expected : %s", buffer, "01/01/70 13:14:40 Thursday"); ftime = strftime(buffer, 80, "%x %X", tmTime); - TEST_ASSERT_GREATER_THAN_INT(0, ftime); - TEST_ASSERT_EQUAL_STRING("01/01/70 13:14:40", buffer); + ICUNIT_ASSERT_WITHIN_EQUAL(ftime, 1, ftime, 0); + ICUNIT_ASSERT_STRING_EQUAL("01/01/70 13:14:40", buffer, 0); LOG("\nresult: %s, expected : %s", buffer, "01/01/70 13:14:40"); ftime = strftime(buffer, 80, "%D %A %H:%M:%S", tmTime); - TEST_ASSERT_GREATER_THAN_INT(0, ftime); - TEST_ASSERT_EQUAL_STRING("01/01/70 Thursday 13:14:40", buffer); + ICUNIT_ASSERT_WITHIN_EQUAL(ftime, 1, ftime, 0); + ICUNIT_ASSERT_STRING_EQUAL("01/01/70 Thursday 13:14:40", buffer, 0); LOG("\nresult: %s, expected : %s", buffer, "01/01/70 Thursday 13:14:40"); return 0; }; @@ -521,25 +521,25 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeStrftime003, Function | MediumTes struct tm *tmTime = localtime(&mtime); ftime = strftime(buffer, 12, "%Y-%m-%d %H:%M:%S", tmTime); - TEST_ASSERT_EQUAL_INT(0, ftime); + ICUNIT_ASSERT_EQUAL(ftime, 0, ftime); LOG("\nresult: %s, expected : %s", buffer, "1970-01-01 13:14:40"); ftime = strftime(buffer, 80, "", tmTime); - TEST_ASSERT_EQUAL_INT(0, ftime); + ICUNIT_ASSERT_EQUAL(ftime, 0, ftime); LOG("\nresult: %s, expected : %s", buffer, "1970-01-01 13:14:40"); ftime = strftime(buffer, 19, "%Y-%m-%d %H:%M:%S", tmTime); - TEST_ASSERT_EQUAL_INT(0, ftime); + ICUNIT_ASSERT_EQUAL(ftime, 0, ftime); LOG("\nresult: %s, expected : %s", buffer, "1970-01-01 13:14:40"); ftime = strftime(buffer, 20, "%Y-%m-%d %H:%M:%S", tmTime); - TEST_ASSERT_EQUAL_INT(19, ftime); - TEST_ASSERT_EQUAL_STRING("1970-01-01 13:14:40", buffer); + ICUNIT_ASSERT_EQUAL(ftime, 19, ftime); + ICUNIT_ASSERT_STRING_EQUAL("1970-01-01 13:14:40", buffer, 0); LOG("\nresult: %s, expected : %s", buffer, "1970-01-01 13:14:40"); tmTime->__tm_zone = "UTC+8"; ftime = strftime(buffer, 80, "%F %T %Z", tmTime); - TEST_ASSERT_EQUAL_INT(20, ftime); + ICUNIT_ASSERT_EQUAL(ftime, 20, ftime); LOG("\nresult: %s, expected : %s", buffer, "1970-01-01 13:14:40"); return 0; }; @@ -572,10 +572,10 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimes, Function | MediumTest | Level1 (long)(end.tms_utime - start.tms_utime), (long)(end.tms_stime - start.tms_stime)); if (!CheckValueClose((end.tms_utime - start.tms_utime), testClockt, 0.02)) { - TEST_FAIL(); + ICUNIT_ASSERT_EQUAL(1, 0, 0); } if (!CheckValueClose((endTime - stTime), testClockt, 0.02)) { - TEST_FAIL(); + ICUNIT_ASSERT_EQUAL(1, 0, 0); } return 0; }