Skip to content

Commit 44f2f9a

Browse files
committed
Added relevant unit tests for issue Tencent#1108 suggested improvement.
1 parent 86e280f commit 44f2f9a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

test/unittest/pointertest.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,8 @@ TEST(Pointer, ConstructorWithToken) {
462462

463463
TEST(Pointer, CopyConstructor) {
464464
{
465-
Pointer p("/foo/0");
465+
CrtAllocator allocator;
466+
Pointer p("/foo/0", &allocator);
466467
Pointer q(p);
467468
EXPECT_TRUE(q.IsValid());
468469
EXPECT_EQ(2u, q.GetTokenCount());
@@ -471,6 +472,7 @@ TEST(Pointer, CopyConstructor) {
471472
EXPECT_EQ(1u, q.GetTokens()[1].length);
472473
EXPECT_STREQ("0", q.GetTokens()[1].name);
473474
EXPECT_EQ(0u, q.GetTokens()[1].index);
475+
EXPECT_EQ(&p.GetAllocator(), &q.GetAllocator());
474476
}
475477

476478
// Static tokens
@@ -489,7 +491,8 @@ TEST(Pointer, CopyConstructor) {
489491

490492
TEST(Pointer, Assignment) {
491493
{
492-
Pointer p("/foo/0");
494+
CrtAllocator allocator;
495+
Pointer p("/foo/0", &allocator);
493496
Pointer q;
494497
q = p;
495498
EXPECT_TRUE(q.IsValid());
@@ -499,6 +502,7 @@ TEST(Pointer, Assignment) {
499502
EXPECT_EQ(1u, q.GetTokens()[1].length);
500503
EXPECT_STREQ("0", q.GetTokens()[1].name);
501504
EXPECT_EQ(0u, q.GetTokens()[1].index);
505+
EXPECT_NE(&p.GetAllocator(), &q.GetAllocator());
502506
q = q;
503507
EXPECT_TRUE(q.IsValid());
504508
EXPECT_EQ(2u, q.GetTokenCount());
@@ -507,6 +511,7 @@ TEST(Pointer, Assignment) {
507511
EXPECT_EQ(1u, q.GetTokens()[1].length);
508512
EXPECT_STREQ("0", q.GetTokens()[1].name);
509513
EXPECT_EQ(0u, q.GetTokens()[1].index);
514+
EXPECT_NE(&p.GetAllocator(), &q.GetAllocator());
510515
}
511516

512517
// Static tokens

0 commit comments

Comments
 (0)