Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
json
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
json
Commits
d3216300
Commit
d3216300
authored
Dec 28, 2014
by
Niels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
+ more test cases
parent
ea94518a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
5 deletions
+30
-5
src/JSON.cc
src/JSON.cc
+0
-5
test/JSON_unit.cc
test/JSON_unit.cc
+30
-0
No files found.
src/JSON.cc
View file @
d3216300
...
...
@@ -1940,11 +1940,6 @@ JSON::Parser::~Parser()
*/
void
JSON
::
Parser
::
parse
(
JSON
&
result
)
{
if
(
_buffer
==
nullptr
)
{
error
(
"unexpected end of file"
);
}
switch
(
_current
)
{
case
(
'{'
):
...
...
test/JSON_unit.cc
View file @
d3216300
...
...
@@ -1335,6 +1335,36 @@ TEST_CASE("Parser")
CHECK_THROWS_AS
(
JSON
::
parse
(
"infinity"
),
std
::
invalid_argument
);
}
SECTION
(
"number (float)"
)
{
// accept the exact values
CHECK
(
JSON
::
parse
(
"0.5"
)
==
JSON
(
0.5
));
CHECK
(
JSON
::
parse
(
"-0.5"
)
==
JSON
(
-
0.5
));
CHECK
(
JSON
::
parse
(
"1.5"
)
==
JSON
(
1.5
));
CHECK
(
JSON
::
parse
(
"-1.5"
)
==
JSON
(
-
1.5
));
CHECK
(
JSON
::
parse
(
"12345678.5"
)
==
JSON
(
12345678.5
));
CHECK
(
JSON
::
parse
(
"-12345678.5"
)
==
JSON
(
-
12345678.5
));
CHECK
(
JSON
::
parse
(
"17.5e0"
)
==
JSON
(
17.5
));
CHECK
(
JSON
::
parse
(
"17.5e1"
)
==
JSON
(
175
));
CHECK
(
JSON
::
parse
(
"17.5e3"
)
==
JSON
(
17500
));
CHECK
(
JSON
::
parse
(
"17.5e+0"
)
==
JSON
(
17.5
));
CHECK
(
JSON
::
parse
(
"17.5e+1"
)
==
JSON
(
175
));
CHECK
(
JSON
::
parse
(
"17.5e+3"
)
==
JSON
(
17500
));
CHECK
(
JSON
::
parse
(
"17.5E0"
)
==
JSON
(
17.5
));
CHECK
(
JSON
::
parse
(
"17.5E1"
)
==
JSON
(
175
));
CHECK
(
JSON
::
parse
(
"17.5E3"
)
==
JSON
(
17500
));
CHECK
(
JSON
::
parse
(
"17.5E+0"
)
==
JSON
(
17.5
));
CHECK
(
JSON
::
parse
(
"17.5E+1"
)
==
JSON
(
175
));
CHECK
(
JSON
::
parse
(
"17.5E+3"
)
==
JSON
(
17500
));
CHECK
(
JSON
::
parse
(
"10000.5e-0"
)
==
JSON
(
10000.5
));
CHECK
(
JSON
::
parse
(
"10000.5e-1"
)
==
JSON
(
1000.05
));
CHECK
(
JSON
::
parse
(
"10000.5e-4"
)
==
JSON
(
1.00005
));
CHECK
(
JSON
::
parse
(
"10000.5E-0"
)
==
JSON
(
10000.5
));
CHECK
(
JSON
::
parse
(
"10000.5E-1"
)
==
JSON
(
1000.05
));
CHECK
(
JSON
::
parse
(
"10000.5E-4"
)
==
JSON
(
1.00005
));
}
SECTION
(
"parse from C++ string"
)
{
std
::
string
s
=
"{
\"
foo
\"
: [1,2,true] }"
;
...
...
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