Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: core/fxcrt/cfx_count_ref_unittest.cpp

Issue 2283113002: Add -> operators to CFX_CountRef. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@privatize
Patch Set: Regenerate patch, rebase off of master. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fpdftext/cpdf_textpage.cpp ('k') | core/fxcrt/include/cfx_count_ref.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/fxcrt/include/cfx_count_ref.h" 5 #include "core/fxcrt/include/cfx_count_ref.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "testing/fx_string_testhelpers.h" 10 #include "testing/fx_string_testhelpers.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 EXPECT_EQ(0, observer.GetDestructionCount("two")); 102 EXPECT_EQ(0, observer.GetDestructionCount("two"));
103 } 103 }
104 EXPECT_EQ(1, observer.GetDestructionCount("one")); 104 EXPECT_EQ(1, observer.GetDestructionCount("one"));
105 EXPECT_EQ(1, observer.GetDestructionCount("two")); 105 EXPECT_EQ(1, observer.GetDestructionCount("two"));
106 } 106 }
107 107
108 TEST(fxcrt, CountRefGetModify) { 108 TEST(fxcrt, CountRefGetModify) {
109 Observer observer; 109 Observer observer;
110 { 110 {
111 CFX_CountRef<Object> ptr; 111 CFX_CountRef<Object> ptr;
112 EXPECT_NE(nullptr, ptr.GetPrivateCopy(&observer, std::string("one"))); 112 ptr.MakePrivateCopy(&observer, std::string("one"));
113 EXPECT_NE(nullptr, ptr.GetObject());
113 EXPECT_EQ(1, observer.GetConstructionCount("one")); 114 EXPECT_EQ(1, observer.GetConstructionCount("one"));
114 EXPECT_EQ(0, observer.GetDestructionCount("one")); 115 EXPECT_EQ(0, observer.GetDestructionCount("one"));
115 116
116 EXPECT_NE(nullptr, ptr.GetPrivateCopy(&observer, std::string("one"))); 117 ptr.MakePrivateCopy(&observer, std::string("one"));
118 EXPECT_NE(nullptr, ptr.GetObject());
117 EXPECT_EQ(1, observer.GetConstructionCount("one")); 119 EXPECT_EQ(1, observer.GetConstructionCount("one"));
118 EXPECT_EQ(0, observer.GetDestructionCount("one")); 120 EXPECT_EQ(0, observer.GetDestructionCount("one"));
119 { 121 {
120 CFX_CountRef<Object> other(ptr); 122 CFX_CountRef<Object> other(ptr);
121 EXPECT_NE(nullptr, ptr.GetPrivateCopy(&observer, std::string("one"))); 123 ptr.MakePrivateCopy(&observer, std::string("one"));
124 EXPECT_NE(nullptr, ptr.GetObject());
122 EXPECT_EQ(2, observer.GetConstructionCount("one")); 125 EXPECT_EQ(2, observer.GetConstructionCount("one"));
123 EXPECT_EQ(0, observer.GetDestructionCount("one")); 126 EXPECT_EQ(0, observer.GetDestructionCount("one"));
124 } 127 }
125 EXPECT_EQ(2, observer.GetConstructionCount("one")); 128 EXPECT_EQ(2, observer.GetConstructionCount("one"));
126 EXPECT_EQ(1, observer.GetDestructionCount("one")); 129 EXPECT_EQ(1, observer.GetDestructionCount("one"));
127 } 130 }
128 EXPECT_EQ(2, observer.GetDestructionCount("one")); 131 EXPECT_EQ(2, observer.GetDestructionCount("one"));
129 } 132 }
OLDNEW
« no previous file with comments | « core/fpdftext/cpdf_textpage.cpp ('k') | core/fxcrt/include/cfx_count_ref.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698