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
1ab26ab3
Commit
1ab26ab3
authored
Jan 16, 2017
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✨
option to switch off exceptions
parent
74cbd30c
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
21 deletions
+51
-21
.travis.yml
.travis.yml
+15
-0
json.hpp
src/json.hpp
+0
-0
json.hpp.re2c
src/json.hpp.re2c
+0
-0
Makefile
test/Makefile
+1
-1
unit-cbor.cpp
test/src/unit-cbor.cpp
+1
-1
unit-element_access2.cpp
test/src/unit-element_access2.cpp
+34
-19
No files found.
.travis.yml
View file @
1ab26ab3
...
...
@@ -71,6 +71,21 @@ matrix:
after_success
:
-
make cppcheck
# no exceptions
-
os
:
linux
compiler
:
gcc
env
:
-
COMPILER=g++-4.9
-
SPECIAL=no_exceptions
-
TEST_PATTERN="-e \"*\""
addons
:
apt
:
sources
:
[
'
ubuntu-toolchain-r-test'
]
packages
:
[
g++-4.9
,
cppcheck
]
before_script
:
-
make FLAGS="-fno-exceptions"
# Coveralls (http://gronlier.fr/blog/2015/01/adding-code-coverage-to-your-c-project/)
-
os
:
linux
...
...
src/json.hpp
View file @
1ab26ab3
This diff is collapsed.
Click to expand it.
src/json.hpp.re2c
View file @
1ab26ab3
This diff is collapsed.
Click to expand it.
test/Makefile
View file @
1ab26ab3
...
...
@@ -75,7 +75,7 @@ test-%: src/unit-%.cpp ../src/json.hpp thirdparty/catch/catch.hpp
@
echo
"[CXXLD]
$@
"
@
$(CXX)
$(CXXFLAGS)
$(CPPFLAGS)
$(LDFLAGS)
-DCATCH_CONFIG_MAIN
$<
-o
$@
TEST_PATTERN
=
"*"
TEST_PATTERN
?
=
"*"
TEST_PREFIX
=
""
check
:
$(TESTCASES)
@
cd
..
;
for
testcase
in
$(TESTCASES)
;
do
echo
"Executing
$$
testcase..."
;
$(TEST_PREFIX)
test
/
$$
testcase
$(TEST_PATTERN)
||
exit
1
;
done
...
...
test/src/unit-cbor.cpp
View file @
1ab26ab3
...
...
@@ -1187,7 +1187,7 @@ TEST_CASE("single CBOR roundtrip")
}
}
TEST_CASE
(
"CBOR regressions"
)
TEST_CASE
(
"CBOR regressions"
,
"[!throws]"
)
{
SECTION
(
"fuzz test results"
)
{
...
...
test/src/unit-element_access2.cpp
View file @
1ab26ab3
...
...
@@ -298,25 +298,6 @@ TEST_CASE("element access 2")
CHECK
(
j_const
.
value
(
"/array"
_json_pointer
,
json
({
10
,
100
}))
==
json
({
1
,
2
,
3
}));
}
SECTION
(
"access non-existing value"
)
{
CHECK
(
j
.
value
(
"/not/existing"
_json_pointer
,
2
)
==
2
);
CHECK
(
j
.
value
(
"/not/existing"
_json_pointer
,
2u
)
==
2u
);
CHECK
(
j
.
value
(
"/not/existing"
_json_pointer
,
false
)
==
false
);
CHECK
(
j
.
value
(
"/not/existing"
_json_pointer
,
"bar"
)
==
"bar"
);
CHECK
(
j
.
value
(
"/not/existing"
_json_pointer
,
12.34
)
==
Approx
(
12.34
));
CHECK
(
j
.
value
(
"/not/existing"
_json_pointer
,
json
({{
"foo"
,
"bar"
}}))
==
json
({{
"foo"
,
"bar"
}}));
CHECK
(
j
.
value
(
"/not/existing"
_json_pointer
,
json
({
10
,
100
}))
==
json
({
10
,
100
}));
CHECK
(
j_const
.
value
(
"/not/existing"
_json_pointer
,
2
)
==
2
);
CHECK
(
j_const
.
value
(
"/not/existing"
_json_pointer
,
2u
)
==
2u
);
CHECK
(
j_const
.
value
(
"/not/existing"
_json_pointer
,
false
)
==
false
);
CHECK
(
j_const
.
value
(
"/not/existing"
_json_pointer
,
"bar"
)
==
"bar"
);
CHECK
(
j_const
.
value
(
"/not/existing"
_json_pointer
,
12.34
)
==
Approx
(
12.34
));
CHECK
(
j_const
.
value
(
"/not/existing"
_json_pointer
,
json
({{
"foo"
,
"bar"
}}))
==
json
({{
"foo"
,
"bar"
}}));
CHECK
(
j_const
.
value
(
"/not/existing"
_json_pointer
,
json
({
10
,
100
}))
==
json
({
10
,
100
}));
}
SECTION
(
"access on non-object type"
)
{
SECTION
(
"null"
)
...
...
@@ -957,3 +938,37 @@ TEST_CASE("element access 2")
}
}
}
TEST_CASE
(
"element access 2 (throwing tests)"
,
"[!throws]"
)
{
SECTION
(
"object"
)
{
json
j
=
{{
"integer"
,
1
},
{
"unsigned"
,
1u
},
{
"floating"
,
42.23
},
{
"null"
,
nullptr
},
{
"string"
,
"hello world"
},
{
"boolean"
,
true
},
{
"object"
,
json
::
object
()},
{
"array"
,
{
1
,
2
,
3
}}};
const
json
j_const
=
j
;
SECTION
(
"access specified element with default value"
)
{
SECTION
(
"given a JSON pointer"
)
{
SECTION
(
"access non-existing value"
)
{
CHECK
(
j
.
value
(
"/not/existing"
_json_pointer
,
2
)
==
2
);
CHECK
(
j
.
value
(
"/not/existing"
_json_pointer
,
2u
)
==
2u
);
CHECK
(
j
.
value
(
"/not/existing"
_json_pointer
,
false
)
==
false
);
CHECK
(
j
.
value
(
"/not/existing"
_json_pointer
,
"bar"
)
==
"bar"
);
CHECK
(
j
.
value
(
"/not/existing"
_json_pointer
,
12.34
)
==
Approx
(
12.34
));
CHECK
(
j
.
value
(
"/not/existing"
_json_pointer
,
json
({{
"foo"
,
"bar"
}}))
==
json
({{
"foo"
,
"bar"
}}));
CHECK
(
j
.
value
(
"/not/existing"
_json_pointer
,
json
({
10
,
100
}))
==
json
({
10
,
100
}));
CHECK
(
j_const
.
value
(
"/not/existing"
_json_pointer
,
2
)
==
2
);
CHECK
(
j_const
.
value
(
"/not/existing"
_json_pointer
,
2u
)
==
2u
);
CHECK
(
j_const
.
value
(
"/not/existing"
_json_pointer
,
false
)
==
false
);
CHECK
(
j_const
.
value
(
"/not/existing"
_json_pointer
,
"bar"
)
==
"bar"
);
CHECK
(
j_const
.
value
(
"/not/existing"
_json_pointer
,
12.34
)
==
Approx
(
12.34
));
CHECK
(
j_const
.
value
(
"/not/existing"
_json_pointer
,
json
({{
"foo"
,
"bar"
}}))
==
json
({{
"foo"
,
"bar"
}}));
CHECK
(
j_const
.
value
(
"/not/existing"
_json_pointer
,
json
({
10
,
100
}))
==
json
({
10
,
100
}));
}
}
}
}
}
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