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

Unified Diff: core/fpdfapi/parser/cpdf_array_unittest.cpp

Issue 2384883003: Remove CPDF_Object::Release() in favor of direct delete (Closed)
Patch Set: rebase Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fpdfapi/parser/cpdf_array.cpp ('k') | core/fpdfapi/parser/cpdf_data_avail.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/parser/cpdf_array_unittest.cpp
diff --git a/core/fpdfapi/parser/cpdf_array_unittest.cpp b/core/fpdfapi/parser/cpdf_array_unittest.cpp
index bc9f578021c4ace3d48958cdb7332b19e79c8c84..800afb0f9ae2012ece2267c67e19b6c50009f29c 100644
--- a/core/fpdfapi/parser/cpdf_array_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_array_unittest.cpp
@@ -10,16 +10,10 @@
#include "testing/gtest/include/gtest/gtest.h"
-namespace {
-
-using ScopedArray = std::unique_ptr<CPDF_Array, ReleaseDeleter<CPDF_Array>>;
-
-} // namespace
-
TEST(cpdf_array, RemoveAt) {
{
int elems[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
- ScopedArray arr(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
for (size_t i = 0; i < FX_ArraySize(elems); ++i)
arr->AddInteger(elems[i]);
arr->RemoveAt(3, 3);
@@ -36,7 +30,7 @@ TEST(cpdf_array, RemoveAt) {
{
// When the range is out of bound, RemoveAt has no effect.
int elems[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
- ScopedArray arr(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
for (size_t i = 0; i < FX_ArraySize(elems); ++i)
arr->AddInteger(elems[i]);
arr->RemoveAt(8, 5);
@@ -53,7 +47,7 @@ TEST(cpdf_array, RemoveAt) {
TEST(cpdf_array, InsertAt) {
{
int elems[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
- ScopedArray arr(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
for (size_t i = 0; i < FX_ArraySize(elems); ++i)
arr->InsertAt(i, new CPDF_Number(elems[i]));
EXPECT_EQ(FX_ArraySize(elems), arr->GetCount());
@@ -72,7 +66,7 @@ TEST(cpdf_array, InsertAt) {
// an element is inserted at that position while other unfilled
// positions have nullptr.
int elems[] = {1, 2};
- ScopedArray arr(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
for (size_t i = 0; i < FX_ArraySize(elems); ++i)
arr->InsertAt(i, new CPDF_Number(elems[i]));
arr->InsertAt(10, new CPDF_Number(10));
@@ -89,10 +83,10 @@ TEST(cpdf_array, Clone) {
{
// Basic case.
int elems[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
- ScopedArray arr(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
for (size_t i = 0; i < FX_ArraySize(elems); ++i)
arr->InsertAt(i, new CPDF_Number(elems[i]));
- ScopedArray arr2(arr->Clone()->AsArray());
+ std::unique_ptr<CPDF_Array> arr2(arr->Clone()->AsArray());
EXPECT_EQ(arr->GetCount(), arr2->GetCount());
for (size_t i = 0; i < FX_ArraySize(elems); ++i) {
// Clone() always create new objects.
@@ -106,7 +100,7 @@ TEST(cpdf_array, Clone) {
static const size_t kNumOfRowElems = 5;
int elems[kNumOfRows][kNumOfRowElems] = {
{1, 2, 3, 4, 5}, {10, 9, 8, 7, 6}, {11, 12, 13, 14, 15}};
- ScopedArray arr(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
// Indirect references to indirect objects.
std::unique_ptr<CPDF_IndirectObjectHolder> obj_holder(
new CPDF_IndirectObjectHolder());
@@ -124,10 +118,10 @@ TEST(cpdf_array, Clone) {
ASSERT_EQ(kNumOfRows, arr->GetCount());
// Not dereferencing reference objects means just creating new references
// instead of new copies of direct objects.
- ScopedArray arr1(arr->Clone()->AsArray());
+ std::unique_ptr<CPDF_Array> arr1(arr->Clone()->AsArray());
EXPECT_EQ(arr->GetCount(), arr1->GetCount());
// Dereferencing reference objects creates new copies of direct objects.
- ScopedArray arr2(arr->CloneDirectObject()->AsArray());
+ std::unique_ptr<CPDF_Array> arr2(arr->CloneDirectObject()->AsArray());
EXPECT_EQ(arr->GetCount(), arr2->GetCount());
for (size_t i = 0; i < kNumOfRows; ++i) {
CPDF_Array* arr_elem = arr->GetObjectAt(i)->AsArray();
@@ -171,7 +165,7 @@ TEST(cpdf_array, Clone) {
TEST(cpdf_array, Iterator) {
int elems[] = {-23, -11, 3, 455, 2345877,
0, 7895330, -12564334, 10000, -100000};
- ScopedArray arr(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
for (size_t i = 0; i < FX_ArraySize(elems); ++i)
arr->InsertAt(i, new CPDF_Number(elems[i]));
size_t index = 0;
« no previous file with comments | « core/fpdfapi/parser/cpdf_array.cpp ('k') | core/fpdfapi/parser/cpdf_data_avail.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698