Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
json
Commits
963ec13b
Commit
963ec13b
authored
Feb 10, 2015
by
Niels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testing the parser
parent
35898370
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
86 additions
and
32 deletions
+86
-32
Makefile.am
Makefile.am
+1
-1
json.hpp
src/json.hpp
+30
-0
unit.cpp
test/unit.cpp
+55
-31
No files found.
Makefile.am
View file @
963ec13b
...
@@ -14,7 +14,7 @@ json_unit_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/test -Dprivate=public
...
@@ -14,7 +14,7 @@ json_unit_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/test -Dprivate=public
# -i do not create #line information
# -i do not create #line information
# --no-generation-date suppress generation date output
# --no-generation-date suppress generation date output
src/json.hpp
:
src/json.hpp.re2c
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
:
cppcheck
--enable
=
all
--inconclusive
--std
=
c++11 src/json.hpp
cppcheck
--enable
=
all
--inconclusive
--std
=
c++11 src/json.hpp
...
...
src/json.hpp
View file @
963ec13b
#line 1 "src/json.hpp.re2c"
#ifndef _NLOHMANN_JSON
#ifndef _NLOHMANN_JSON
#define _NLOHMANN_JSON
#define _NLOHMANN_JSON
...
@@ -2601,6 +2602,7 @@ class basic_json
...
@@ -2601,6 +2602,7 @@ class basic_json
const
lexer_char_t
*
marker
;
const
lexer_char_t
*
marker
;
// set up RE2C
// set up RE2C
#line 2612 "src/json.hpp.re2c"
for
(;;)
for
(;;)
...
@@ -2609,6 +2611,7 @@ class basic_json
...
@@ -2609,6 +2611,7 @@ class basic_json
current_re2c
=
buffer_re2c
;
current_re2c
=
buffer_re2c
;
#line 2616 "<stdout>"
{
{
lexer_char_t
yych
;
lexer_char_t
yych
;
unsigned
int
yyaccept
=
0
;
unsigned
int
yyaccept
=
0
;
...
@@ -2768,15 +2771,19 @@ class basic_json
...
@@ -2768,15 +2771,19 @@ class basic_json
}
}
}
}
json_parser_2
:
json_parser_2
:
#line 2622 "src/json.hpp.re2c"
{
{
continue
;
continue
;
}
}
#line 2705 "<stdout>"
json_parser_3
:
json_parser_3
:
++
buffer_re2c
;
++
buffer_re2c
;
json_parser_4
:
json_parser_4
:
#line 2661 "src/json.hpp.re2c"
{
{
return
last_token
=
token_type
::
parse_error
;
return
last_token
=
token_type
::
parse_error
;
}
}
#line 2711 "<stdout>"
json_parser_5
:
json_parser_5
:
yych
=
*++
buffer_re2c
;
yych
=
*++
buffer_re2c
;
goto
json_parser_60
;
goto
json_parser_60
;
...
@@ -2786,9 +2793,11 @@ json_parser_6:
...
@@ -2786,9 +2793,11 @@ json_parser_6:
goto
json_parser_51
;
goto
json_parser_51
;
json_parser_7
:
json_parser_7
:
++
buffer_re2c
;
++
buffer_re2c
;
#line 2629 "src/json.hpp.re2c"
{
{
return
last_token
=
token_type
::
value_separator
;
return
last_token
=
token_type
::
value_separator
;
}
}
#line 2723 "<stdout>"
json_parser_9
:
json_parser_9
:
yych
=
*++
buffer_re2c
;
yych
=
*++
buffer_re2c
;
if
(
yych
<=
'/'
)
if
(
yych
<=
'/'
)
...
@@ -2826,28 +2835,36 @@ json_parser_10:
...
@@ -2826,28 +2835,36 @@ json_parser_10:
}
}
}
}
json_parser_11
:
json_parser_11
:
#line 2649 "src/json.hpp.re2c"
{
{
return
last_token
=
token_type
::
value_number
;
return
last_token
=
token_type
::
value_number
;
}
}
#line 2742 "<stdout>"
json_parser_12
:
json_parser_12
:
yyaccept
=
1
;
yyaccept
=
1
;
yych
=
*
(
marker
=
++
buffer_re2c
);
yych
=
*
(
marker
=
++
buffer_re2c
);
goto
json_parser_41
;
goto
json_parser_41
;
json_parser_13
:
json_parser_13
:
++
buffer_re2c
;
++
buffer_re2c
;
#line 2630 "src/json.hpp.re2c"
{
{
return
last_token
=
token_type
::
name_separator
;
return
last_token
=
token_type
::
name_separator
;
}
}
#line 2751 "<stdout>"
json_parser_15
:
json_parser_15
:
++
buffer_re2c
;
++
buffer_re2c
;
#line 2625 "src/json.hpp.re2c"
{
{
return
last_token
=
token_type
::
begin_array
;
return
last_token
=
token_type
::
begin_array
;
}
}
#line 2756 "<stdout>"
json_parser_17
:
json_parser_17
:
++
buffer_re2c
;
++
buffer_re2c
;
#line 2626 "src/json.hpp.re2c"
{
{
return
last_token
=
token_type
::
end_array
;
return
last_token
=
token_type
::
end_array
;
}
}
#line 2761 "<stdout>"
json_parser_19
:
json_parser_19
:
yyaccept
=
0
;
yyaccept
=
0
;
yych
=
*
(
marker
=
++
buffer_re2c
);
yych
=
*
(
marker
=
++
buffer_re2c
);
...
@@ -2874,14 +2891,18 @@ json_parser_21:
...
@@ -2874,14 +2891,18 @@ json_parser_21:
goto
json_parser_4
;
goto
json_parser_4
;
json_parser_22
:
json_parser_22
:
++
buffer_re2c
;
++
buffer_re2c
;
#line 2627 "src/json.hpp.re2c"
{
{
return
last_token
=
token_type
::
begin_object
;
return
last_token
=
token_type
::
begin_object
;
}
}
#line 2781 "<stdout>"
json_parser_24
:
json_parser_24
:
++
buffer_re2c
;
++
buffer_re2c
;
#line 2628 "src/json.hpp.re2c"
{
{
return
last_token
=
token_type
::
end_object
;
return
last_token
=
token_type
::
end_object
;
}
}
#line 2786 "<stdout>"
json_parser_26
:
json_parser_26
:
yych
=
*++
buffer_re2c
;
yych
=
*++
buffer_re2c
;
if
(
yych
==
'u'
)
if
(
yych
==
'u'
)
...
@@ -2905,9 +2926,11 @@ json_parser_28:
...
@@ -2905,9 +2926,11 @@ json_parser_28:
goto
json_parser_27
;
goto
json_parser_27
;
}
}
++
buffer_re2c
;
++
buffer_re2c
;
#line 2634 "src/json.hpp.re2c"
{
{
return
last_token
=
token_type
::
literal_true
;
return
last_token
=
token_type
::
literal_true
;
}
}
#line 2803 "<stdout>"
json_parser_31
:
json_parser_31
:
yych
=
*++
buffer_re2c
;
yych
=
*++
buffer_re2c
;
if
(
yych
!=
'l'
)
if
(
yych
!=
'l'
)
...
@@ -2920,9 +2943,11 @@ json_parser_31:
...
@@ -2920,9 +2943,11 @@ json_parser_31:
goto
json_parser_27
;
goto
json_parser_27
;
}
}
++
buffer_re2c
;
++
buffer_re2c
;
#line 2633 "src/json.hpp.re2c"
{
{
return
last_token
=
token_type
::
literal_null
;
return
last_token
=
token_type
::
literal_null
;
}
}
#line 2812 "<stdout>"
json_parser_35
:
json_parser_35
:
yych
=
*++
buffer_re2c
;
yych
=
*++
buffer_re2c
;
if
(
yych
!=
'l'
)
if
(
yych
!=
'l'
)
...
@@ -2940,9 +2965,11 @@ json_parser_35:
...
@@ -2940,9 +2965,11 @@ json_parser_35:
goto
json_parser_27
;
goto
json_parser_27
;
}
}
++
buffer_re2c
;
++
buffer_re2c
;
#line 2635 "src/json.hpp.re2c"
{
{
return
last_token
=
token_type
::
literal_false
;
return
last_token
=
token_type
::
literal_false
;
}
}
#line 2823 "<stdout>"
json_parser_40
:
json_parser_40
:
yyaccept
=
1
;
yyaccept
=
1
;
marker
=
++
buffer_re2c
;
marker
=
++
buffer_re2c
;
...
@@ -3168,9 +3195,11 @@ json_parser_51:
...
@@ -3168,9 +3195,11 @@ json_parser_51:
}
}
json_parser_53
:
json_parser_53
:
++
buffer_re2c
;
++
buffer_re2c
;
#line 2658 "src/json.hpp.re2c"
{
{
return
last_token
=
token_type
::
value_string
;
return
last_token
=
token_type
::
value_string
;
}
}
#line 2932 "<stdout>"
json_parser_55
:
json_parser_55
:
++
buffer_re2c
;
++
buffer_re2c
;
yych
=
*
buffer_re2c
;
yych
=
*
buffer_re2c
;
...
@@ -3299,6 +3328,7 @@ json_parser_60:
...
@@ -3299,6 +3328,7 @@ json_parser_60:
}
}
goto
json_parser_2
;
goto
json_parser_2
;
}
}
#line 2662 "src/json.hpp.re2c"
}
}
}
}
...
...
test/unit.cpp
View file @
963ec13b
...
@@ -3940,36 +3940,59 @@ TEST_CASE("convenience functions")
...
@@ -3940,36 +3940,59 @@ TEST_CASE("convenience functions")
CHECK
(
json
::
escape_string
(
"
\r
"
)
==
"
\\
r"
);
CHECK
(
json
::
escape_string
(
"
\r
"
)
==
"
\\
r"
);
CHECK
(
json
::
escape_string
(
"
\t
"
)
==
"
\\
t"
);
CHECK
(
json
::
escape_string
(
"
\t
"
)
==
"
\\
t"
);
CHECK
(
json
::
escape_string
(
"
\x01
"
)
==
"
\\
u0001"
);
CHECK
(
json
::
escape_string
(
"
\x01
"
)
==
"
\\
u0001"
);
CHECK
(
json
::
escape_string
(
"
\x02
"
)
==
"
\\
u0002"
);
CHECK
(
json
::
escape_string
(
"
\x02
"
)
==
"
\\
u0002"
);
CHECK
(
json
::
escape_string
(
"
\x03
"
)
==
"
\\
u0003"
);
CHECK
(
json
::
escape_string
(
"
\x03
"
)
==
"
\\
u0003"
);
CHECK
(
json
::
escape_string
(
"
\x04
"
)
==
"
\\
u0004"
);
CHECK
(
json
::
escape_string
(
"
\x04
"
)
==
"
\\
u0004"
);
CHECK
(
json
::
escape_string
(
"
\x05
"
)
==
"
\\
u0005"
);
CHECK
(
json
::
escape_string
(
"
\x05
"
)
==
"
\\
u0005"
);
CHECK
(
json
::
escape_string
(
"
\x06
"
)
==
"
\\
u0006"
);
CHECK
(
json
::
escape_string
(
"
\x06
"
)
==
"
\\
u0006"
);
CHECK
(
json
::
escape_string
(
"
\x07
"
)
==
"
\\
u0007"
);
CHECK
(
json
::
escape_string
(
"
\x07
"
)
==
"
\\
u0007"
);
CHECK
(
json
::
escape_string
(
"
\x08
"
)
==
"
\\
b"
);
CHECK
(
json
::
escape_string
(
"
\x08
"
)
==
"
\\
b"
);
CHECK
(
json
::
escape_string
(
"
\x09
"
)
==
"
\\
t"
);
CHECK
(
json
::
escape_string
(
"
\x09
"
)
==
"
\\
t"
);
CHECK
(
json
::
escape_string
(
"
\x0a
"
)
==
"
\\
n"
);
CHECK
(
json
::
escape_string
(
"
\x0a
"
)
==
"
\\
n"
);
CHECK
(
json
::
escape_string
(
"
\x0b
"
)
==
"
\\
u000b"
);
CHECK
(
json
::
escape_string
(
"
\x0b
"
)
==
"
\\
u000b"
);
CHECK
(
json
::
escape_string
(
"
\x0c
"
)
==
"
\\
f"
);
CHECK
(
json
::
escape_string
(
"
\x0c
"
)
==
"
\\
f"
);
CHECK
(
json
::
escape_string
(
"
\x0d
"
)
==
"
\\
r"
);
CHECK
(
json
::
escape_string
(
"
\x0d
"
)
==
"
\\
r"
);
CHECK
(
json
::
escape_string
(
"
\x0e
"
)
==
"
\\
u000e"
);
CHECK
(
json
::
escape_string
(
"
\x0e
"
)
==
"
\\
u000e"
);
CHECK
(
json
::
escape_string
(
"
\x0f
"
)
==
"
\\
u000f"
);
CHECK
(
json
::
escape_string
(
"
\x0f
"
)
==
"
\\
u000f"
);
CHECK
(
json
::
escape_string
(
"
\x10
"
)
==
"
\\
u0010"
);
CHECK
(
json
::
escape_string
(
"
\x10
"
)
==
"
\\
u0010"
);
CHECK
(
json
::
escape_string
(
"
\x11
"
)
==
"
\\
u0011"
);
CHECK
(
json
::
escape_string
(
"
\x11
"
)
==
"
\\
u0011"
);
CHECK
(
json
::
escape_string
(
"
\x12
"
)
==
"
\\
u0012"
);
CHECK
(
json
::
escape_string
(
"
\x12
"
)
==
"
\\
u0012"
);
CHECK
(
json
::
escape_string
(
"
\x13
"
)
==
"
\\
u0013"
);
CHECK
(
json
::
escape_string
(
"
\x13
"
)
==
"
\\
u0013"
);
CHECK
(
json
::
escape_string
(
"
\x14
"
)
==
"
\\
u0014"
);
CHECK
(
json
::
escape_string
(
"
\x14
"
)
==
"
\\
u0014"
);
CHECK
(
json
::
escape_string
(
"
\x15
"
)
==
"
\\
u0015"
);
CHECK
(
json
::
escape_string
(
"
\x15
"
)
==
"
\\
u0015"
);
CHECK
(
json
::
escape_string
(
"
\x16
"
)
==
"
\\
u0016"
);
CHECK
(
json
::
escape_string
(
"
\x16
"
)
==
"
\\
u0016"
);
CHECK
(
json
::
escape_string
(
"
\x17
"
)
==
"
\\
u0017"
);
CHECK
(
json
::
escape_string
(
"
\x17
"
)
==
"
\\
u0017"
);
CHECK
(
json
::
escape_string
(
"
\x18
"
)
==
"
\\
u0018"
);
CHECK
(
json
::
escape_string
(
"
\x18
"
)
==
"
\\
u0018"
);
CHECK
(
json
::
escape_string
(
"
\x19
"
)
==
"
\\
u0019"
);
CHECK
(
json
::
escape_string
(
"
\x19
"
)
==
"
\\
u0019"
);
CHECK
(
json
::
escape_string
(
"
\x1a
"
)
==
"
\\
u001a"
);
CHECK
(
json
::
escape_string
(
"
\x1a
"
)
==
"
\\
u001a"
);
CHECK
(
json
::
escape_string
(
"
\x1b
"
)
==
"
\\
u001b"
);
CHECK
(
json
::
escape_string
(
"
\x1b
"
)
==
"
\\
u001b"
);
CHECK
(
json
::
escape_string
(
"
\x1c
"
)
==
"
\\
u001c"
);
CHECK
(
json
::
escape_string
(
"
\x1c
"
)
==
"
\\
u001c"
);
CHECK
(
json
::
escape_string
(
"
\x1d
"
)
==
"
\\
u001d"
);
CHECK
(
json
::
escape_string
(
"
\x1d
"
)
==
"
\\
u001d"
);
CHECK
(
json
::
escape_string
(
"
\x1e
"
)
==
"
\\
u001e"
);
CHECK
(
json
::
escape_string
(
"
\x1e
"
)
==
"
\\
u001e"
);
CHECK
(
json
::
escape_string
(
"
\x1f
"
)
==
"
\\
u001f"
);
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment