Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
畅游知识海洋
json
提交
963ec13b
J
json
项目概览
畅游知识海洋
/
json
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
json
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
963ec13b
编写于
2月 10, 2015
作者:
N
Niels
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
testing the parser
上级
35898370
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
85 addition
and
32 deletion
+85
-32
Makefile.am
Makefile.am
+1
-1
src/json.hpp
src/json.hpp
+30
-0
test/unit.cpp
test/unit.cpp
+54
-31
未找到文件。
Makefile.am
浏览文件 @
963ec13b
...
...
@@ -14,7 +14,7 @@ json_unit_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/test -Dprivate=public
# -i do not create #line information
# --no-generation-date suppress generation date output
src/json.hpp
:
src/json.hpp.re2c
$(AM_V_GEN)$(RE2C)
-b
-s
-
i
-
-no-generation-date
$<
|
$(SED)
'1d'
>
$@
$(AM_V_GEN)$(RE2C)
-b
-s
--no-generation-date
$<
|
$(SED)
'1d'
>
$@
cppcheck
:
cppcheck
--enable
=
all
--inconclusive
--std
=
c++11 src/json.hpp
...
...
src/json.hpp
浏览文件 @
963ec13b
#line 1 "src/json.hpp.re2c"
#ifndef _NLOHMANN_JSON
#define _NLOHMANN_JSON
...
...
@@ -2601,6 +2602,7 @@ class basic_json
const
lexer_char_t
*
marker
;
// set up RE2C
#line 2612 "src/json.hpp.re2c"
for
(;;)
...
...
@@ -2609,6 +2611,7 @@ class basic_json
current_re2c
=
buffer_re2c
;
#line 2616 "<stdout>"
{
lexer_char_t
yych
;
unsigned
int
yyaccept
=
0
;
...
...
@@ -2768,15 +2771,19 @@ class basic_json
}
}
json_parser_2:
#line 2622 "src/json.hpp.re2c"
{
continue
;
}
#line 2705 "<stdout>"
json_parser_3:
++
buffer_re2c
;
json_parser_4:
#line 2661 "src/json.hpp.re2c"
{
return
last_token
=
token_type
::
parse_error
;
}
#line 2711 "<stdout>"
json_parser_5:
yych
=
*++
buffer_re2c
;
goto
json_parser_60
;
...
...
@@ -2786,9 +2793,11 @@ json_parser_6:
goto
json_parser_51
;
json_parser_7:
++
buffer_re2c
;
#line 2629 "src/json.hpp.re2c"
{
return
last_token
=
token_type
::
value_separator
;
}
#line 2723 "<stdout>"
json_parser_9:
yych
=
*++
buffer_re2c
;
if
(
yych
<=
'/'
)
...
...
@@ -2826,28 +2835,36 @@ json_parser_10:
}
}
json_parser_11:
#line 2649 "src/json.hpp.re2c"
{
return
last_token
=
token_type
::
value_number
;
}
#line 2742 "<stdout>"
json_parser_12:
yyaccept
=
1
;
yych
=
*
(
marker
=
++
buffer_re2c
);
goto
json_parser_41
;
json_parser_13:
++
buffer_re2c
;
#line 2630 "src/json.hpp.re2c"
{
return
last_token
=
token_type
::
name_separator
;
}
#line 2751 "<stdout>"
json_parser_15:
++
buffer_re2c
;
#line 2625 "src/json.hpp.re2c"
{
return
last_token
=
token_type
::
begin_array
;
}
#line 2756 "<stdout>"
json_parser_17:
++
buffer_re2c
;
#line 2626 "src/json.hpp.re2c"
{
return
last_token
=
token_type
::
end_array
;
}
#line 2761 "<stdout>"
json_parser_19:
yyaccept
=
0
;
yych
=
*
(
marker
=
++
buffer_re2c
);
...
...
@@ -2874,14 +2891,18 @@ json_parser_21:
goto
json_parser_4
;
json_parser_22:
++
buffer_re2c
;
#line 2627 "src/json.hpp.re2c"
{
return
last_token
=
token_type
::
begin_object
;
}
#line 2781 "<stdout>"
json_parser_24:
++
buffer_re2c
;
#line 2628 "src/json.hpp.re2c"
{
return
last_token
=
token_type
::
end_object
;
}
#line 2786 "<stdout>"
json_parser_26:
yych
=
*++
buffer_re2c
;
if
(
yych
==
'u'
)
...
...
@@ -2905,9 +2926,11 @@ json_parser_28:
goto
json_parser_27
;
}
++
buffer_re2c
;
#line 2634 "src/json.hpp.re2c"
{
return
last_token
=
token_type
::
literal_true
;
}
#line 2803 "<stdout>"
json_parser_31:
yych
=
*++
buffer_re2c
;
if
(
yych
!=
'l'
)
...
...
@@ -2920,9 +2943,11 @@ json_parser_31:
goto
json_parser_27
;
}
++
buffer_re2c
;
#line 2633 "src/json.hpp.re2c"
{
return
last_token
=
token_type
::
literal_null
;
}
#line 2812 "<stdout>"
json_parser_35:
yych
=
*++
buffer_re2c
;
if
(
yych
!=
'l'
)
...
...
@@ -2940,9 +2965,11 @@ json_parser_35:
goto
json_parser_27
;
}
++
buffer_re2c
;
#line 2635 "src/json.hpp.re2c"
{
return
last_token
=
token_type
::
literal_false
;
}
#line 2823 "<stdout>"
json_parser_40:
yyaccept
=
1
;
marker
=
++
buffer_re2c
;
...
...
@@ -3168,9 +3195,11 @@ json_parser_51:
}
json_parser_53:
++
buffer_re2c
;
#line 2658 "src/json.hpp.re2c"
{
return
last_token
=
token_type
::
value_string
;
}
#line 2932 "<stdout>"
json_parser_55:
++
buffer_re2c
;
yych
=
*
buffer_re2c
;
...
...
@@ -3299,6 +3328,7 @@ json_parser_60:
}
goto
json_parser_2
;
}
#line 2662 "src/json.hpp.re2c"
}
}
...
...
test/unit.cpp
浏览文件 @
963ec13b
...
...
@@ -3940,36 +3940,59 @@ TEST_CASE("convenience functions")
CHECK
(
json
::
escape_string
(
"
\r
"
)
==
"
\\
r"
);
CHECK
(
json
::
escape_string
(
"
\t
"
)
==
"
\\
t"
);
CHECK
(
json
::
escape_string
(
"
\x01
"
)
==
"
\\
u0001"
);
CHECK
(
json
::
escape_string
(
"
\x02
"
)
==
"
\\
u0002"
);
CHECK
(
json
::
escape_string
(
"
\x03
"
)
==
"
\\
u0003"
);
CHECK
(
json
::
escape_string
(
"
\x04
"
)
==
"
\\
u0004"
);
CHECK
(
json
::
escape_string
(
"
\x05
"
)
==
"
\\
u0005"
);
CHECK
(
json
::
escape_string
(
"
\x06
"
)
==
"
\\
u0006"
);
CHECK
(
json
::
escape_string
(
"
\x07
"
)
==
"
\\
u0007"
);
CHECK
(
json
::
escape_string
(
"
\x08
"
)
==
"
\\
b"
);
CHECK
(
json
::
escape_string
(
"
\x09
"
)
==
"
\\
t"
);
CHECK
(
json
::
escape_string
(
"
\x0a
"
)
==
"
\\
n"
);
CHECK
(
json
::
escape_string
(
"
\x0b
"
)
==
"
\\
u000b"
);
CHECK
(
json
::
escape_string
(
"
\x0c
"
)
==
"
\\
f"
);
CHECK
(
json
::
escape_string
(
"
\x0d
"
)
==
"
\\
r"
);
CHECK
(
json
::
escape_string
(
"
\x0e
"
)
==
"
\\
u000e"
);
CHECK
(
json
::
escape_string
(
"
\x0f
"
)
==
"
\\
u000f"
);
CHECK
(
json
::
escape_string
(
"
\x10
"
)
==
"
\\
u0010"
);
CHECK
(
json
::
escape_string
(
"
\x11
"
)
==
"
\\
u0011"
);
CHECK
(
json
::
escape_string
(
"
\x12
"
)
==
"
\\
u0012"
);
CHECK
(
json
::
escape_string
(
"
\x13
"
)
==
"
\\
u0013"
);
CHECK
(
json
::
escape_string
(
"
\x14
"
)
==
"
\\
u0014"
);
CHECK
(
json
::
escape_string
(
"
\x15
"
)
==
"
\\
u0015"
);
CHECK
(
json
::
escape_string
(
"
\x16
"
)
==
"
\\
u0016"
);
CHECK
(
json
::
escape_string
(
"
\x17
"
)
==
"
\\
u0017"
);
CHECK
(
json
::
escape_string
(
"
\x18
"
)
==
"
\\
u0018"
);
CHECK
(
json
::
escape_string
(
"
\x19
"
)
==
"
\\
u0019"
);
CHECK
(
json
::
escape_string
(
"
\x1a
"
)
==
"
\\
u001a"
);
CHECK
(
json
::
escape_string
(
"
\x1b
"
)
==
"
\\
u001b"
);
CHECK
(
json
::
escape_string
(
"
\x1c
"
)
==
"
\\
u001c"
);
CHECK
(
json
::
escape_string
(
"
\x1d
"
)
==
"
\\
u001d"
);
CHECK
(
json
::
escape_string
(
"
\x1e
"
)
==
"
\\
u001e"
);
CHECK
(
json
::
escape_string
(
"
\x1f
"
)
==
"
\\
u001f"
);
CHECK
(
json
::
escape_string
(
"
\x01
"
)
==
"
\\
u0001"
);
CHECK
(
json
::
escape_string
(
"
\x02
"
)
==
"
\\
u0002"
);
CHECK
(
json
::
escape_string
(
"
\x03
"
)
==
"
\\
u0003"
);
CHECK
(
json
::
escape_string
(
"
\x04
"
)
==
"
\\
u0004"
);
CHECK
(
json
::
escape_string
(
"
\x05
"
)
==
"
\\
u0005"
);
CHECK
(
json
::
escape_string
(
"
\x06
"
)
==
"
\\
u0006"
);
CHECK
(
json
::
escape_string
(
"
\x07
"
)
==
"
\\
u0007"
);
CHECK
(
json
::
escape_string
(
"
\x08
"
)
==
"
\\
b"
);
CHECK
(
json
::
escape_string
(
"
\x09
"
)
==
"
\\
t"
);
CHECK
(
json
::
escape_string
(
"
\x0a
"
)
==
"
\\
n"
);
CHECK
(
json
::
escape_string
(
"
\x0b
"
)
==
"
\\
u000b"
);
CHECK
(
json
::
escape_string
(
"
\x0c
"
)
==
"
\\
f"
);
CHECK
(
json
::
escape_string
(
"
\x0d
"
)
==
"
\\
r"
);
CHECK
(
json
::
escape_string
(
"
\x0e
"
)
==
"
\\
u000e"
);
CHECK
(
json
::
escape_string
(
"
\x0f
"
)
==
"
\\
u000f"
);
CHECK
(
json
::
escape_string
(
"
\x10
"
)
==
"
\\
u0010"
);
CHECK
(
json
::
escape_string
(
"
\x11
"
)
==
"
\\
u0011"
);
CHECK
(
json
::
escape_string
(
"
\x12
"
)
==
"
\\
u0012"
);
CHECK
(
json
::
escape_string
(
"
\x13
"
)
==
"
\\
u0013"
);
CHECK
(
json
::
escape_string
(
"
\x14
"
)
==
"
\\
u0014"
);
CHECK
(
json
::
escape_string
(
"
\x15
"
)
==
"
\\
u0015"
);
CHECK
(
json
::
escape_string
(
"
\x16
"
)
==
"
\\
u0016"
);
CHECK
(
json
::
escape_string
(
"
\x17
"
)
==
"
\\
u0017"
);
CHECK
(
json
::
escape_string
(
"
\x18
"
)
==
"
\\
u0018"
);
CHECK
(
json
::
escape_string
(
"
\x19
"
)
==
"
\\
u0019"
);
CHECK
(
json
::
escape_string
(
"
\x1a
"
)
==
"
\\
u001a"
);
CHECK
(
json
::
escape_string
(
"
\x1b
"
)
==
"
\\
u001b"
);
CHECK
(
json
::
escape_string
(
"
\x1c
"
)
==
"
\\
u001c"
);
CHECK
(
json
::
escape_string
(
"
\x1d
"
)
==
"
\\
u001d"
);
CHECK
(
json
::
escape_string
(
"
\x1e
"
)
==
"
\\
u001e"
);
CHECK
(
json
::
escape_string
(
"
\x1f
"
)
==
"
\\
u001f"
);
}
}
TEST_CASE
(
"parser class"
)
{
SECTION
(
"get_token"
)
{
SECTION
(
"structural characters"
)
{
CHECK
(
json
::
parser
(
"["
).
last_token
==
json
::
parser
::
token_type
::
begin_array
);
CHECK
(
json
::
parser
(
"]"
).
last_token
==
json
::
parser
::
token_type
::
end_array
);
CHECK
(
json
::
parser
(
"{"
).
last_token
==
json
::
parser
::
token_type
::
begin_object
);
CHECK
(
json
::
parser
(
"}"
).
last_token
==
json
::
parser
::
token_type
::
end_object
);
CHECK
(
json
::
parser
(
","
).
last_token
==
json
::
parser
::
token_type
::
value_separator
);
CHECK
(
json
::
parser
(
":"
).
last_token
==
json
::
parser
::
token_type
::
name_separator
);
}
SECTION
(
"literal names"
)
{
CHECK
(
json
::
parser
(
"null"
).
last_token
==
json
::
parser
::
token_type
::
literal_null
);
CHECK
(
json
::
parser
(
"true"
).
last_token
==
json
::
parser
::
token_type
::
literal_true
);
CHECK
(
json
::
parser
(
"false"
).
last_token
==
json
::
parser
::
token_type
::
literal_false
);
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录