Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
R
rapidjson
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
rapidjson
Commits
4f20bdcf
Commit
4f20bdcf
authored
Jan 23, 2016
by
Milo Yip
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #515 from miloyip/cxx11warnings
Fix C++11 warnings and make travis to compile with/without C++11
parents
968a666a
40311501
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
157 additions
and
15 deletions
+157
-15
.travis.yml
.travis.yml
+7
-4
CMakeLists.txt
CMakeLists.txt
+12
-0
serialize.cpp
example/serialize/serialize.cpp
+16
-0
document.h
include/rapidjson/document.h
+2
-2
stack.h
include/rapidjson/internal/stack.h
+9
-0
swap.h
include/rapidjson/internal/swap.h
+9
-0
stringbuffer.h
include/rapidjson/stringbuffer.h
+9
-0
documenttest.cpp
test/unittest/documenttest.cpp
+14
-0
readertest.cpp
test/unittest/readertest.cpp
+1
-0
stringbuffertest.cpp
test/unittest/stringbuffertest.cpp
+13
-0
unittest.cpp
test/unittest/unittest.cpp
+11
-0
unittest.h
test/unittest/unittest.h
+12
-0
valuetest.cpp
test/unittest/valuetest.cpp
+42
-9
No files found.
.travis.yml
View file @
4f20bdcf
...
@@ -6,10 +6,12 @@ compiler:
...
@@ -6,10 +6,12 @@ compiler:
env
:
env
:
matrix
:
matrix
:
-
CONF=debug ARCH=x86_64
-
CONF=debug ARCH=x86_64 CXX11=ON
-
CONF=release ARCH=x86_64
-
CONF=release ARCH=x86_64 CXX11=ON
-
CONF=debug ARCH=x86
-
CONF=debug ARCH=x86 CXX11=ON
-
CONF=release ARCH=x86
-
CONF=release ARCH=x86 CXX11=ON
-
CONF=debug ARCH=x86_64 CXX11=OFF
-
CONF=debug ARCH=x86 CXX11=OFF
global
:
global
:
-
ARCH_FLAGS_x86='-m32'
# #266: don't use SSE on 32-bit
-
ARCH_FLAGS_x86='-m32'
# #266: don't use SSE on 32-bit
-
ARCH_FLAGS_x86_64='-msse4.2'
# use SSE4.2 on 64-bit
-
ARCH_FLAGS_x86_64='-msse4.2'
# use SSE4.2 on 64-bit
...
@@ -34,6 +36,7 @@ before_script:
...
@@ -34,6 +36,7 @@ before_script:
eval "ARCH_FLAGS=\${ARCH_FLAGS_${ARCH}}" ;
eval "ARCH_FLAGS=\${ARCH_FLAGS_${ARCH}}" ;
(cd build && cmake
(cd build && cmake
-DRAPIDJSON_HAS_STDSTRING=ON
-DRAPIDJSON_HAS_STDSTRING=ON
-DRAPIDJSON_BUILD_CXX11=$CXX11
-DCMAKE_VERBOSE_MAKEFILE=ON
-DCMAKE_VERBOSE_MAKEFILE=ON
-DCMAKE_BUILD_TYPE=$CONF
-DCMAKE_BUILD_TYPE=$CONF
-DCMAKE_CXX_FLAGS="$ARCH_FLAGS $GCOV_FLAGS"
-DCMAKE_CXX_FLAGS="$ARCH_FLAGS $GCOV_FLAGS"
...
...
CMakeLists.txt
View file @
4f20bdcf
...
@@ -20,6 +20,8 @@ option(RAPIDJSON_BUILD_TESTS "Build rapidjson perftests and unittests." ON)
...
@@ -20,6 +20,8 @@ option(RAPIDJSON_BUILD_TESTS "Build rapidjson perftests and unittests." ON)
option
(
RAPIDJSON_BUILD_THIRDPARTY_GTEST
option
(
RAPIDJSON_BUILD_THIRDPARTY_GTEST
"Use gtest installation in `thirdparty/gtest` by default if available"
OFF
)
"Use gtest installation in `thirdparty/gtest` by default if available"
OFF
)
option
(
RAPIDJSON_BUILD_CXX11
"Build rapidjson with C++11 (gcc/clang)"
ON
)
option
(
RAPIDJSON_HAS_STDSTRING
""
OFF
)
option
(
RAPIDJSON_HAS_STDSTRING
""
OFF
)
if
(
RAPIDJSON_HAS_STDSTRING
)
if
(
RAPIDJSON_HAS_STDSTRING
)
add_definitions
(
-DRAPIDJSON_HAS_STDSTRING
)
add_definitions
(
-DRAPIDJSON_HAS_STDSTRING
)
...
@@ -27,8 +29,18 @@ endif()
...
@@ -27,8 +29,18 @@ endif()
if
(
"
${
CMAKE_CXX_COMPILER_ID
}
"
STREQUAL
"GNU"
)
if
(
"
${
CMAKE_CXX_COMPILER_ID
}
"
STREQUAL
"GNU"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-march=native -Wall -Wextra -Werror"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-march=native -Wall -Wextra -Werror"
)
if
(
RAPIDJSON_BUILD_CXX11
)
if
(
CMAKE_CXX_COMPILER_VERSION VERSION_LESS
"4.7.0"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=c++0x"
)
else
()
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=c++11"
)
endif
()
endif
()
elseif
(
CMAKE_CXX_COMPILER_ID MATCHES
"Clang"
)
elseif
(
CMAKE_CXX_COMPILER_ID MATCHES
"Clang"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-march=native -Wall -Wextra -Werror -Wno-missing-field-initializers"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-march=native -Wall -Wextra -Werror -Wno-missing-field-initializers"
)
if
(
RAPIDJSON_BUILD_CXX11
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=c++11"
)
endif
()
elseif
(
"
${
CMAKE_CXX_COMPILER_ID
}
"
STREQUAL
"MSVC"
)
elseif
(
"
${
CMAKE_CXX_COMPILER_ID
}
"
STREQUAL
"MSVC"
)
add_definitions
(
-D_CRT_SECURE_NO_WARNINGS=1
)
add_definitions
(
-D_CRT_SECURE_NO_WARNINGS=1
)
endif
()
endif
()
...
...
example/serialize/serialize.cpp
View file @
4f20bdcf
...
@@ -11,8 +11,15 @@ using namespace rapidjson;
...
@@ -11,8 +11,15 @@ using namespace rapidjson;
class
Person
{
class
Person
{
public
:
public
:
Person
(
const
std
::
string
&
name
,
unsigned
age
)
:
name_
(
name
),
age_
(
age
)
{}
Person
(
const
std
::
string
&
name
,
unsigned
age
)
:
name_
(
name
),
age_
(
age
)
{}
Person
(
const
Person
&
rhs
)
:
name_
(
rhs
.
name_
),
age_
(
rhs
.
age_
)
{}
virtual
~
Person
();
virtual
~
Person
();
Person
&
operator
=
(
const
Person
&
rhs
)
{
name_
=
rhs
.
name_
;
age_
=
rhs
.
age_
;
return
*
this
;
}
protected
:
protected
:
template
<
typename
Writer
>
template
<
typename
Writer
>
void
Serialize
(
Writer
&
writer
)
const
{
void
Serialize
(
Writer
&
writer
)
const
{
...
@@ -38,6 +45,7 @@ Person::~Person() {
...
@@ -38,6 +45,7 @@ Person::~Person() {
class
Education
{
class
Education
{
public
:
public
:
Education
(
const
std
::
string
&
school
,
double
GPA
)
:
school_
(
school
),
GPA_
(
GPA
)
{}
Education
(
const
std
::
string
&
school
,
double
GPA
)
:
school_
(
school
),
GPA_
(
GPA
)
{}
Education
(
const
Education
&
rhs
)
:
school_
(
rhs
.
school_
),
GPA_
(
rhs
.
GPA_
)
{}
template
<
typename
Writer
>
template
<
typename
Writer
>
void
Serialize
(
Writer
&
writer
)
const
{
void
Serialize
(
Writer
&
writer
)
const
{
...
@@ -102,8 +110,16 @@ Dependent::~Dependent() {
...
@@ -102,8 +110,16 @@ Dependent::~Dependent() {
class
Employee
:
public
Person
{
class
Employee
:
public
Person
{
public
:
public
:
Employee
(
const
std
::
string
&
name
,
unsigned
age
,
bool
married
)
:
Person
(
name
,
age
),
dependents_
(),
married_
(
married
)
{}
Employee
(
const
std
::
string
&
name
,
unsigned
age
,
bool
married
)
:
Person
(
name
,
age
),
dependents_
(),
married_
(
married
)
{}
Employee
(
const
Employee
&
rhs
)
:
Person
(
rhs
),
dependents_
(
rhs
.
dependents_
),
married_
(
rhs
.
married_
)
{}
virtual
~
Employee
();
virtual
~
Employee
();
Employee
&
operator
=
(
const
Employee
&
rhs
)
{
static_cast
<
Person
&>
(
*
this
)
=
rhs
;
dependents_
=
rhs
.
dependents_
;
married_
=
rhs
.
married_
;
return
*
this
;
}
void
AddDependent
(
const
Dependent
&
dependent
)
{
void
AddDependent
(
const
Dependent
&
dependent
)
{
dependents_
.
push_back
(
dependent
);
dependents_
.
push_back
(
dependent
);
}
}
...
...
include/rapidjson/document.h
View file @
4f20bdcf
...
@@ -31,6 +31,7 @@ RAPIDJSON_DIAG_OFF(4127) // conditional expression is constant
...
@@ -31,6 +31,7 @@ RAPIDJSON_DIAG_OFF(4127) // conditional expression is constant
RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF
(
padded
)
RAPIDJSON_DIAG_OFF
(
padded
)
RAPIDJSON_DIAG_OFF
(
switch
-
enum
)
RAPIDJSON_DIAG_OFF
(
switch
-
enum
)
RAPIDJSON_DIAG_OFF
(
c
++
98
-
compat
)
#endif
#endif
#ifdef __GNUC__
#ifdef __GNUC__
...
@@ -141,6 +142,7 @@ public:
...
@@ -141,6 +142,7 @@ public:
Otherwise, the copy constructor is implicitly defined.
Otherwise, the copy constructor is implicitly defined.
*/
*/
GenericMemberIterator
(
const
NonConstIterator
&
it
)
:
ptr_
(
it
.
ptr_
)
{}
GenericMemberIterator
(
const
NonConstIterator
&
it
)
:
ptr_
(
it
.
ptr_
)
{}
Iterator
&
operator
=
(
const
NonConstIterator
&
it
)
{
ptr_
=
it
.
ptr_
;
return
*
this
;
}
//! @name stepping
//! @name stepping
//@{
//@{
...
@@ -314,8 +316,6 @@ struct GenericStringRef {
...
@@ -314,8 +316,6 @@ struct GenericStringRef {
const
SizeType
length
;
//!< length of the string (excluding the trailing NULL terminator)
const
SizeType
length
;
//!< length of the string (excluding the trailing NULL terminator)
private
:
private
:
//! Disallow copy-assignment
GenericStringRef
operator
=
(
const
GenericStringRef
&
);
//! Disallow construction from non-const array
//! Disallow construction from non-const array
template
<
SizeType
N
>
template
<
SizeType
N
>
GenericStringRef
(
CharType
(
&
str
)[
N
])
/* = delete */
;
GenericStringRef
(
CharType
(
&
str
)[
N
])
/* = delete */
;
...
...
include/rapidjson/internal/stack.h
View file @
4f20bdcf
...
@@ -18,6 +18,11 @@
...
@@ -18,6 +18,11 @@
#include "../rapidjson.h"
#include "../rapidjson.h"
#include "swap.h"
#include "swap.h"
#if defined(__clang__)
RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF
(
c
++
98
-
compat
)
#endif
RAPIDJSON_NAMESPACE_BEGIN
RAPIDJSON_NAMESPACE_BEGIN
namespace
internal
{
namespace
internal
{
...
@@ -203,4 +208,8 @@ private:
...
@@ -203,4 +208,8 @@ private:
}
// namespace internal
}
// namespace internal
RAPIDJSON_NAMESPACE_END
RAPIDJSON_NAMESPACE_END
#if defined(__clang__)
RAPIDJSON_DIAG_POP
#endif
#endif // RAPIDJSON_STACK_H_
#endif // RAPIDJSON_STACK_H_
include/rapidjson/internal/swap.h
View file @
4f20bdcf
...
@@ -17,6 +17,11 @@
...
@@ -17,6 +17,11 @@
#include "../rapidjson.h"
#include "../rapidjson.h"
#if defined(__clang__)
RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF
(
c
++
98
-
compat
)
#endif
RAPIDJSON_NAMESPACE_BEGIN
RAPIDJSON_NAMESPACE_BEGIN
namespace
internal
{
namespace
internal
{
...
@@ -34,4 +39,8 @@ inline void Swap(T& a, T& b) RAPIDJSON_NOEXCEPT {
...
@@ -34,4 +39,8 @@ inline void Swap(T& a, T& b) RAPIDJSON_NOEXCEPT {
}
// namespace internal
}
// namespace internal
RAPIDJSON_NAMESPACE_END
RAPIDJSON_NAMESPACE_END
#if defined(__clang__)
RAPIDJSON_DIAG_POP
#endif
#endif // RAPIDJSON_INTERNAL_SWAP_H_
#endif // RAPIDJSON_INTERNAL_SWAP_H_
include/rapidjson/stringbuffer.h
View file @
4f20bdcf
...
@@ -23,6 +23,11 @@
...
@@ -23,6 +23,11 @@
#include "internal/stack.h"
#include "internal/stack.h"
#if defined(__clang__)
RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF
(
c
++
98
-
compat
)
#endif
RAPIDJSON_NAMESPACE_BEGIN
RAPIDJSON_NAMESPACE_BEGIN
//! Represents an in-memory output stream.
//! Represents an in-memory output stream.
...
@@ -103,4 +108,8 @@ inline void PutN(GenericStringBuffer<UTF8<> >& stream, char c, size_t n) {
...
@@ -103,4 +108,8 @@ inline void PutN(GenericStringBuffer<UTF8<> >& stream, char c, size_t n) {
RAPIDJSON_NAMESPACE_END
RAPIDJSON_NAMESPACE_END
#if defined(__clang__)
RAPIDJSON_DIAG_POP
#endif
#endif // RAPIDJSON_STRINGBUFFER_H_
#endif // RAPIDJSON_STRINGBUFFER_H_
test/unittest/documenttest.cpp
View file @
4f20bdcf
...
@@ -21,6 +21,12 @@
...
@@ -21,6 +21,12 @@
#include <sstream>
#include <sstream>
#include <algorithm>
#include <algorithm>
#ifdef __clang__
RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF
(
c
++
98
-
compat
)
RAPIDJSON_DIAG_OFF
(
missing
-
variable
-
declarations
)
#endif
using
namespace
rapidjson
;
using
namespace
rapidjson
;
template
<
typename
DocumentType
>
template
<
typename
DocumentType
>
...
@@ -328,6 +334,8 @@ TEST(Document, UTF16_Document) {
...
@@ -328,6 +334,8 @@ TEST(Document, UTF16_Document) {
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
#if 0 // Many old compiler does not support these. Turn it off temporaily.
#include <type_traits>
#include <type_traits>
TEST(Document, Traits) {
TEST(Document, Traits) {
...
@@ -365,6 +373,8 @@ TEST(Document, Traits) {
...
@@ -365,6 +373,8 @@ TEST(Document, Traits) {
#endif
#endif
}
}
#endif
template
<
typename
Allocator
>
template
<
typename
Allocator
>
struct
DocumentMove
:
public
::
testing
::
Test
{
struct
DocumentMove
:
public
::
testing
::
Test
{
};
};
...
@@ -573,3 +583,7 @@ TYPED_TEST(DocumentMove, MoveAssignmentStack) {
...
@@ -573,3 +583,7 @@ TYPED_TEST(DocumentMove, MoveAssignmentStack) {
// Document d2;
// Document d2;
// d1 = d2;
// d1 = d2;
//}
//}
#ifdef __clang__
RAPIDJSON_DIAG_POP
#endif
test/unittest/readertest.cpp
View file @
4f20bdcf
...
@@ -31,6 +31,7 @@ RAPIDJSON_DIAG_OFF(missing-noreturn)
...
@@ -31,6 +31,7 @@ RAPIDJSON_DIAG_OFF(missing-noreturn)
#ifdef __clang__
#ifdef __clang__
RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF
(
variadic
-
macros
)
RAPIDJSON_DIAG_OFF
(
variadic
-
macros
)
RAPIDJSON_DIAG_OFF
(
c
++
98
-
compat
-
pedantic
)
#endif
#endif
template
<
bool
expect
>
template
<
bool
expect
>
...
...
test/unittest/stringbuffertest.cpp
View file @
4f20bdcf
...
@@ -16,6 +16,11 @@
...
@@ -16,6 +16,11 @@
#include "rapidjson/stringbuffer.h"
#include "rapidjson/stringbuffer.h"
#include "rapidjson/writer.h"
#include "rapidjson/writer.h"
#ifdef __clang__
RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF
(
c
++
98
-
compat
)
#endif
using
namespace
rapidjson
;
using
namespace
rapidjson
;
TEST
(
StringBuffer
,
InitialSize
)
{
TEST
(
StringBuffer
,
InitialSize
)
{
...
@@ -69,6 +74,8 @@ TEST(StringBuffer, Pop) {
...
@@ -69,6 +74,8 @@ TEST(StringBuffer, Pop) {
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
#if 0 // Many old compiler does not support these. Turn it off temporaily.
#include <type_traits>
#include <type_traits>
TEST(StringBuffer, Traits) {
TEST(StringBuffer, Traits) {
...
@@ -106,6 +113,8 @@ TEST(StringBuffer, Traits) {
...
@@ -106,6 +113,8 @@ TEST(StringBuffer, Traits) {
#endif
#endif
}
}
#endif
TEST
(
StringBuffer
,
MoveConstructor
)
{
TEST
(
StringBuffer
,
MoveConstructor
)
{
StringBuffer
x
;
StringBuffer
x
;
x
.
Put
(
'A'
);
x
.
Put
(
'A'
);
...
@@ -148,3 +157,7 @@ TEST(StringBuffer, MoveAssignment) {
...
@@ -148,3 +157,7 @@ TEST(StringBuffer, MoveAssignment) {
}
}
#endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS
#endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS
#ifdef __clang__
RAPIDJSON_DIAG_POP
#endif
test/unittest/unittest.cpp
View file @
4f20bdcf
...
@@ -15,8 +15,19 @@
...
@@ -15,8 +15,19 @@
#include "unittest.h"
#include "unittest.h"
#include "rapidjson/rapidjson.h"
#include "rapidjson/rapidjson.h"
#ifdef __clang__
#pragma GCC diagnostic push
#if __has_warning("-Wdeprecated")
#pragma GCC diagnostic ignored "-Wdeprecated"
#endif
#endif
AssertException
::~
AssertException
()
throw
()
{}
AssertException
::~
AssertException
()
throw
()
{}
#ifdef __clang__
#pragma GCC diagnostic pop
#endif
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
::
testing
::
InitGoogleTest
(
&
argc
,
argv
);
::
testing
::
InitGoogleTest
(
&
argc
,
argv
);
...
...
test/unittest/unittest.h
View file @
4f20bdcf
...
@@ -99,12 +99,24 @@ inline FILE* TempFile(char *filename) {
...
@@ -99,12 +99,24 @@ inline FILE* TempFile(char *filename) {
#pragma warning(disable : 4127)
#pragma warning(disable : 4127)
#endif
#endif
#ifdef __clang__
#pragma GCC diagnostic push
#if __has_warning("-Wdeprecated")
#pragma GCC diagnostic ignored "-Wdeprecated"
#endif
#endif
class
AssertException
:
public
std
::
logic_error
{
class
AssertException
:
public
std
::
logic_error
{
public
:
public
:
AssertException
(
const
char
*
w
)
:
std
::
logic_error
(
w
)
{}
AssertException
(
const
char
*
w
)
:
std
::
logic_error
(
w
)
{}
AssertException
(
const
AssertException
&
rhs
)
:
std
::
logic_error
(
rhs
)
{}
virtual
~
AssertException
()
throw
();
virtual
~
AssertException
()
throw
();
};
};
#ifdef __clang__
#pragma GCC diagnostic pop
#endif
#define RAPIDJSON_ASSERT(x) if (!(x)) throw AssertException(RAPIDJSON_STRINGIFY(x))
#define RAPIDJSON_ASSERT(x) if (!(x)) throw AssertException(RAPIDJSON_STRINGIFY(x))
class
Random
{
class
Random
{
...
...
test/unittest/valuetest.cpp
View file @
4f20bdcf
...
@@ -16,6 +16,11 @@
...
@@ -16,6 +16,11 @@
#include "rapidjson/document.h"
#include "rapidjson/document.h"
#include <algorithm>
#include <algorithm>
#ifdef __clang__
RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF
(
c
++
98
-
compat
)
#endif
using
namespace
rapidjson
;
using
namespace
rapidjson
;
TEST
(
Value
,
DefaultConstructor
)
{
TEST
(
Value
,
DefaultConstructor
)
{
...
@@ -34,6 +39,8 @@ TEST(Value, DefaultConstructor) {
...
@@ -34,6 +39,8 @@ TEST(Value, DefaultConstructor) {
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
#if 0 // Many old compiler does not support these. Turn it off temporaily.
#include <type_traits>
#include <type_traits>
TEST(Value, Traits) {
TEST(Value, Traits) {
...
@@ -72,6 +79,8 @@ TEST(Value, Traits) {
...
@@ -72,6 +79,8 @@ TEST(Value, Traits) {
#endif
#endif
}
}
#endif
TEST
(
Value
,
MoveConstructor
)
{
TEST
(
Value
,
MoveConstructor
)
{
typedef
GenericValue
<
UTF8
<>
,
CrtAllocator
>
Value
;
typedef
GenericValue
<
UTF8
<>
,
CrtAllocator
>
Value
;
Value
::
AllocatorType
allocator
;
Value
::
AllocatorType
allocator
;
...
@@ -764,15 +773,15 @@ TEST(Value, Array) {
...
@@ -764,15 +773,15 @@ TEST(Value, Array) {
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
// PushBack(GenericValue&&, Allocator&);
// PushBack(GenericValue&&, Allocator&);
{
{
Value
y
(
kArrayType
);
Value
y
2
(
kArrayType
);
y
.
PushBack
(
Value
(
true
),
allocator
);
y
2
.
PushBack
(
Value
(
true
),
allocator
);
y
.
PushBack
(
std
::
move
(
Value
(
kArrayType
).
PushBack
(
Value
(
1
),
allocator
).
PushBack
(
"foo"
,
allocator
)),
allocator
);
y
2
.
PushBack
(
std
::
move
(
Value
(
kArrayType
).
PushBack
(
Value
(
1
),
allocator
).
PushBack
(
"foo"
,
allocator
)),
allocator
);
EXPECT_EQ
(
2u
,
y
.
Size
());
EXPECT_EQ
(
2u
,
y
2
.
Size
());
EXPECT_TRUE
(
y
[
0
].
IsTrue
());
EXPECT_TRUE
(
y
2
[
0
].
IsTrue
());
EXPECT_TRUE
(
y
[
1
].
IsArray
());
EXPECT_TRUE
(
y
2
[
1
].
IsArray
());
EXPECT_EQ
(
2u
,
y
[
1
].
Size
());
EXPECT_EQ
(
2u
,
y
2
[
1
].
Size
());
EXPECT_TRUE
(
y
[
1
][
0
].
IsInt
());
EXPECT_TRUE
(
y
2
[
1
][
0
].
IsInt
());
EXPECT_TRUE
(
y
[
1
][
1
].
IsString
());
EXPECT_TRUE
(
y
2
[
1
][
1
].
IsString
());
}
}
#endif
#endif
...
@@ -1354,3 +1363,27 @@ TEST(Value, AcceptTerminationByHandler) {
...
@@ -1354,3 +1363,27 @@ TEST(Value, AcceptTerminationByHandler) {
TEST_TERMINATION
(
11
,
"{
\"
a
\"
:[]}"
);
TEST_TERMINATION
(
11
,
"{
\"
a
\"
:[]}"
);
TEST_TERMINATION
(
12
,
"{
\"
a
\"
:[]}"
);
TEST_TERMINATION
(
12
,
"{
\"
a
\"
:[]}"
);
}
}
struct
ValueIntComparer
{
bool
operator
()(
const
Value
&
lhs
,
const
Value
&
rhs
)
const
{
return
lhs
.
GetInt
()
<
rhs
.
GetInt
();
}
};
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
TEST
(
Value
,
Sorting
)
{
Value
::
AllocatorType
allocator
;
Value
a
(
kArrayType
);
a
.
PushBack
(
5
,
allocator
);
a
.
PushBack
(
1
,
allocator
);
a
.
PushBack
(
3
,
allocator
);
std
::
sort
(
a
.
Begin
(),
a
.
End
(),
ValueIntComparer
());
EXPECT_EQ
(
1
,
a
[
0
].
GetInt
());
EXPECT_EQ
(
3
,
a
[
1
].
GetInt
());
EXPECT_EQ
(
5
,
a
[
2
].
GetInt
());
}
#endif
#ifdef __clang__
RAPIDJSON_DIAG_POP
#endif
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