Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Unity
提交
b4ab81bb
T
Third Party Unity
项目概览
OpenHarmony
/
Third Party Unity
1 年多 前同步成功
通知
36
Star
144
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Unity
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b4ab81bb
编写于
10月 27, 2018
作者:
F
Fabian Zahn
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added first working implementation.
上级
7d2bf62b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
144 addition
and
23 deletion
+144
-23
src/unity.c
src/unity.c
+135
-23
src/unity_internals.h
src/unity_internals.h
+9
-0
未找到文件。
src/unity.c
浏览文件 @
b4ab81bb
...
...
@@ -67,6 +67,57 @@ static const char UnityStrDetail2Name[] = " " UNITY_DETAIL2_NAME " ";
* Pretty Printers & Test Result Output Handlers
*-----------------------------------------------*/
/*-----------------------------------------------*/
/* Local helper function to print characters. */
static
void
UnityPrintChar
(
const
char
*
pch
)
{
/* printable characters plus CR & LF are printed */
if
((
*
pch
<=
126
)
&&
(
*
pch
>=
32
))
{
UNITY_OUTPUT_CHAR
(
*
pch
);
}
/* write escaped carriage returns */
else
if
(
*
pch
==
13
)
{
UNITY_OUTPUT_CHAR
(
'\\'
);
UNITY_OUTPUT_CHAR
(
'r'
);
}
/* write escaped line feeds */
else
if
(
*
pch
==
10
)
{
UNITY_OUTPUT_CHAR
(
'\\'
);
UNITY_OUTPUT_CHAR
(
'n'
);
}
/* unprintable characters are shown as codes */
else
{
UNITY_OUTPUT_CHAR
(
'\\'
);
UNITY_OUTPUT_CHAR
(
'x'
);
UnityPrintNumberHex
((
UNITY_UINT
)
*
pch
,
2
);
}
}
/*-----------------------------------------------*/
#ifdef UNITY_OUTPUT_COLOR
static
UNITY_UINT
UnityPrintAnsiEscapeString
(
const
char
*
string
)
{
const
char
*
pch
=
string
;
UNITY_UINT
count
=
0
;
while
(
*
pch
&&
*
pch
!=
'm'
)
{
UNITY_OUTPUT_CHAR
(
*
pch
);
pch
++
;
count
++
;
}
UNITY_OUTPUT_CHAR
(
'm'
);
count
++
;
return
count
;
}
#endif
/*-----------------------------------------------*/
void
UnityPrint
(
const
char
*
string
)
{
const
char
*
pch
=
string
;
...
...
@@ -75,47 +126,108 @@ void UnityPrint(const char* string)
{
while
(
*
pch
)
{
/* printable characters plus CR & LF are printed */
if
((
*
pch
<=
126
)
&&
(
*
pch
>=
32
))
{
UNITY_OUTPUT_CHAR
(
*
pch
);
}
/* write escaped carriage returns */
else
if
(
*
pch
==
13
)
#ifdef UNITY_OUTPUT_COLOR
/* print ANSI escape code */
if
(
*
pch
==
27
&&
*
(
pch
+
1
)
==
'['
)
{
UNITY_OUTPUT_CHAR
(
'\\'
);
UNITY_OUTPUT_CHAR
(
'r'
)
;
pch
+=
UnityPrintAnsiEscapeString
(
pch
);
continue
;
}
/* write escaped line feeds */
else
if
(
*
pch
==
10
)
#endif
UnityPrintChar
(
pch
);
pch
++
;
}
}
}
/*-----------------------------------------------*/
#ifndef UNITY_EXCLUDE_PRINT_FORMATTED
void
UnityPrintFormatted
(
const
char
*
format
,
...
)
{
const
char
*
pch
=
format
;
va_list
va
;
va_start
(
va
,
format
);
if
(
pch
!=
NULL
)
{
while
(
*
pch
)
{
/* format identification character */
if
(
*
pch
==
'%'
)
{
UNITY_OUTPUT_CHAR
(
'\\'
);
UNITY_OUTPUT_CHAR
(
'n'
);
pch
++
;
if
(
pch
!=
NULL
)
{
switch
(
*
pch
)
{
case
'd'
:
case
'i'
:
{
const
UNITY_INT
number
=
va_arg
(
va
,
UNITY_INT
);
UnityPrintNumber
(
number
);
break
;
}
case
'u'
:
{
const
UNITY_UINT
number
=
va_arg
(
va
,
UNITY_UINT
);
UnityPrintNumberUnsigned
(
number
);
break
;
}
case
'x'
:
case
'X'
:
case
'p'
:
{
const
UNITY_UINT
number
=
va_arg
(
va
,
UNITY_UINT
);
UNITY_OUTPUT_CHAR
(
'0'
);
UNITY_OUTPUT_CHAR
(
'x'
);
UnityPrintNumberHex
(
number
,
8
);
break
;
}
case
'c'
:
{
const
UNITY_INT
ch
=
va_arg
(
va
,
UNITY_INT
);
UnityPrintChar
((
const
char
*
)
&
ch
);
break
;
}
case
's'
:
{
const
char
*
string
=
va_arg
(
va
,
const
char
*
);
UnityPrint
(
string
);
break
;
}
case
'%'
:
default:
UnityPrintChar
(
pch
);
break
;
}
}
}
#ifdef UNITY_OUTPUT_COLOR
/* print ANSI escape code */
else
if
(
*
pch
==
27
&&
*
(
pch
+
1
)
==
'['
)
{
while
(
*
pch
&&
*
pch
!=
'm'
)
{
UNITY_OUTPUT_CHAR
(
*
pch
);
pch
++
;
}
UNITY_OUTPUT_CHAR
(
'm'
);
pch
+=
UnityPrintAnsiEscapeString
(
pch
);
continue
;
}
#endif
/* unprintable characters are shown as codes */
else
if
(
*
pch
==
'\n'
)
{
UNITY_PRINT_EOL
();
}
else
{
UNITY_OUTPUT_CHAR
(
'\\'
);
UNITY_OUTPUT_CHAR
(
'x'
);
UnityPrintNumberHex
((
UNITY_UINT
)
*
pch
,
2
);
UnityPrintChar
(
pch
);
}
pch
++
;
}
}
va_end
(
va
);
}
#endif
/* ! UNITY_EXCLUDE_PRINT_FORMATTED */
/*-----------------------------------------------*/
void
UnityPrintLen
(
const
char
*
string
,
const
UNITY_UINT32
length
)
{
const
char
*
pch
=
string
;
...
...
src/unity_internals.h
浏览文件 @
b4ab81bb
...
...
@@ -23,6 +23,10 @@
#include <stddef.h>
#endif
#ifndef UNITY_EXCLUDE_PRINT_FORMATTED
#include <stdarg.h>
#endif
/* Unity Attempts to Auto-Detect Integer Types
* Attempt 1: UINT_MAX, ULONG_MAX in <limits.h>, or default to 32 bits
* Attempt 2: UINTPTR_MAX in <stdint.h>, or default to same size as long
...
...
@@ -489,6 +493,11 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int
*-------------------------------------------------------*/
void
UnityPrint
(
const
char
*
string
);
#ifndef UNITY_EXCLUDE_PRINT_FORMATTED
void
UnityPrintFormatted
(
const
char
*
format
,
...
);
#endif
void
UnityPrintLen
(
const
char
*
string
,
const
UNITY_UINT32
length
);
void
UnityPrintMask
(
const
UNITY_UINT
mask
,
const
UNITY_UINT
number
);
void
UnityPrintNumberByStyle
(
const
UNITY_INT
number
,
const
UNITY_DISPLAY_STYLE_T
style
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录