| 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/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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 } | 69 } |
| 70 { | 70 { |
| 71 // When the position to insert is beyond the upper bound, | 71 // When the position to insert is beyond the upper bound, |
| 72 // an element is inserted at that position while other unfilled | 72 // an element is inserted at that position while other unfilled |
| 73 // positions have nullptr. | 73 // positions have nullptr. |
| 74 int elems[] = {1, 2}; | 74 int elems[] = {1, 2}; |
| 75 ScopedArray arr(new CPDF_Array); | 75 ScopedArray arr(new CPDF_Array); |
| 76 for (size_t i = 0; i < FX_ArraySize(elems); ++i) | 76 for (size_t i = 0; i < FX_ArraySize(elems); ++i) |
| 77 arr->InsertAt(i, new CPDF_Number(elems[i])); | 77 arr->InsertAt(i, new CPDF_Number(elems[i])); |
| 78 arr->InsertAt(10, new CPDF_Number(10)); | 78 arr->InsertAt(10, new CPDF_Number(10)); |
| 79 EXPECT_EQ(11, arr->GetCount()); | 79 EXPECT_EQ(11u, arr->GetCount()); |
| 80 for (size_t i = 0; i < FX_ArraySize(elems); ++i) | 80 for (size_t i = 0; i < FX_ArraySize(elems); ++i) |
| 81 EXPECT_EQ(elems[i], arr->GetIntegerAt(i)); | 81 EXPECT_EQ(elems[i], arr->GetIntegerAt(i)); |
| 82 for (size_t i = FX_ArraySize(elems); i < 10; ++i) | 82 for (size_t i = FX_ArraySize(elems); i < 10; ++i) |
| 83 EXPECT_EQ(nullptr, arr->GetObjectAt(i)); | 83 EXPECT_EQ(nullptr, arr->GetObjectAt(i)); |
| 84 EXPECT_EQ(10, arr->GetIntegerAt(10)); | 84 EXPECT_EQ(10, arr->GetIntegerAt(10)); |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 | 87 |
| 88 TEST(cpdf_array, Clone) { | 88 TEST(cpdf_array, Clone) { |
| 89 { | 89 { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } |
| OLD | NEW |