Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Kernel Liteos M
提交
da2429a0
K
Kernel Liteos M
项目概览
OpenHarmony
/
Kernel Liteos M
9 个月 前同步成功
通知
20
Star
28
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel Liteos M
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
da2429a0
编写于
5月 09, 2023
作者:
O
openharmony_ci
提交者:
Gitee
5月 09, 2023
浏览文件
操作
浏览文件
下载
差异文件
!1040 Fix : 内核测试用例框架统一
Merge pull request !1040 from yinjiaming/test_framework
上级
3b9e83c6
6c6fddb9
变更
26
展开全部
隐藏空白更改
内联
并排
Showing
26 changed file
with
577 addition
and
617 deletion
+577
-617
testsuites/unittest/posix/src/ctype/ctype_func_test.c
testsuites/unittest/posix/src/ctype/ctype_func_test.c
+25
-27
testsuites/unittest/posix/src/ctype/isdigit_test.c
testsuites/unittest/posix/src/ctype/isdigit_test.c
+5
-8
testsuites/unittest/posix/src/ctype/islower_test.c
testsuites/unittest/posix/src/ctype/islower_test.c
+6
-8
testsuites/unittest/posix/src/ctype/isxdigit_test.c
testsuites/unittest/posix/src/ctype/isxdigit_test.c
+10
-12
testsuites/unittest/posix/src/ctype/tolower_test.c
testsuites/unittest/posix/src/ctype/tolower_test.c
+5
-7
testsuites/unittest/posix/src/ctype/toupper_test.c
testsuites/unittest/posix/src/ctype/toupper_test.c
+5
-7
testsuites/unittest/posix/src/errno/strerror_test.c
testsuites/unittest/posix/src/errno/strerror_test.c
+8
-10
testsuites/unittest/posix/src/fs/posix_fs_func_test.c
testsuites/unittest/posix/src/fs/posix_fs_func_test.c
+214
-213
testsuites/unittest/posix/src/math/math_func_test.c
testsuites/unittest/posix/src/math/math_func_test.c
+9
-9
testsuites/unittest/posix/src/posix_test.h
testsuites/unittest/posix/src/posix_test.h
+1
-25
testsuites/unittest/posix/src/regex/regex_func_test.c
testsuites/unittest/posix/src/regex/regex_func_test.c
+4
-4
testsuites/unittest/posix/src/semaphore/semaphore_func_test.c
...suites/unittest/posix/src/semaphore/semaphore_func_test.c
+26
-26
testsuites/unittest/posix/src/stdarg/stdarg_func_test.c
testsuites/unittest/posix/src/stdarg/stdarg_func_test.c
+7
-7
testsuites/unittest/posix/src/stdlib/atoi_test.c
testsuites/unittest/posix/src/stdlib/atoi_test.c
+10
-10
testsuites/unittest/posix/src/stdlib/atol_test.c
testsuites/unittest/posix/src/stdlib/atol_test.c
+9
-9
testsuites/unittest/posix/src/stdlib/atoll_test.c
testsuites/unittest/posix/src/stdlib/atoll_test.c
+9
-9
testsuites/unittest/posix/src/stdlib/strtol_test.c
testsuites/unittest/posix/src/stdlib/strtol_test.c
+26
-26
testsuites/unittest/posix/src/stdlib/strtoul_test.c
testsuites/unittest/posix/src/stdlib/strtoul_test.c
+20
-20
testsuites/unittest/posix/src/stdlib/strtoull_test.c
testsuites/unittest/posix/src/stdlib/strtoull_test.c
+21
-21
testsuites/unittest/posix/src/string/memory_func_test.c
testsuites/unittest/posix/src/string/memory_func_test.c
+30
-30
testsuites/unittest/posix/src/string/strchr_test.c
testsuites/unittest/posix/src/string/strchr_test.c
+6
-6
testsuites/unittest/posix/src/string/string_func_test_01.c
testsuites/unittest/posix/src/string/string_func_test_01.c
+23
-25
testsuites/unittest/posix/src/string/string_func_test_02.c
testsuites/unittest/posix/src/string/string_func_test_02.c
+5
-5
testsuites/unittest/posix/src/string/string_func_test_03.c
testsuites/unittest/posix/src/string/string_func_test_03.c
+22
-22
testsuites/unittest/posix/src/string/strstr_test.c
testsuites/unittest/posix/src/string/strstr_test.c
+13
-13
testsuites/unittest/posix/src/time/time_func_test_01.c
testsuites/unittest/posix/src/time/time_func_test_01.c
+58
-58
未找到文件。
testsuites/unittest/posix/src/ctype/ctype_func_test.c
浏览文件 @
da2429a0
...
...
@@ -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...."
);
...
...
testsuites/unittest/posix/src/ctype/isdigit_test.c
浏览文件 @
da2429a0
...
...
@@ -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...."
);
...
...
testsuites/unittest/posix/src/ctype/islower_test.c
浏览文件 @
da2429a0
...
...
@@ -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...."
);
...
...
testsuites/unittest/posix/src/ctype/isxdigit_test.c
浏览文件 @
da2429a0
...
...
@@ -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...."
);
...
...
testsuites/unittest/posix/src/ctype/tolower_test.c
浏览文件 @
da2429a0
...
...
@@ -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...."
);
...
...
testsuites/unittest/posix/src/ctype/toupper_test.c
浏览文件 @
da2429a0
...
...
@@ -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...."
);
...
...
testsuites/unittest/posix/src/errno/strerror_test.c
浏览文件 @
da2429a0
...
...
@@ -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...."
);
...
...
testsuites/unittest/posix/src/fs/posix_fs_func_test.c
浏览文件 @
da2429a0
此差异已折叠。
点击以展开。
testsuites/unittest/posix/src/math/math_func_test.c
浏览文件 @
da2429a0
...
...
@@ -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
;
};
...
...
testsuites/unittest/posix/src/posix_test.h
浏览文件 @
da2429a0
...
...
@@ -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
);
...
...
testsuites/unittest/posix/src/regex/regex_func_test.c
浏览文件 @
da2429a0
...
...
@@ -82,7 +82,7 @@ int TestRegex(int flag, const char *pattern, const char *buf, const int expected
int
j
=
0
;
regcomp
(
&
reg
,
pattern
,
flag
);
int
status
=
regexec
(
&
reg
,
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
(
&
reg
);
return
0
;
...
...
@@ -105,7 +105,7 @@ int TestRegcomp(int flag, const char *pattern, const int expectedStatus)
regex_t
reg
;
int
status
=
regcomp
(
&
reg
,
pattern
,
flag
);
LOG
(
"pattern : %s ,real status : %d
\n
"
,
pattern
,
status
);
TEST_ASSERT_EQUAL_INT
(
expectedStatus
,
status
);
ICUNIT_ASSERT_EQUAL
(
status
,
expectedStatus
,
status
);
regfree
(
&
reg
);
return
0
;
}
...
...
@@ -166,7 +166,7 @@ LITE_TEST_CASE(PosixRegexFuncTestSuite, testRegexNosub001, Function | MediumTest
const
char
*
pattern2
=
"HARMONY[1-9]"
;
regcomp
(
&
reg
,
pattern2
,
cflags
);
int
status
=
regexec
(
&
reg
,
buf
,
(
size_t
)
0
,
NULL
,
0
);
TEST_ASSERT_EQUAL_INT
(
0
,
status
);
ICUNIT_ASSERT_EQUAL
(
status
,
0
,
status
);
regfree
(
&
reg
);
return
0
;
}
...
...
testsuites/unittest/posix/src/semaphore/semaphore_func_test.c
浏览文件 @
da2429a0
...
...
@@ -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
;
}
...
...
testsuites/unittest/posix/src/stdarg/stdarg_func_test.c
浏览文件 @
da2429a0
...
...
@@ -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
;
}
...
...
testsuites/unittest/posix/src/stdlib/atoi_test.c
浏览文件 @
da2429a0
...
...
@@ -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
...
...
testsuites/unittest/posix/src/stdlib/atol_test.c
浏览文件 @
da2429a0
...
...
@@ -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
;
}
...
...
testsuites/unittest/posix/src/stdlib/atoll_test.c
浏览文件 @
da2429a0
...
...
@@ -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
;
}
...
...
testsuites/unittest/posix/src/stdlib/strtol_test.c
浏览文件 @
da2429a0
...
...
@@ -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
;
}
...
...
testsuites/unittest/posix/src/stdlib/strtoul_test.c
浏览文件 @
da2429a0
...
...
@@ -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
;
}
...
...
testsuites/unittest/posix/src/stdlib/strtoull_test.c
浏览文件 @
da2429a0
...
...
@@ -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
;
}
...
...
testsuites/unittest/posix/src/string/memory_func_test.c
浏览文件 @
da2429a0
...
...
@@ -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
;
...
...
testsuites/unittest/posix/src/string/strchr_test.c
浏览文件 @
da2429a0
...
...
@@ -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
;
}
...
...
testsuites/unittest/posix/src/string/string_func_test_01.c
浏览文件 @
da2429a0
...
...
@@ -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
\0
world"
;
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
[]
=
"
\0
helloworld"
;
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
\0
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
;
}
...
...
@@ -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
\0
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
;
}
...
...
@@ -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
\0
world"
;
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
\0
world"
;
char
*
ret
=
strrchr
(
src
,
' '
);
TEST_ASSERT_EQUAL_PTR
(
NULL
,
ret
);
TEST_ASSERT_NULL
(
ret
);
ICUNIT_ASSERT_EQUAL
(
ret
,
NULL
,
0
);
return
0
;
}
...
...
testsuites/unittest/posix/src/string/string_func_test_02.c
浏览文件 @
da2429a0
...
...
@@ -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
;
};
...
...
testsuites/unittest/posix/src/string/string_func_test_03.c
浏览文件 @
da2429a0
...
...
@@ -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
...
...
testsuites/unittest/posix/src/string/strstr_test.c
浏览文件 @
da2429a0
...
...
@@ -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
;
}
...
...
testsuites/unittest/posix/src/time/time_func_test_01.c
浏览文件 @
da2429a0
...
...
@@ -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
(
"
\n
sizeof(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
(
"
\n
result: %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
(
"
\n
result: %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
(
"
\n
result: %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
(
"
\n
result: %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
(
"
\n
result: %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
(
"
\n
result: %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
(
"
\n
result: %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
(
"
\n
result: %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
(
"
\n
result: %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
(
"
\n
result: %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
(
"
\n
result: %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
(
"
\n
result: %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
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录