Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/miloyip/rapidjson.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilo Yip <miloyip@gmail.com>2018-01-26 05:59:11 +0300
committerGitHub <noreply@github.com>2018-01-26 05:59:11 +0300
commit7641af690eb1996a15143b53fd675be6c3e11078 (patch)
tree8b642de7f5a7ebefb080d8393c939fb70bdbf34b
parentcdc899a3f3b918bcdcdc262ac4c4861e63d1a822 (diff)
parent44f2f9aa536d8cced21f4e9c58f7d9d98bd88a71 (diff)
Merge pull request #1122 from svart-riddare/issue-1108
Suggestion for issue #1108
-rw-r--r--include/rapidjson/pointer.h7
-rw-r--r--test/unittest/pointertest.cpp9
2 files changed, 13 insertions, 3 deletions
diff --git a/include/rapidjson/pointer.h b/include/rapidjson/pointer.h
index 0f377efe..217e71ce 100644
--- a/include/rapidjson/pointer.h
+++ b/include/rapidjson/pointer.h
@@ -165,7 +165,12 @@ public:
GenericPointer(const Token* tokens, size_t tokenCount) : allocator_(), ownAllocator_(), nameBuffer_(), tokens_(const_cast<Token*>(tokens)), tokenCount_(tokenCount), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) {}
//! Copy constructor.
- GenericPointer(const GenericPointer& rhs, Allocator* allocator = 0) : allocator_(allocator), ownAllocator_(), nameBuffer_(), tokens_(), tokenCount_(), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) {
+ GenericPointer(const GenericPointer& rhs) : allocator_(rhs.allocator_), ownAllocator_(), nameBuffer_(), tokens_(), tokenCount_(), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) {
+ *this = rhs;
+ }
+
+ //! Copy constructor.
+ GenericPointer(const GenericPointer& rhs, Allocator* allocator) : allocator_(allocator), ownAllocator_(), nameBuffer_(), tokens_(), tokenCount_(), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) {
*this = rhs;
}
diff --git a/test/unittest/pointertest.cpp b/test/unittest/pointertest.cpp
index d5a688db..855d822c 100644
--- a/test/unittest/pointertest.cpp
+++ b/test/unittest/pointertest.cpp
@@ -462,7 +462,8 @@ TEST(Pointer, ConstructorWithToken) {
TEST(Pointer, CopyConstructor) {
{
- Pointer p("/foo/0");
+ CrtAllocator allocator;
+ Pointer p("/foo/0", &allocator);
Pointer q(p);
EXPECT_TRUE(q.IsValid());
EXPECT_EQ(2u, q.GetTokenCount());
@@ -471,6 +472,7 @@ TEST(Pointer, CopyConstructor) {
EXPECT_EQ(1u, q.GetTokens()[1].length);
EXPECT_STREQ("0", q.GetTokens()[1].name);
EXPECT_EQ(0u, q.GetTokens()[1].index);
+ EXPECT_EQ(&p.GetAllocator(), &q.GetAllocator());
}
// Static tokens
@@ -489,7 +491,8 @@ TEST(Pointer, CopyConstructor) {
TEST(Pointer, Assignment) {
{
- Pointer p("/foo/0");
+ CrtAllocator allocator;
+ Pointer p("/foo/0", &allocator);
Pointer q;
q = p;
EXPECT_TRUE(q.IsValid());
@@ -499,6 +502,7 @@ TEST(Pointer, Assignment) {
EXPECT_EQ(1u, q.GetTokens()[1].length);
EXPECT_STREQ("0", q.GetTokens()[1].name);
EXPECT_EQ(0u, q.GetTokens()[1].index);
+ EXPECT_NE(&p.GetAllocator(), &q.GetAllocator());
q = q;
EXPECT_TRUE(q.IsValid());
EXPECT_EQ(2u, q.GetTokenCount());
@@ -507,6 +511,7 @@ TEST(Pointer, Assignment) {
EXPECT_EQ(1u, q.GetTokens()[1].length);
EXPECT_STREQ("0", q.GetTokens()[1].name);
EXPECT_EQ(0u, q.GetTokens()[1].index);
+ EXPECT_NE(&p.GetAllocator(), &q.GetAllocator());
}
// Static tokens