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
f05614b2
Unverified
Commit
f05614b2
authored
Apr 04, 2019
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🏗
adding anonymous namespace
parent
0da99027
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
51 additions
and
8 deletions
+51
-8
test/src/unit-allocator.cpp
test/src/unit-allocator.cpp
+6
-1
test/src/unit-alt-string.cpp
test/src/unit-alt-string.cpp
+0
-4
test/src/unit-bson.cpp
test/src/unit-bson.cpp
+3
-0
test/src/unit-cbor.cpp
test/src/unit-cbor.cpp
+3
-0
test/src/unit-class_lexer.cpp
test/src/unit-class_lexer.cpp
+3
-0
test/src/unit-class_parser.cpp
test/src/unit-class_parser.cpp
+3
-0
test/src/unit-comparison.cpp
test/src/unit-comparison.cpp
+3
-0
test/src/unit-convenience.cpp
test/src/unit-convenience.cpp
+3
-0
test/src/unit-deserialization.cpp
test/src/unit-deserialization.cpp
+3
-0
test/src/unit-msgpack.cpp
test/src/unit-msgpack.cpp
+3
-2
test/src/unit-noexcept.cpp
test/src/unit-noexcept.cpp
+3
-0
test/src/unit-testsuites.cpp
test/src/unit-testsuites.cpp
+3
-1
test/src/unit-to_chars.cpp
test/src/unit-to_chars.cpp
+3
-0
test/src/unit-ubjson.cpp
test/src/unit-ubjson.cpp
+3
-0
test/src/unit-unicode.cpp
test/src/unit-unicode.cpp
+6
-0
test/src/unit-wstring.cpp
test/src/unit-wstring.cpp
+3
-0
No files found.
test/src/unit-allocator.cpp
View file @
f05614b2
...
...
@@ -34,8 +34,9 @@ SOFTWARE.
using
nlohmann
::
json
;
#undef private
namespace
{
// special test case to check if memory is leaked if constructor throws
template
<
class
T
>
struct
bad_allocator
:
std
::
allocator
<
T
>
{
...
...
@@ -45,6 +46,7 @@ struct bad_allocator : std::allocator<T>
throw
std
::
bad_alloc
();
}
};
}
TEST_CASE
(
"bad_alloc"
)
{
...
...
@@ -65,6 +67,8 @@ TEST_CASE("bad_alloc")
}
}
namespace
{
static
bool
next_construct_fails
=
false
;
static
bool
next_destroy_fails
=
false
;
static
bool
next_deallocate_fails
=
false
;
...
...
@@ -130,6 +134,7 @@ void my_allocator_clean_up(T* p)
alloc
.
destroy
(
p
);
alloc
.
deallocate
(
p
,
1
);
}
}
TEST_CASE
(
"controlled bad_alloc"
)
{
...
...
test/src/unit-alt-string.cpp
View file @
f05614b2
...
...
@@ -39,7 +39,6 @@ SOFTWARE.
class
alt_string
;
bool
operator
<
(
const
char
*
op1
,
const
alt_string
&
op2
);
/*
* This is virtually a string class.
* It covers std::string under the hood.
...
...
@@ -155,7 +154,6 @@ class alt_string
friend
bool
::
operator
<
(
const
char
*
,
const
alt_string
&
);
};
using
alt_json
=
nlohmann
::
basic_json
<
std
::
map
,
std
::
vector
,
...
...
@@ -173,8 +171,6 @@ bool operator<(const char* op1, const alt_string& op2)
return
op1
<
op2
.
str_impl
;
}
TEST_CASE
(
"alternative string type"
)
{
SECTION
(
"dump"
)
...
...
test/src/unit-bson.cpp
View file @
f05614b2
...
...
@@ -608,6 +608,8 @@ TEST_CASE("BSON input/output_adapters")
}
}
namespace
{
class
SaxCountdown
{
public:
...
...
@@ -677,6 +679,7 @@ class SaxCountdown
private:
int
events_left
=
0
;
};
}
TEST_CASE
(
"Incomplete BSON Input"
)
{
...
...
test/src/unit-cbor.cpp
View file @
f05614b2
...
...
@@ -38,6 +38,8 @@ using nlohmann::json;
#include <iomanip>
#include <set>
namespace
{
class
SaxCountdown
{
public:
...
...
@@ -107,6 +109,7 @@ class SaxCountdown
private:
int
events_left
=
0
;
};
}
TEST_CASE
(
"CBOR"
)
{
...
...
test/src/unit-class_lexer.cpp
View file @
f05614b2
...
...
@@ -34,12 +34,15 @@ SOFTWARE.
using
nlohmann
::
json
;
#undef private
namespace
{
// shortcut to scan a string literal
json
::
lexer
::
token_type
scan_string
(
const
char
*
s
);
json
::
lexer
::
token_type
scan_string
(
const
char
*
s
)
{
return
json
::
lexer
(
nlohmann
::
detail
::
input_adapter
(
s
)).
scan
();
}
}
TEST_CASE
(
"lexer class"
)
{
...
...
test/src/unit-class_parser.cpp
View file @
f05614b2
...
...
@@ -36,6 +36,8 @@ using nlohmann::json;
#include <valarray>
namespace
{
class
SaxEventLogger
{
public:
...
...
@@ -256,6 +258,7 @@ bool accept_helper(const std::string& s)
// 7. return result
return
ok_accept
;
}
}
TEST_CASE
(
"parser class"
)
{
...
...
test/src/unit-comparison.cpp
View file @
f05614b2
...
...
@@ -32,6 +32,8 @@ SOFTWARE.
#include <nlohmann/json.hpp>
using
nlohmann
::
json
;
namespace
{
// helper function to check std::less<json::value_t>
// see https://en.cppreference.com/w/cpp/utility/functional/less
template
<
typename
A
,
typename
B
,
typename
U
=
std
::
less
<
json
::
value_t
>
>
...
...
@@ -39,6 +41,7 @@ bool f(A a, B b, U u = U())
{
return
u
(
a
,
b
);
}
}
TEST_CASE
(
"lexicographical comparison operators"
)
{
...
...
test/src/unit-convenience.cpp
View file @
f05614b2
...
...
@@ -36,6 +36,8 @@ using nlohmann::json;
#include <sstream>
namespace
{
void
check_escaped
(
const
char
*
original
,
const
char
*
escaped
=
""
,
const
bool
ensure_ascii
=
false
);
void
check_escaped
(
const
char
*
original
,
const
char
*
escaped
,
const
bool
ensure_ascii
)
{
...
...
@@ -44,6 +46,7 @@ void check_escaped(const char* original, const char* escaped, const bool ensure_
s
.
dump_escaped
(
original
,
ensure_ascii
);
CHECK
(
ss
.
str
()
==
escaped
);
}
}
TEST_CASE
(
"convenience functions"
)
{
...
...
test/src/unit-deserialization.cpp
View file @
f05614b2
...
...
@@ -36,6 +36,8 @@ using nlohmann::json;
#include <sstream>
#include <valarray>
namespace
{
struct
SaxEventLogger
:
public
nlohmann
::
json_sax
<
json
>
{
bool
null
()
override
...
...
@@ -167,6 +169,7 @@ struct SaxEventLoggerExitAfterStartArray : public SaxEventLogger
return
false
;
}
};
}
TEST_CASE
(
"deserialization"
)
{
...
...
test/src/unit-msgpack.cpp
View file @
f05614b2
...
...
@@ -37,6 +37,8 @@ using nlohmann::json;
#include <iomanip>
#include <set>
namespace
{
class
SaxCountdown
{
public:
...
...
@@ -106,6 +108,7 @@ class SaxCountdown
private:
int
events_left
=
0
;
};
}
TEST_CASE
(
"MessagePack"
)
{
...
...
@@ -1300,7 +1303,6 @@ TEST_CASE("MessagePack")
}
}
// use this testcase outside [hide] to run it with Valgrind
TEST_CASE
(
"single MessagePack roundtrip"
)
{
...
...
@@ -1347,7 +1349,6 @@ TEST_CASE("single MessagePack roundtrip")
}
}
TEST_CASE
(
"MessagePack roundtrips"
*
doctest
::
skip
())
{
SECTION
(
"input from msgpack-python"
)
...
...
test/src/unit-noexcept.cpp
View file @
f05614b2
...
...
@@ -33,6 +33,8 @@ SOFTWARE.
using
nlohmann
::
json
;
namespace
{
enum
test
{
};
...
...
@@ -59,6 +61,7 @@ static_assert(noexcept(json(pod{})), "");
static_assert
(
noexcept
(
j
.
get
<
pod
>
()),
""
);
static_assert
(
not
noexcept
(
j
.
get
<
pod_bis
>
()),
""
);
static_assert
(
noexcept
(
json
(
pod
{})),
""
);
}
TEST_CASE
(
"runtime checks"
)
{
...
...
test/src/unit-testsuites.cpp
View file @
f05614b2
...
...
@@ -418,7 +418,6 @@ TEST_CASE("json.org examples")
json
j
;
CHECK_NOTHROW
(
j
.
parse
(
f
.
get
()));
}
}
TEST_CASE
(
"RFC 7159 examples"
)
...
...
@@ -1352,6 +1351,8 @@ TEST_CASE("nst's JSONTestSuite (2)")
}
}
namespace
{
std
::
string
trim
(
const
std
::
string
&
str
);
// from http://stackoverflow.com/a/25829178/266378
...
...
@@ -1365,6 +1366,7 @@ std::string trim(const std::string& str)
size_t
last
=
str
.
find_last_not_of
(
' '
);
return
str
.
substr
(
first
,
(
last
-
first
+
1
));
}
}
TEST_CASE
(
"Big List of Naughty Strings"
)
{
...
...
test/src/unit-to_chars.cpp
View file @
f05614b2
...
...
@@ -36,6 +36,8 @@ SOFTWARE.
#include <nlohmann/json.hpp>
using
nlohmann
::
detail
::
dtoa_impl
::
reinterpret_bits
;
namespace
{
static
float
make_float
(
uint32_t
sign_bit
,
uint32_t
biased_exponent
,
uint32_t
significand
)
{
assert
(
sign_bit
==
0
||
sign_bit
==
1
);
...
...
@@ -139,6 +141,7 @@ static double make_double(uint64_t f, int e)
uint64_t
bits
=
(
f
&
kSignificandMask
)
|
(
biased_exponent
<<
kPhysicalSignificandSize
);
return
reinterpret_bits
<
double
>
(
bits
);
}
}
TEST_CASE
(
"digit gen"
)
{
...
...
test/src/unit-ubjson.cpp
View file @
f05614b2
...
...
@@ -35,6 +35,8 @@ using nlohmann::json;
#include <fstream>
#include <set>
namespace
{
class
SaxCountdown
{
public:
...
...
@@ -104,6 +106,7 @@ class SaxCountdown
private:
int
events_left
=
0
;
};
}
TEST_CASE
(
"UBJSON"
)
{
...
...
test/src/unit-unicode.cpp
View file @
f05614b2
...
...
@@ -42,6 +42,8 @@ using nlohmann::json;
#include <iostream>
#include <iomanip>
namespace
{
extern
size_t
calls
;
size_t
calls
=
0
;
...
...
@@ -165,6 +167,7 @@ void check_utf8string(bool success_expected, int byte1, int byte2 = -1, int byte
CHECK_THROWS_AS
(
json
::
parse
(
json_string
),
json
::
parse_error
&
);
}
}
}
TEST_CASE
(
"Unicode"
*
doctest
::
skip
())
{
...
...
@@ -1205,6 +1208,8 @@ TEST_CASE("Unicode" * doctest::skip())
}
}
namespace
{
void
roundtrip
(
bool
success_expected
,
const
std
::
string
&
s
);
void
roundtrip
(
bool
success_expected
,
const
std
::
string
&
s
)
...
...
@@ -1244,6 +1249,7 @@ void roundtrip(bool success_expected, const std::string& s)
CHECK_THROWS_AS
(
json
::
parse
(
ps
),
json
::
parse_error
&
);
}
}
}
TEST_CASE
(
"Markus Kuhn's UTF-8 decoder capability and stress test"
)
{
...
...
test/src/unit-wstring.cpp
View file @
f05614b2
...
...
@@ -32,6 +32,8 @@ SOFTWARE.
#include <nlohmann/json.hpp>
using
nlohmann
::
json
;
namespace
{
bool
wstring_is_utf16
();
bool
wstring_is_utf16
()
{
...
...
@@ -49,6 +51,7 @@ bool u32string_is_utf32()
{
return
(
std
::
u32string
(
U"💩"
)
==
std
::
u32string
(
U"\U0001F4A9"
));
}
}
TEST_CASE
(
"wide strings"
)
{
...
...
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