| OLD | NEW |
| 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/cpdf_array.h" | 5 #include "core/fpdfapi/fpdf_parser/cpdf_array.h" |
| 6 #include "core/fpdfapi/fpdf_parser/cpdf_number.h" | 6 #include "core/fpdfapi/fpdf_parser/cpdf_number.h" |
| 7 #include "core/fpdfapi/fpdf_parser/cpdf_reference.h" | 7 #include "core/fpdfapi/fpdf_parser/cpdf_reference.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 using ScopedArray = std::unique_ptr<CPDF_Array, ReleaseDeleter<CPDF_Array>>; | 15 using ScopedArray = std::unique_ptr<CPDF_Array>; |
| 16 | 16 |
| 17 } // namespace | 17 } // namespace |
| 18 | 18 |
| 19 TEST(cpdf_array, RemoveAt) { | 19 TEST(cpdf_array, RemoveAt) { |
| 20 { | 20 { |
| 21 int elems[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; | 21 int elems[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; |
| 22 ScopedArray arr(new CPDF_Array); | 22 ScopedArray arr(new CPDF_Array); |
| 23 for (size_t i = 0; i < FX_ArraySize(elems); ++i) | 23 for (size_t i = 0; i < FX_ArraySize(elems); ++i) |
| 24 arr->AddInteger(elems[i]); | 24 arr->AddInteger(elems[i]); |
| 25 arr->RemoveAt(3, 3); | 25 arr->RemoveAt(3, 3); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 TEST(cpdf_array, Iterator) { | 171 TEST(cpdf_array, Iterator) { |
| 172 int elems[] = {-23, -11, 3, 455, 2345877, | 172 int elems[] = {-23, -11, 3, 455, 2345877, |
| 173 0, 7895330, -12564334, 10000, -100000}; | 173 0, 7895330, -12564334, 10000, -100000}; |
| 174 ScopedArray arr(new CPDF_Array); | 174 ScopedArray arr(new CPDF_Array); |
| 175 for (size_t i = 0; i < FX_ArraySize(elems); ++i) | 175 for (size_t i = 0; i < FX_ArraySize(elems); ++i) |
| 176 arr->InsertAt(i, new CPDF_Number(elems[i])); | 176 arr->InsertAt(i, new CPDF_Number(elems[i])); |
| 177 size_t index = 0; | 177 size_t index = 0; |
| 178 for (const auto& it : *arr) | 178 for (const auto& it : *arr) |
| 179 EXPECT_EQ(elems[index++], it->AsNumber()->GetInteger()); | 179 EXPECT_EQ(elems[index++], it->AsNumber()->GetInteger()); |
| 180 } | 180 } |
| OLD | NEW |