From 655c783b8077f18e17418a3aab9b5a07c8055049 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 23 May 2017 17:10:46 -0700 Subject: Convert to CFX_UnownedPtr, part 3. Remove an explicit clear to re-order the member destruction order. Change-Id: I33da3f3de4b8e8e0cfbdceaf5140e98f5d6f904a Reviewed-on: https://pdfium-review.googlesource.com/5791 Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- core/fpdfdoc/cpdf_dest_unittest.cpp | 59 ++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 27 deletions(-) (limited to 'core/fpdfdoc/cpdf_dest_unittest.cpp') diff --git a/core/fpdfdoc/cpdf_dest_unittest.cpp b/core/fpdfdoc/cpdf_dest_unittest.cpp index 7c35371085..2b3c86a882 100644 --- a/core/fpdfdoc/cpdf_dest_unittest.cpp +++ b/core/fpdfdoc/cpdf_dest_unittest.cpp @@ -19,43 +19,48 @@ TEST(cpdf_dest, GetXYZ) { float y; float zoom; - auto dest = pdfium::MakeUnique(); - EXPECT_FALSE(dest->GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom)); - + // |array| must outlive |dest|. auto array = pdfium::MakeUnique(); array->AddNew(0); // Page Index. array->AddNew("XYZ"); array->AddNew(4); // X - - // Not enough entries. - dest = pdfium::MakeUnique(array.get()); - EXPECT_FALSE(dest->GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom)); - + { + auto dest = pdfium::MakeUnique(); + EXPECT_FALSE(dest->GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom)); + } + { + // Not enough entries. + auto dest = pdfium::MakeUnique(array.get()); + EXPECT_FALSE(dest->GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom)); + } array->AddNew(5); // Y array->AddNew(6); // Zoom. - - dest = pdfium::MakeUnique(array.get()); - EXPECT_TRUE(dest->GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom)); - EXPECT_TRUE(hasX); - EXPECT_TRUE(hasY); - EXPECT_TRUE(hasZoom); - EXPECT_EQ(4, x); - EXPECT_EQ(5, y); - EXPECT_EQ(6, zoom); - + { + auto dest = pdfium::MakeUnique(array.get()); + EXPECT_TRUE(dest->GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom)); + EXPECT_TRUE(hasX); + EXPECT_TRUE(hasY); + EXPECT_TRUE(hasZoom); + EXPECT_EQ(4, x); + EXPECT_EQ(5, y); + EXPECT_EQ(6, zoom); + } // Set zoom to 0. array->SetNewAt(4, 0); - dest = pdfium::MakeUnique(array.get()); - EXPECT_TRUE(dest->GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom)); - EXPECT_FALSE(hasZoom); - + { + auto dest = pdfium::MakeUnique(array.get()); + EXPECT_TRUE(dest->GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom)); + EXPECT_FALSE(hasZoom); + } // Set values to null. array->SetNewAt(2); array->SetNewAt(3); array->SetNewAt(4); - dest = pdfium::MakeUnique(array.get()); - EXPECT_TRUE(dest->GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom)); - EXPECT_FALSE(hasX); - EXPECT_FALSE(hasY); - EXPECT_FALSE(hasZoom); + { + auto dest = pdfium::MakeUnique(array.get()); + EXPECT_TRUE(dest->GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom)); + EXPECT_FALSE(hasX); + EXPECT_FALSE(hasY); + EXPECT_FALSE(hasZoom); + } } -- cgit v1.2.3