Unverified Commit 7641af69 authored by Milo Yip's avatar Milo Yip Committed by GitHub

Merge pull request #1122 from svart-riddare/issue-1108

Suggestion for issue #1108
parents cdc899a3 44f2f9aa
...@@ -165,7 +165,12 @@ public: ...@@ -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) {} GenericPointer(const Token* tokens, size_t tokenCount) : allocator_(), ownAllocator_(), nameBuffer_(), tokens_(const_cast<Token*>(tokens)), tokenCount_(tokenCount), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) {}
//! Copy constructor. //! 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; *this = rhs;
} }
......
...@@ -462,7 +462,8 @@ TEST(Pointer, ConstructorWithToken) { ...@@ -462,7 +462,8 @@ TEST(Pointer, ConstructorWithToken) {
TEST(Pointer, CopyConstructor) { TEST(Pointer, CopyConstructor) {
{ {
Pointer p("/foo/0"); CrtAllocator allocator;
Pointer p("/foo/0", &allocator);
Pointer q(p); Pointer q(p);
EXPECT_TRUE(q.IsValid()); EXPECT_TRUE(q.IsValid());
EXPECT_EQ(2u, q.GetTokenCount()); EXPECT_EQ(2u, q.GetTokenCount());
...@@ -471,6 +472,7 @@ TEST(Pointer, CopyConstructor) { ...@@ -471,6 +472,7 @@ TEST(Pointer, CopyConstructor) {
EXPECT_EQ(1u, q.GetTokens()[1].length); EXPECT_EQ(1u, q.GetTokens()[1].length);
EXPECT_STREQ("0", q.GetTokens()[1].name); EXPECT_STREQ("0", q.GetTokens()[1].name);
EXPECT_EQ(0u, q.GetTokens()[1].index); EXPECT_EQ(0u, q.GetTokens()[1].index);
EXPECT_EQ(&p.GetAllocator(), &q.GetAllocator());
} }
// Static tokens // Static tokens
...@@ -489,7 +491,8 @@ TEST(Pointer, CopyConstructor) { ...@@ -489,7 +491,8 @@ TEST(Pointer, CopyConstructor) {
TEST(Pointer, Assignment) { TEST(Pointer, Assignment) {
{ {
Pointer p("/foo/0"); CrtAllocator allocator;
Pointer p("/foo/0", &allocator);
Pointer q; Pointer q;
q = p; q = p;
EXPECT_TRUE(q.IsValid()); EXPECT_TRUE(q.IsValid());
...@@ -499,6 +502,7 @@ TEST(Pointer, Assignment) { ...@@ -499,6 +502,7 @@ TEST(Pointer, Assignment) {
EXPECT_EQ(1u, q.GetTokens()[1].length); EXPECT_EQ(1u, q.GetTokens()[1].length);
EXPECT_STREQ("0", q.GetTokens()[1].name); EXPECT_STREQ("0", q.GetTokens()[1].name);
EXPECT_EQ(0u, q.GetTokens()[1].index); EXPECT_EQ(0u, q.GetTokens()[1].index);
EXPECT_NE(&p.GetAllocator(), &q.GetAllocator());
q = q; q = q;
EXPECT_TRUE(q.IsValid()); EXPECT_TRUE(q.IsValid());
EXPECT_EQ(2u, q.GetTokenCount()); EXPECT_EQ(2u, q.GetTokenCount());
...@@ -507,6 +511,7 @@ TEST(Pointer, Assignment) { ...@@ -507,6 +511,7 @@ TEST(Pointer, Assignment) {
EXPECT_EQ(1u, q.GetTokens()[1].length); EXPECT_EQ(1u, q.GetTokens()[1].length);
EXPECT_STREQ("0", q.GetTokens()[1].name); EXPECT_STREQ("0", q.GetTokens()[1].name);
EXPECT_EQ(0u, q.GetTokens()[1].index); EXPECT_EQ(0u, q.GetTokens()[1].index);
EXPECT_NE(&p.GetAllocator(), &q.GetAllocator());
} }
// Static tokens // Static tokens
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment