diff options
Diffstat (limited to 'core/fpdfapi/parser')
-rw-r--r-- | core/fpdfapi/parser/cpdf_array_unittest.cpp | 13 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_object_unittest.cpp | 19 |
2 files changed, 15 insertions, 17 deletions
diff --git a/core/fpdfapi/parser/cpdf_array_unittest.cpp b/core/fpdfapi/parser/cpdf_array_unittest.cpp index 6d458d83cd..1e92b32716 100644 --- a/core/fpdfapi/parser/cpdf_array_unittest.cpp +++ b/core/fpdfapi/parser/cpdf_array_unittest.cpp @@ -15,7 +15,7 @@ TEST(cpdf_array, RemoveAt) { { int elems[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; - std::unique_ptr<CPDF_Array> arr(new CPDF_Array); + auto arr = pdfium::MakeUnique<CPDF_Array>(); for (size_t i = 0; i < FX_ArraySize(elems); ++i) arr->AddNew<CPDF_Number>(elems[i]); arr->RemoveAt(3, 3); @@ -32,7 +32,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}; - std::unique_ptr<CPDF_Array> arr(new CPDF_Array); + auto arr = pdfium::MakeUnique<CPDF_Array>(); for (size_t i = 0; i < FX_ArraySize(elems); ++i) arr->AddNew<CPDF_Number>(elems[i]); arr->RemoveAt(8, 5); @@ -102,14 +102,13 @@ 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}}; - std::unique_ptr<CPDF_Array> arr(new CPDF_Array); + auto arr = pdfium::MakeUnique<CPDF_Array>(); // Indirect references to indirect objects. - std::unique_ptr<CPDF_IndirectObjectHolder> obj_holder( - new CPDF_IndirectObjectHolder()); + auto obj_holder = pdfium::MakeUnique<CPDF_IndirectObjectHolder>(); for (size_t i = 0; i < kNumOfRows; ++i) { auto arr_elem = pdfium::MakeUnique<CPDF_Array>(); for (size_t j = 0; j < kNumOfRowElems; ++j) { - std::unique_ptr<CPDF_Number> obj(new CPDF_Number(elems[i][j])); + auto obj = pdfium::MakeUnique<CPDF_Number>(elems[i][j]); // Starts object number from 1. int obj_num = i * kNumOfRowElems + j + 1; obj_holder->ReplaceIndirectObjectIfHigherGeneration(obj_num, @@ -168,7 +167,7 @@ TEST(cpdf_array, Clone) { TEST(cpdf_array, Iterator) { const int elems[] = {-23, -11, 3, 455, 2345877, 0, 7895330, -12564334, 10000, -100000}; - std::unique_ptr<CPDF_Array> arr(new CPDF_Array); + auto arr = pdfium::MakeUnique<CPDF_Array>(); for (size_t i = 0; i < FX_ArraySize(elems); ++i) arr->InsertNewAt<CPDF_Number>(i, elems[i]); size_t index = 0; diff --git a/core/fpdfapi/parser/cpdf_object_unittest.cpp b/core/fpdfapi/parser/cpdf_object_unittest.cpp index b25d40a029..3b5374b637 100644 --- a/core/fpdfapi/parser/cpdf_object_unittest.cpp +++ b/core/fpdfapi/parser/cpdf_object_unittest.cpp @@ -484,8 +484,8 @@ TEST(PDFArrayTest, GetTypeAt) { // String and name array const char* const vals[] = {"this", "adsde$%^", "\r\t", "\"012", ".", "EYREW", "It is a joke :)"}; - std::unique_ptr<CPDF_Array> string_array(new CPDF_Array); - std::unique_ptr<CPDF_Array> name_array(new CPDF_Array); + auto string_array = pdfium::MakeUnique<CPDF_Array>(); + auto name_array = pdfium::MakeUnique<CPDF_Array>(); for (size_t i = 0; i < FX_ArraySize(vals); ++i) { string_array->InsertNewAt<CPDF_String>(i, vals[i], false); name_array->InsertNewAt<CPDF_Name>(i, vals[i]); @@ -695,8 +695,8 @@ TEST(PDFArrayTest, AddInteger) { TEST(PDFArrayTest, AddStringAndName) { const char* vals[] = {"", "a", "ehjhRIOYTTFdfcdnv", "122323", "$#%^&**", " ", "This is a test.\r\n"}; - std::unique_ptr<CPDF_Array> string_array(new CPDF_Array); - std::unique_ptr<CPDF_Array> name_array(new CPDF_Array); + auto string_array = pdfium::MakeUnique<CPDF_Array>(); + auto name_array = pdfium::MakeUnique<CPDF_Array>(); for (size_t i = 0; i < FX_ArraySize(vals); ++i) { string_array->AddNew<CPDF_String>(vals[i], false); name_array->AddNew<CPDF_Name>(vals[i]); @@ -710,8 +710,7 @@ TEST(PDFArrayTest, AddStringAndName) { } TEST(PDFArrayTest, AddReferenceAndGetObjectAt) { - std::unique_ptr<CPDF_IndirectObjectHolder> holder( - new CPDF_IndirectObjectHolder()); + auto holder = pdfium::MakeUnique<CPDF_IndirectObjectHolder>(); CPDF_Boolean* boolean_obj = new CPDF_Boolean(true); CPDF_Number* int_obj = new CPDF_Number(-1234); CPDF_Number* float_obj = new CPDF_Number(2345.089f); @@ -723,7 +722,7 @@ TEST(PDFArrayTest, AddReferenceAndGetObjectAt) { str_obj, name_obj, null_obj}; unsigned int obj_nums[] = {2, 4, 7, 2345, 799887, 1}; auto arr = pdfium::MakeUnique<CPDF_Array>(); - std::unique_ptr<CPDF_Array> arr1(new CPDF_Array); + auto arr1 = pdfium::MakeUnique<CPDF_Array>(); // Create two arrays of references by different AddReference() APIs. for (size_t i = 0; i < FX_ArraySize(indirect_objs); ++i) { holder->ReplaceIndirectObjectIfHigherGeneration( @@ -748,7 +747,7 @@ TEST(PDFArrayTest, AddReferenceAndGetObjectAt) { TEST(PDFArrayTest, CloneDirectObject) { CPDF_IndirectObjectHolder objects_holder; - std::unique_ptr<CPDF_Array> array(new CPDF_Array); + auto array = pdfium::MakeUnique<CPDF_Array>(); array->AddNew<CPDF_Reference>(&objects_holder, 1234); ASSERT_EQ(1U, array->GetCount()); CPDF_Object* obj = array->GetObjectAt(0); @@ -782,7 +781,7 @@ TEST(PDFArrayTest, ConvertIndirect) { TEST(PDFDictionaryTest, CloneDirectObject) { CPDF_IndirectObjectHolder objects_holder; - std::unique_ptr<CPDF_Dictionary> dict(new CPDF_Dictionary()); + auto dict = pdfium::MakeUnique<CPDF_Dictionary>(); dict->SetNewFor<CPDF_Reference>("foo", &objects_holder, 1234); ASSERT_EQ(1U, dict->GetCount()); CPDF_Object* obj = dict->GetObjectFor("foo"); @@ -867,7 +866,7 @@ TEST(PDFObjectTest, CloneCheckLoop) { TEST(PDFDictionaryTest, ConvertIndirect) { CPDF_IndirectObjectHolder objects_holder; - std::unique_ptr<CPDF_Dictionary> dict(new CPDF_Dictionary); + auto dict = pdfium::MakeUnique<CPDF_Dictionary>(); CPDF_Object* pObj = dict->SetNewFor<CPDF_Number>("clams", 42); dict->ConvertToIndirectObjectFor("clams", &objects_holder); CPDF_Object* pRef = dict->GetObjectFor("clams"); |