Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party CJSON
提交
79f30800
T
Third Party CJSON
项目概览
OpenHarmony
/
Third Party CJSON
大约 1 年 前同步成功
通知
6
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party CJSON
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
79f30800
编写于
4月 27, 2017
作者:
M
Max Bruckner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move print depth into printbuffer
上级
e0d3a8a2
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
37 addition
and
32 deletion
+37
-32
cJSON.c
cJSON.c
+25
-20
tests/print_array.c
tests/print_array.c
+4
-4
tests/print_number.c
tests/print_number.c
+1
-1
tests/print_object.c
tests/print_object.c
+4
-4
tests/print_string.c
tests/print_string.c
+1
-1
tests/print_value.c
tests/print_value.c
+2
-2
未找到文件。
cJSON.c
浏览文件 @
79f30800
...
@@ -315,6 +315,7 @@ typedef struct
...
@@ -315,6 +315,7 @@ typedef struct
unsigned
char
*
buffer
;
unsigned
char
*
buffer
;
size_t
length
;
size_t
length
;
size_t
offset
;
size_t
offset
;
size_t
depth
;
/* current nesting depth (for formatted printing) */
cJSON_bool
noalloc
;
cJSON_bool
noalloc
;
}
printbuffer
;
}
printbuffer
;
...
@@ -927,11 +928,11 @@ static cJSON_bool print_string(const cJSON * const item, printbuffer * const p,
...
@@ -927,11 +928,11 @@ static cJSON_bool print_string(const cJSON * const item, printbuffer * const p,
/* Predeclare these prototypes. */
/* Predeclare these prototypes. */
static
cJSON_bool
parse_value
(
cJSON
*
const
item
,
parse_buffer
*
const
input_buffer
,
const
internal_hooks
*
const
hooks
);
static
cJSON_bool
parse_value
(
cJSON
*
const
item
,
parse_buffer
*
const
input_buffer
,
const
internal_hooks
*
const
hooks
);
static
cJSON_bool
print_value
(
const
cJSON
*
const
item
,
const
size_t
depth
,
const
cJSON_bool
format
,
printbuffer
*
const
output_buffer
,
const
internal_hooks
*
const
hooks
);
static
cJSON_bool
print_value
(
const
cJSON
*
const
item
,
const
cJSON_bool
format
,
printbuffer
*
const
output_buffer
,
const
internal_hooks
*
const
hooks
);
static
cJSON_bool
parse_array
(
cJSON
*
const
item
,
parse_buffer
*
const
input_buffer
,
const
internal_hooks
*
const
hooks
);
static
cJSON_bool
parse_array
(
cJSON
*
const
item
,
parse_buffer
*
const
input_buffer
,
const
internal_hooks
*
const
hooks
);
static
cJSON_bool
print_array
(
const
cJSON
*
const
item
,
const
size_t
depth
,
const
cJSON_bool
format
,
printbuffer
*
const
output_buffer
,
const
internal_hooks
*
const
hooks
);
static
cJSON_bool
print_array
(
const
cJSON
*
const
item
,
const
cJSON_bool
format
,
printbuffer
*
const
output_buffer
,
const
internal_hooks
*
const
hooks
);
static
cJSON_bool
parse_object
(
cJSON
*
const
item
,
parse_buffer
*
const
input_buffer
,
const
internal_hooks
*
const
hooks
);
static
cJSON_bool
parse_object
(
cJSON
*
const
item
,
parse_buffer
*
const
input_buffer
,
const
internal_hooks
*
const
hooks
);
static
cJSON_bool
print_object
(
const
cJSON
*
const
item
,
const
size_t
depth
,
const
cJSON_bool
format
,
printbuffer
*
const
output_buffer
,
const
internal_hooks
*
const
hooks
);
static
cJSON_bool
print_object
(
const
cJSON
*
const
item
,
const
cJSON_bool
format
,
printbuffer
*
const
output_buffer
,
const
internal_hooks
*
const
hooks
);
/* Utility to jump whitespace and cr/lf */
/* Utility to jump whitespace and cr/lf */
static
parse_buffer
*
buffer_skip_whitespace
(
parse_buffer
*
const
buffer
)
static
parse_buffer
*
buffer_skip_whitespace
(
parse_buffer
*
const
buffer
)
...
@@ -1058,7 +1059,7 @@ static unsigned char *print(const cJSON * const item, cJSON_bool format, const i
...
@@ -1058,7 +1059,7 @@ static unsigned char *print(const cJSON * const item, cJSON_bool format, const i
}
}
/* print the value */
/* print the value */
if
(
!
print_value
(
item
,
0
,
format
,
buffer
,
hooks
))
if
(
!
print_value
(
item
,
format
,
buffer
,
hooks
))
{
{
goto
fail
;
goto
fail
;
}
}
...
@@ -1116,7 +1117,7 @@ CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item)
...
@@ -1116,7 +1117,7 @@ CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item)
CJSON_PUBLIC
(
char
*
)
cJSON_PrintBuffered
(
const
cJSON
*
item
,
int
prebuffer
,
cJSON_bool
fmt
)
CJSON_PUBLIC
(
char
*
)
cJSON_PrintBuffered
(
const
cJSON
*
item
,
int
prebuffer
,
cJSON_bool
fmt
)
{
{
printbuffer
p
;
printbuffer
p
=
{
0
,
0
,
0
,
0
,
0
}
;
if
(
prebuffer
<
0
)
if
(
prebuffer
<
0
)
{
{
...
@@ -1133,7 +1134,7 @@ CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON
...
@@ -1133,7 +1134,7 @@ CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON
p
.
offset
=
0
;
p
.
offset
=
0
;
p
.
noalloc
=
false
;
p
.
noalloc
=
false
;
if
(
!
print_value
(
item
,
0
,
fmt
,
&
p
,
&
global_hooks
))
if
(
!
print_value
(
item
,
fmt
,
&
p
,
&
global_hooks
))
{
{
return
NULL
;
return
NULL
;
}
}
...
@@ -1143,7 +1144,7 @@ CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON
...
@@ -1143,7 +1144,7 @@ CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON
CJSON_PUBLIC
(
cJSON_bool
)
cJSON_PrintPreallocated
(
cJSON
*
item
,
char
*
buf
,
const
int
len
,
const
cJSON_bool
fmt
)
CJSON_PUBLIC
(
cJSON_bool
)
cJSON_PrintPreallocated
(
cJSON
*
item
,
char
*
buf
,
const
int
len
,
const
cJSON_bool
fmt
)
{
{
printbuffer
p
;
printbuffer
p
=
{
0
,
0
,
0
,
0
,
0
}
;
if
(
len
<
0
)
if
(
len
<
0
)
{
{
...
@@ -1154,7 +1155,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buf, const i
...
@@ -1154,7 +1155,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buf, const i
p
.
length
=
(
size_t
)
len
;
p
.
length
=
(
size_t
)
len
;
p
.
offset
=
0
;
p
.
offset
=
0
;
p
.
noalloc
=
true
;
p
.
noalloc
=
true
;
return
print_value
(
item
,
0
,
fmt
,
&
p
,
&
global_hooks
);
return
print_value
(
item
,
fmt
,
&
p
,
&
global_hooks
);
}
}
/* Parser core - when encountering text, process appropriately. */
/* Parser core - when encountering text, process appropriately. */
...
@@ -1214,7 +1215,7 @@ static cJSON_bool parse_value(cJSON * const item, parse_buffer * const input_buf
...
@@ -1214,7 +1215,7 @@ static cJSON_bool parse_value(cJSON * const item, parse_buffer * const input_buf
}
}
/* Render a value to text. */
/* Render a value to text. */
static
cJSON_bool
print_value
(
const
cJSON
*
const
item
,
const
size_t
depth
,
const
cJSON_bool
format
,
printbuffer
*
const
output_buffer
,
const
internal_hooks
*
const
hooks
)
static
cJSON_bool
print_value
(
const
cJSON
*
const
item
,
const
cJSON_bool
format
,
printbuffer
*
const
output_buffer
,
const
internal_hooks
*
const
hooks
)
{
{
unsigned
char
*
output
=
NULL
;
unsigned
char
*
output
=
NULL
;
...
@@ -1281,10 +1282,10 @@ static cJSON_bool print_value(const cJSON * const item, const size_t depth, cons
...
@@ -1281,10 +1282,10 @@ static cJSON_bool print_value(const cJSON * const item, const size_t depth, cons
return
print_string
(
item
,
output_buffer
,
hooks
);
return
print_string
(
item
,
output_buffer
,
hooks
);
case
cJSON_Array
:
case
cJSON_Array
:
return
print_array
(
item
,
depth
,
format
,
output_buffer
,
hooks
);
return
print_array
(
item
,
format
,
output_buffer
,
hooks
);
case
cJSON_Object
:
case
cJSON_Object
:
return
print_object
(
item
,
depth
,
format
,
output_buffer
,
hooks
);
return
print_object
(
item
,
format
,
output_buffer
,
hooks
);
default:
default:
return
false
;
return
false
;
...
@@ -1386,7 +1387,7 @@ fail:
...
@@ -1386,7 +1387,7 @@ fail:
}
}
/* Render an array to text */
/* Render an array to text */
static
cJSON_bool
print_array
(
const
cJSON
*
const
item
,
const
size_t
depth
,
const
cJSON_bool
format
,
printbuffer
*
const
output_buffer
,
const
internal_hooks
*
const
hooks
)
static
cJSON_bool
print_array
(
const
cJSON
*
const
item
,
const
cJSON_bool
format
,
printbuffer
*
const
output_buffer
,
const
internal_hooks
*
const
hooks
)
{
{
unsigned
char
*
output_pointer
=
NULL
;
unsigned
char
*
output_pointer
=
NULL
;
size_t
length
=
0
;
size_t
length
=
0
;
...
@@ -1407,10 +1408,11 @@ static cJSON_bool print_array(const cJSON * const item, const size_t depth, cons
...
@@ -1407,10 +1408,11 @@ static cJSON_bool print_array(const cJSON * const item, const size_t depth, cons
*
output_pointer
=
'['
;
*
output_pointer
=
'['
;
output_buffer
->
offset
++
;
output_buffer
->
offset
++
;
output_buffer
->
depth
++
;
while
(
current_element
!=
NULL
)
while
(
current_element
!=
NULL
)
{
{
if
(
!
print_value
(
current_element
,
depth
+
1
,
format
,
output_buffer
,
hooks
))
if
(
!
print_value
(
current_element
,
format
,
output_buffer
,
hooks
))
{
{
return
false
;
return
false
;
}
}
...
@@ -1441,6 +1443,7 @@ static cJSON_bool print_array(const cJSON * const item, const size_t depth, cons
...
@@ -1441,6 +1443,7 @@ static cJSON_bool print_array(const cJSON * const item, const size_t depth, cons
}
}
*
output_pointer
++
=
']'
;
*
output_pointer
++
=
']'
;
*
output_pointer
=
'\0'
;
*
output_pointer
=
'\0'
;
output_buffer
->
depth
--
;
return
true
;
return
true
;
}
}
...
@@ -1555,7 +1558,7 @@ fail:
...
@@ -1555,7 +1558,7 @@ fail:
}
}
/* Render an object to text. */
/* Render an object to text. */
static
cJSON_bool
print_object
(
const
cJSON
*
const
item
,
const
size_t
depth
,
const
cJSON_bool
format
,
printbuffer
*
const
output_buffer
,
const
internal_hooks
*
const
hooks
)
static
cJSON_bool
print_object
(
const
cJSON
*
const
item
,
const
cJSON_bool
format
,
printbuffer
*
const
output_buffer
,
const
internal_hooks
*
const
hooks
)
{
{
unsigned
char
*
output_pointer
=
NULL
;
unsigned
char
*
output_pointer
=
NULL
;
size_t
length
=
0
;
size_t
length
=
0
;
...
@@ -1575,6 +1578,7 @@ static cJSON_bool print_object(const cJSON * const item, const size_t depth, con
...
@@ -1575,6 +1578,7 @@ static cJSON_bool print_object(const cJSON * const item, const size_t depth, con
}
}
*
output_pointer
++
=
'{'
;
*
output_pointer
++
=
'{'
;
output_buffer
->
depth
++
;
if
(
format
)
if
(
format
)
{
{
*
output_pointer
++
=
'\n'
;
*
output_pointer
++
=
'\n'
;
...
@@ -1586,16 +1590,16 @@ static cJSON_bool print_object(const cJSON * const item, const size_t depth, con
...
@@ -1586,16 +1590,16 @@ static cJSON_bool print_object(const cJSON * const item, const size_t depth, con
if
(
format
)
if
(
format
)
{
{
size_t
i
;
size_t
i
;
output_pointer
=
ensure
(
output_buffer
,
depth
+
1
,
hooks
);
output_pointer
=
ensure
(
output_buffer
,
output_buffer
->
depth
,
hooks
);
if
(
output_pointer
==
NULL
)
if
(
output_pointer
==
NULL
)
{
{
return
false
;
return
false
;
}
}
for
(
i
=
0
;
i
<
depth
+
1
;
i
++
)
for
(
i
=
0
;
i
<
output_buffer
->
depth
;
i
++
)
{
{
*
output_pointer
++
=
'\t'
;
*
output_pointer
++
=
'\t'
;
}
}
output_buffer
->
offset
+=
depth
+
1
;
output_buffer
->
offset
+=
output_buffer
->
depth
;
}
}
/* print key */
/* print key */
...
@@ -1619,7 +1623,7 @@ static cJSON_bool print_object(const cJSON * const item, const size_t depth, con
...
@@ -1619,7 +1623,7 @@ static cJSON_bool print_object(const cJSON * const item, const size_t depth, con
output_buffer
->
offset
+=
length
;
output_buffer
->
offset
+=
length
;
/* print value */
/* print value */
if
(
!
print_value
(
current_item
,
depth
+
1
,
format
,
output_buffer
,
hooks
))
if
(
!
print_value
(
current_item
,
format
,
output_buffer
,
hooks
))
{
{
return
false
;
return
false
;
}
}
...
@@ -1647,7 +1651,7 @@ static cJSON_bool print_object(const cJSON * const item, const size_t depth, con
...
@@ -1647,7 +1651,7 @@ static cJSON_bool print_object(const cJSON * const item, const size_t depth, con
current_item
=
current_item
->
next
;
current_item
=
current_item
->
next
;
}
}
output_pointer
=
ensure
(
output_buffer
,
format
?
(
depth
+
2
)
:
2
,
hooks
);
output_pointer
=
ensure
(
output_buffer
,
format
?
(
output_buffer
->
depth
+
1
)
:
2
,
hooks
);
if
(
output_pointer
==
NULL
)
if
(
output_pointer
==
NULL
)
{
{
return
false
;
return
false
;
...
@@ -1655,13 +1659,14 @@ static cJSON_bool print_object(const cJSON * const item, const size_t depth, con
...
@@ -1655,13 +1659,14 @@ static cJSON_bool print_object(const cJSON * const item, const size_t depth, con
if
(
format
)
if
(
format
)
{
{
size_t
i
;
size_t
i
;
for
(
i
=
0
;
i
<
(
depth
);
i
++
)
for
(
i
=
0
;
i
<
(
output_buffer
->
depth
-
1
);
i
++
)
{
{
*
output_pointer
++
=
'\t'
;
*
output_pointer
++
=
'\t'
;
}
}
}
}
*
output_pointer
++
=
'}'
;
*
output_pointer
++
=
'}'
;
*
output_pointer
=
'\0'
;
*
output_pointer
=
'\0'
;
output_buffer
->
depth
--
;
return
true
;
return
true
;
}
}
...
...
tests/print_array.c
浏览文件 @
79f30800
...
@@ -31,8 +31,8 @@ static void assert_print_array(const char * const expected, const char * const i
...
@@ -31,8 +31,8 @@ static void assert_print_array(const char * const expected, const char * const i
cJSON
item
[
1
];
cJSON
item
[
1
];
printbuffer
formatted_buffer
;
printbuffer
formatted_buffer
=
{
0
,
0
,
0
,
0
,
0
}
;
printbuffer
unformatted_buffer
;
printbuffer
unformatted_buffer
=
{
0
,
0
,
0
,
0
,
0
}
;
parse_buffer
parsebuffer
=
{
0
,
0
,
0
,
0
};
parse_buffer
parsebuffer
=
{
0
,
0
,
0
,
0
};
parsebuffer
.
content
=
(
const
unsigned
char
*
)
input
;
parsebuffer
.
content
=
(
const
unsigned
char
*
)
input
;
...
@@ -53,10 +53,10 @@ static void assert_print_array(const char * const expected, const char * const i
...
@@ -53,10 +53,10 @@ static void assert_print_array(const char * const expected, const char * const i
memset
(
item
,
0
,
sizeof
(
item
));
memset
(
item
,
0
,
sizeof
(
item
));
TEST_ASSERT_TRUE_MESSAGE
(
parse_array
(
item
,
&
parsebuffer
,
&
global_hooks
),
"Failed to parse array."
);
TEST_ASSERT_TRUE_MESSAGE
(
parse_array
(
item
,
&
parsebuffer
,
&
global_hooks
),
"Failed to parse array."
);
TEST_ASSERT_TRUE_MESSAGE
(
print_array
(
item
,
0
,
false
,
&
unformatted_buffer
,
&
global_hooks
),
"Failed to print unformatted string."
);
TEST_ASSERT_TRUE_MESSAGE
(
print_array
(
item
,
false
,
&
unformatted_buffer
,
&
global_hooks
),
"Failed to print unformatted string."
);
TEST_ASSERT_EQUAL_STRING_MESSAGE
(
input
,
printed_unformatted
,
"Unformatted array is not correct."
);
TEST_ASSERT_EQUAL_STRING_MESSAGE
(
input
,
printed_unformatted
,
"Unformatted array is not correct."
);
TEST_ASSERT_TRUE_MESSAGE
(
print_array
(
item
,
0
,
true
,
&
formatted_buffer
,
&
global_hooks
),
"Failed to print formatted string."
);
TEST_ASSERT_TRUE_MESSAGE
(
print_array
(
item
,
true
,
&
formatted_buffer
,
&
global_hooks
),
"Failed to print formatted string."
);
TEST_ASSERT_EQUAL_STRING_MESSAGE
(
expected
,
printed_formatted
,
"Formatted array is not correct."
);
TEST_ASSERT_EQUAL_STRING_MESSAGE
(
expected
,
printed_formatted
,
"Formatted array is not correct."
);
reset
(
item
);
reset
(
item
);
...
...
tests/print_number.c
浏览文件 @
79f30800
...
@@ -28,7 +28,7 @@ static void assert_print_number(const char *expected, double input)
...
@@ -28,7 +28,7 @@ static void assert_print_number(const char *expected, double input)
{
{
unsigned
char
printed
[
1024
];
unsigned
char
printed
[
1024
];
cJSON
item
[
1
];
cJSON
item
[
1
];
printbuffer
buffer
;
printbuffer
buffer
=
{
0
,
0
,
0
,
0
,
0
}
;
buffer
.
buffer
=
printed
;
buffer
.
buffer
=
printed
;
buffer
.
length
=
sizeof
(
printed
);
buffer
.
length
=
sizeof
(
printed
);
buffer
.
offset
=
0
;
buffer
.
offset
=
0
;
...
...
tests/print_object.c
浏览文件 @
79f30800
...
@@ -31,8 +31,8 @@ static void assert_print_object(const char * const expected, const char * const
...
@@ -31,8 +31,8 @@ static void assert_print_object(const char * const expected, const char * const
cJSON
item
[
1
];
cJSON
item
[
1
];
printbuffer
formatted_buffer
;
printbuffer
formatted_buffer
=
{
0
,
0
,
0
,
0
,
0
}
;
printbuffer
unformatted_buffer
;
printbuffer
unformatted_buffer
=
{
0
,
0
,
0
,
0
,
0
}
;
parse_buffer
parsebuffer
=
{
0
,
0
,
0
,
0
};
parse_buffer
parsebuffer
=
{
0
,
0
,
0
,
0
};
/* buffer for parsing */
/* buffer for parsing */
...
@@ -54,10 +54,10 @@ static void assert_print_object(const char * const expected, const char * const
...
@@ -54,10 +54,10 @@ static void assert_print_object(const char * const expected, const char * const
memset
(
item
,
0
,
sizeof
(
item
));
memset
(
item
,
0
,
sizeof
(
item
));
TEST_ASSERT_TRUE_MESSAGE
(
parse_object
(
item
,
&
parsebuffer
,
&
global_hooks
),
"Failed to parse object."
);
TEST_ASSERT_TRUE_MESSAGE
(
parse_object
(
item
,
&
parsebuffer
,
&
global_hooks
),
"Failed to parse object."
);
TEST_ASSERT_TRUE_MESSAGE
(
print_object
(
item
,
0
,
false
,
&
unformatted_buffer
,
&
global_hooks
),
"Failed to print unformatted string."
);
TEST_ASSERT_TRUE_MESSAGE
(
print_object
(
item
,
false
,
&
unformatted_buffer
,
&
global_hooks
),
"Failed to print unformatted string."
);
TEST_ASSERT_EQUAL_STRING_MESSAGE
(
input
,
printed_unformatted
,
"Unformatted object is not correct."
);
TEST_ASSERT_EQUAL_STRING_MESSAGE
(
input
,
printed_unformatted
,
"Unformatted object is not correct."
);
TEST_ASSERT_TRUE_MESSAGE
(
print_object
(
item
,
0
,
true
,
&
formatted_buffer
,
&
global_hooks
),
"Failed to print formatted string."
);
TEST_ASSERT_TRUE_MESSAGE
(
print_object
(
item
,
true
,
&
formatted_buffer
,
&
global_hooks
),
"Failed to print formatted string."
);
TEST_ASSERT_EQUAL_STRING_MESSAGE
(
expected
,
printed_formatted
,
"Formatted ojbect is not correct."
);
TEST_ASSERT_EQUAL_STRING_MESSAGE
(
expected
,
printed_formatted
,
"Formatted ojbect is not correct."
);
reset
(
item
);
reset
(
item
);
...
...
tests/print_string.c
浏览文件 @
79f30800
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
static
void
assert_print_string
(
const
char
*
expected
,
const
char
*
input
)
static
void
assert_print_string
(
const
char
*
expected
,
const
char
*
input
)
{
{
unsigned
char
printed
[
1024
];
unsigned
char
printed
[
1024
];
printbuffer
buffer
;
printbuffer
buffer
=
{
0
,
0
,
0
,
0
,
0
}
;
buffer
.
buffer
=
printed
;
buffer
.
buffer
=
printed
;
buffer
.
length
=
sizeof
(
printed
);
buffer
.
length
=
sizeof
(
printed
);
buffer
.
offset
=
0
;
buffer
.
offset
=
0
;
...
...
tests/print_value.c
浏览文件 @
79f30800
...
@@ -32,7 +32,7 @@ static void assert_print_value(const char *input)
...
@@ -32,7 +32,7 @@ static void assert_print_value(const char *input)
{
{
unsigned
char
printed
[
1024
];
unsigned
char
printed
[
1024
];
cJSON
item
[
1
];
cJSON
item
[
1
];
printbuffer
buffer
;
printbuffer
buffer
=
{
0
,
0
,
0
,
0
,
0
}
;
parse_buffer
parsebuffer
=
{
0
,
0
,
0
,
0
};
parse_buffer
parsebuffer
=
{
0
,
0
,
0
,
0
};
buffer
.
buffer
=
printed
;
buffer
.
buffer
=
printed
;
buffer
.
length
=
sizeof
(
printed
);
buffer
.
length
=
sizeof
(
printed
);
...
@@ -46,7 +46,7 @@ static void assert_print_value(const char *input)
...
@@ -46,7 +46,7 @@ static void assert_print_value(const char *input)
TEST_ASSERT_TRUE_MESSAGE
(
parse_value
(
item
,
&
parsebuffer
,
&
global_hooks
),
"Failed to parse value."
);
TEST_ASSERT_TRUE_MESSAGE
(
parse_value
(
item
,
&
parsebuffer
,
&
global_hooks
),
"Failed to parse value."
);
TEST_ASSERT_TRUE_MESSAGE
(
print_value
(
item
,
0
,
false
,
&
buffer
,
&
global_hooks
),
"Failed to print value."
);
TEST_ASSERT_TRUE_MESSAGE
(
print_value
(
item
,
false
,
&
buffer
,
&
global_hooks
),
"Failed to print value."
);
TEST_ASSERT_EQUAL_STRING_MESSAGE
(
input
,
buffer
.
buffer
,
"Printed value is not as expected."
);
TEST_ASSERT_EQUAL_STRING_MESSAGE
(
input
,
buffer
.
buffer
,
"Printed value is not as expected."
);
reset
(
item
);
reset
(
item
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录