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

Side by Side Diff: core/fpdfapi/fpdf_parser/cpdf_array_unittest.cpp

Issue 2275593002: IndirectObjectHolder API updates (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Missed one 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
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/fpdfapi/fpdf_parser/include/cpdf_array.h" 5 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
6 #include "core/fpdfapi/fpdf_parser/include/cpdf_number.h" 6 #include "core/fpdfapi/fpdf_parser/include/cpdf_number.h"
7 #include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h" 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h"
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 ScopedArray arr(new CPDF_Array); 109 ScopedArray arr(new CPDF_Array);
110 // Indirect references to indirect objects. 110 // Indirect references to indirect objects.
111 std::unique_ptr<CPDF_IndirectObjectHolder> obj_holder( 111 std::unique_ptr<CPDF_IndirectObjectHolder> obj_holder(
112 new CPDF_IndirectObjectHolder(nullptr)); 112 new CPDF_IndirectObjectHolder(nullptr));
113 for (size_t i = 0; i < kNumOfRows; ++i) { 113 for (size_t i = 0; i < kNumOfRows; ++i) {
114 CPDF_Array* arr_elem = new CPDF_Array; 114 CPDF_Array* arr_elem = new CPDF_Array;
115 for (size_t j = 0; j < kNumOfRowElems; ++j) { 115 for (size_t j = 0; j < kNumOfRowElems; ++j) {
116 CPDF_Number* obj = new CPDF_Number(elems[i][j]); 116 CPDF_Number* obj = new CPDF_Number(elems[i][j]);
117 // Starts object number from 1. 117 // Starts object number from 1.
118 int obj_num = i * kNumOfRowElems + j + 1; 118 int obj_num = i * kNumOfRowElems + j + 1;
119 obj_holder->InsertIndirectObject(obj_num, obj); 119 obj_holder->ReplaceIndirectObjectIfHigherGeneration(obj_num, obj);
120 arr_elem->InsertAt(j, new CPDF_Reference(obj_holder.get(), obj_num), 120 arr_elem->InsertAt(j, new CPDF_Reference(obj_holder.get(), obj_num),
121 obj_holder.get()); 121 obj_holder.get());
122 } 122 }
123 arr->InsertAt(i, arr_elem); 123 arr->InsertAt(i, arr_elem);
124 } 124 }
125 ASSERT_EQ(kNumOfRows, arr->GetCount()); 125 ASSERT_EQ(kNumOfRows, arr->GetCount());
126 // Not dereferencing reference objects means just creating new references 126 // Not dereferencing reference objects means just creating new references
127 // instead of new copies of direct objects. 127 // instead of new copies of direct objects.
128 ScopedArray arr1(arr->Clone(FALSE)->AsArray()); 128 ScopedArray arr1(arr->Clone(FALSE)->AsArray());
129 EXPECT_EQ(arr->GetCount(), arr1->GetCount()); 129 EXPECT_EQ(arr->GetCount(), arr1->GetCount());
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 TEST(cpdf_array, Iterator) { 172 TEST(cpdf_array, Iterator) {
173 int elems[] = {-23, -11, 3, 455, 2345877, 173 int elems[] = {-23, -11, 3, 455, 2345877,
174 0, 7895330, -12564334, 10000, -100000}; 174 0, 7895330, -12564334, 10000, -100000};
175 ScopedArray arr(new CPDF_Array); 175 ScopedArray arr(new CPDF_Array);
176 for (size_t i = 0; i < FX_ArraySize(elems); ++i) 176 for (size_t i = 0; i < FX_ArraySize(elems); ++i)
177 arr->InsertAt(i, new CPDF_Number(elems[i])); 177 arr->InsertAt(i, new CPDF_Number(elems[i]));
178 size_t index = 0; 178 size_t index = 0;
179 for (const auto& it : *arr) 179 for (const auto& it : *arr)
180 EXPECT_EQ(elems[index++], it->AsNumber()->GetInteger()); 180 EXPECT_EQ(elems[index++], it->AsNumber()->GetInteger());
181 } 181 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_parser/cfdf_document.cpp ('k') | core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698