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
7e750ec1
Commit
7e750ec1
authored
Dec 14, 2016
by
Théo DELRIEU
Committed by
Théo DELRIEU
Jan 21, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix msvc, by doubling parenthesis on catch assertions
parent
3d405c68
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
65 deletions
+65
-65
unit-class_lexer.cpp
test/src/unit-class_lexer.cpp
+65
-65
No files found.
test/src/unit-class_lexer.cpp
View file @
7e750ec1
...
@@ -38,86 +38,86 @@ TEST_CASE("lexer class")
...
@@ -38,86 +38,86 @@ TEST_CASE("lexer class")
{
{
SECTION
(
"structural characters"
)
SECTION
(
"structural characters"
)
{
{
CHECK
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"["
),
CHECK
(
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"["
),
1
).
scan
()
==
json
::
lexer
::
token_type
::
begin_array
);
1
).
scan
()
==
json
::
lexer
::
token_type
::
begin_array
)
)
;
CHECK
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"]"
),
CHECK
(
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"]"
),
1
).
scan
()
==
json
::
lexer
::
token_type
::
end_array
);
1
).
scan
()
==
json
::
lexer
::
token_type
::
end_array
)
)
;
CHECK
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"{"
),
CHECK
(
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"{"
),
1
).
scan
()
==
json
::
lexer
::
token_type
::
begin_object
);
1
).
scan
()
==
json
::
lexer
::
token_type
::
begin_object
)
)
;
CHECK
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"}"
),
CHECK
(
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"}"
),
1
).
scan
()
==
json
::
lexer
::
token_type
::
end_object
);
1
).
scan
()
==
json
::
lexer
::
token_type
::
end_object
)
)
;
CHECK
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
","
),
CHECK
(
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
","
),
1
).
scan
()
==
json
::
lexer
::
token_type
::
value_separator
);
1
).
scan
()
==
json
::
lexer
::
token_type
::
value_separator
)
)
;
CHECK
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
":"
),
CHECK
(
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
":"
),
1
).
scan
()
==
json
::
lexer
::
token_type
::
name_separator
);
1
).
scan
()
==
json
::
lexer
::
token_type
::
name_separator
)
)
;
}
}
SECTION
(
"literal names"
)
SECTION
(
"literal names"
)
{
{
CHECK
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"null"
),
CHECK
(
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"null"
),
4
).
scan
()
==
json
::
lexer
::
token_type
::
literal_null
);
4
).
scan
()
==
json
::
lexer
::
token_type
::
literal_null
)
)
;
CHECK
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"true"
),
CHECK
(
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"true"
),
4
).
scan
()
==
json
::
lexer
::
token_type
::
literal_true
);
4
).
scan
()
==
json
::
lexer
::
token_type
::
literal_true
)
)
;
CHECK
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"false"
),
CHECK
(
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"false"
),
5
).
scan
()
==
json
::
lexer
::
token_type
::
literal_false
);
5
).
scan
()
==
json
::
lexer
::
token_type
::
literal_false
)
)
;
}
}
SECTION
(
"numbers"
)
SECTION
(
"numbers"
)
{
{
CHECK
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"0"
),
CHECK
(
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"0"
),
1
).
scan
()
==
json
::
lexer
::
token_type
::
value_number
);
1
).
scan
()
==
json
::
lexer
::
token_type
::
value_number
)
)
;
CHECK
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"1"
),
CHECK
(
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"1"
),
1
).
scan
()
==
json
::
lexer
::
token_type
::
value_number
);
1
).
scan
()
==
json
::
lexer
::
token_type
::
value_number
)
)
;
CHECK
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"2"
),
CHECK
(
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"2"
),
1
).
scan
()
==
json
::
lexer
::
token_type
::
value_number
);
1
).
scan
()
==
json
::
lexer
::
token_type
::
value_number
)
)
;
CHECK
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"3"
),
CHECK
(
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"3"
),
1
).
scan
()
==
json
::
lexer
::
token_type
::
value_number
);
1
).
scan
()
==
json
::
lexer
::
token_type
::
value_number
)
)
;
CHECK
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"4"
),
CHECK
(
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"4"
),
1
).
scan
()
==
json
::
lexer
::
token_type
::
value_number
);
1
).
scan
()
==
json
::
lexer
::
token_type
::
value_number
)
)
;
CHECK
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"5"
),
CHECK
(
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"5"
),
1
).
scan
()
==
json
::
lexer
::
token_type
::
value_number
);
1
).
scan
()
==
json
::
lexer
::
token_type
::
value_number
)
)
;
CHECK
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"6"
),
CHECK
(
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"6"
),
1
).
scan
()
==
json
::
lexer
::
token_type
::
value_number
);
1
).
scan
()
==
json
::
lexer
::
token_type
::
value_number
)
)
;
CHECK
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"7"
),
CHECK
(
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"7"
),
1
).
scan
()
==
json
::
lexer
::
token_type
::
value_number
);
1
).
scan
()
==
json
::
lexer
::
token_type
::
value_number
)
)
;
CHECK
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"8"
),
CHECK
(
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"8"
),
1
).
scan
()
==
json
::
lexer
::
token_type
::
value_number
);
1
).
scan
()
==
json
::
lexer
::
token_type
::
value_number
)
)
;
CHECK
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"9"
),
CHECK
(
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"9"
),
1
).
scan
()
==
json
::
lexer
::
token_type
::
value_number
);
1
).
scan
()
==
json
::
lexer
::
token_type
::
value_number
)
)
;
}
}
SECTION
(
"whitespace"
)
SECTION
(
"whitespace"
)
{
{
// result is end_of_input, because not token is following
// result is end_of_input, because not token is following
CHECK
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
" "
),
CHECK
(
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
" "
),
1
).
scan
()
==
json
::
lexer
::
token_type
::
end_of_input
);
1
).
scan
()
==
json
::
lexer
::
token_type
::
end_of_input
)
)
;
CHECK
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"
\t
"
),
CHECK
(
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"
\t
"
),
1
).
scan
()
==
json
::
lexer
::
token_type
::
end_of_input
);
1
).
scan
()
==
json
::
lexer
::
token_type
::
end_of_input
)
)
;
CHECK
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"
\n
"
),
CHECK
(
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"
\n
"
),
1
).
scan
()
==
json
::
lexer
::
token_type
::
end_of_input
);
1
).
scan
()
==
json
::
lexer
::
token_type
::
end_of_input
)
)
;
CHECK
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"
\r
"
),
CHECK
(
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"
\r
"
),
1
).
scan
()
==
json
::
lexer
::
token_type
::
end_of_input
);
1
).
scan
()
==
json
::
lexer
::
token_type
::
end_of_input
)
)
;
CHECK
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"
\t\n\r\n\t
"
),
CHECK
(
(
json
::
lexer
(
reinterpret_cast
<
const
json
::
lexer
::
lexer_char_t
*>
(
"
\t\n\r\n\t
"
),
7
).
scan
()
==
json
::
lexer
::
token_type
::
end_of_input
);
7
).
scan
()
==
json
::
lexer
::
token_type
::
end_of_input
)
)
;
}
}
}
}
SECTION
(
"token_type_name"
)
SECTION
(
"token_type_name"
)
{
{
CHECK
(
json
::
lexer
::
token_type_name
(
json
::
lexer
::
token_type
::
uninitialized
)
==
"<uninitialized>"
);
CHECK
(
(
json
::
lexer
::
token_type_name
(
json
::
lexer
::
token_type
::
uninitialized
)
==
"<uninitialized>"
)
);
CHECK
(
json
::
lexer
::
token_type_name
(
json
::
lexer
::
token_type
::
literal_true
)
==
"true literal"
);
CHECK
(
(
json
::
lexer
::
token_type_name
(
json
::
lexer
::
token_type
::
literal_true
)
==
"true literal"
)
);
CHECK
(
json
::
lexer
::
token_type_name
(
json
::
lexer
::
token_type
::
literal_false
)
==
"false literal"
);
CHECK
(
(
json
::
lexer
::
token_type_name
(
json
::
lexer
::
token_type
::
literal_false
)
==
"false literal"
)
);
CHECK
(
json
::
lexer
::
token_type_name
(
json
::
lexer
::
token_type
::
literal_null
)
==
"null literal"
);
CHECK
(
(
json
::
lexer
::
token_type_name
(
json
::
lexer
::
token_type
::
literal_null
)
==
"null literal"
)
);
CHECK
(
json
::
lexer
::
token_type_name
(
json
::
lexer
::
token_type
::
value_string
)
==
"string literal"
);
CHECK
(
(
json
::
lexer
::
token_type_name
(
json
::
lexer
::
token_type
::
value_string
)
==
"string literal"
)
);
CHECK
(
json
::
lexer
::
token_type_name
(
json
::
lexer
::
token_type
::
value_number
)
==
"number literal"
);
CHECK
(
(
json
::
lexer
::
token_type_name
(
json
::
lexer
::
token_type
::
value_number
)
==
"number literal"
)
);
CHECK
(
json
::
lexer
::
token_type_name
(
json
::
lexer
::
token_type
::
begin_array
)
==
"'['"
);
CHECK
(
(
json
::
lexer
::
token_type_name
(
json
::
lexer
::
token_type
::
begin_array
)
==
"'['"
)
);
CHECK
(
json
::
lexer
::
token_type_name
(
json
::
lexer
::
token_type
::
begin_object
)
==
"'{'"
);
CHECK
(
(
json
::
lexer
::
token_type_name
(
json
::
lexer
::
token_type
::
begin_object
)
==
"'{'"
)
);
CHECK
(
json
::
lexer
::
token_type_name
(
json
::
lexer
::
token_type
::
end_array
)
==
"']'"
);
CHECK
(
(
json
::
lexer
::
token_type_name
(
json
::
lexer
::
token_type
::
end_array
)
==
"']'"
)
);
CHECK
(
json
::
lexer
::
token_type_name
(
json
::
lexer
::
token_type
::
end_object
)
==
"'}'"
);
CHECK
(
(
json
::
lexer
::
token_type_name
(
json
::
lexer
::
token_type
::
end_object
)
==
"'}'"
)
);
CHECK
(
json
::
lexer
::
token_type_name
(
json
::
lexer
::
token_type
::
name_separator
)
==
"':'"
);
CHECK
(
(
json
::
lexer
::
token_type_name
(
json
::
lexer
::
token_type
::
name_separator
)
==
"':'"
)
);
CHECK
(
json
::
lexer
::
token_type_name
(
json
::
lexer
::
token_type
::
value_separator
)
==
"','"
);
CHECK
(
(
json
::
lexer
::
token_type_name
(
json
::
lexer
::
token_type
::
value_separator
)
==
"','"
)
);
CHECK
(
json
::
lexer
::
token_type_name
(
json
::
lexer
::
token_type
::
parse_error
)
==
"<parse error>"
);
CHECK
(
(
json
::
lexer
::
token_type_name
(
json
::
lexer
::
token_type
::
parse_error
)
==
"<parse error>"
)
);
CHECK
(
json
::
lexer
::
token_type_name
(
json
::
lexer
::
token_type
::
end_of_input
)
==
"end of input"
);
CHECK
(
(
json
::
lexer
::
token_type_name
(
json
::
lexer
::
token_type
::
end_of_input
)
==
"end of input"
)
);
}
}
SECTION
(
"parse errors on first character"
)
SECTION
(
"parse errors on first character"
)
...
@@ -150,7 +150,7 @@ TEST_CASE("lexer class")
...
@@ -150,7 +150,7 @@ TEST_CASE("lexer class")
case
(
'8'
):
case
(
'8'
):
case
(
'9'
):
case
(
'9'
):
{
{
CHECK
(
res
!=
json
::
lexer
::
token_type
::
parse_error
);
CHECK
(
(
res
!=
json
::
lexer
::
token_type
::
parse_error
)
);
break
;
break
;
}
}
...
@@ -160,14 +160,14 @@ TEST_CASE("lexer class")
...
@@ -160,14 +160,14 @@ TEST_CASE("lexer class")
case
(
'\n'
):
case
(
'\n'
):
case
(
'\r'
):
case
(
'\r'
):
{
{
CHECK
(
res
==
json
::
lexer
::
token_type
::
end_of_input
);
CHECK
(
(
res
==
json
::
lexer
::
token_type
::
end_of_input
)
);
break
;
break
;
}
}
// anything else is not expected
// anything else is not expected
default
:
default
:
{
{
CHECK
(
res
==
json
::
lexer
::
token_type
::
parse_error
);
CHECK
(
(
res
==
json
::
lexer
::
token_type
::
parse_error
)
);
break
;
break
;
}
}
}
}
...
...
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