summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/cpdf_dest_unittest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfdoc/cpdf_dest_unittest.cpp')
-rw-r--r--core/fpdfdoc/cpdf_dest_unittest.cpp59
1 files changed, 32 insertions, 27 deletions
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<CPDF_Dest>();
- EXPECT_FALSE(dest->GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom));
-
+ // |array| must outlive |dest|.
auto array = pdfium::MakeUnique<CPDF_Array>();
array->AddNew<CPDF_Number>(0); // Page Index.
array->AddNew<CPDF_Name>("XYZ");
array->AddNew<CPDF_Number>(4); // X
-
- // Not enough entries.
- dest = pdfium::MakeUnique<CPDF_Dest>(array.get());
- EXPECT_FALSE(dest->GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom));
-
+ {
+ auto dest = pdfium::MakeUnique<CPDF_Dest>();
+ EXPECT_FALSE(dest->GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom));
+ }
+ {
+ // Not enough entries.
+ auto dest = pdfium::MakeUnique<CPDF_Dest>(array.get());
+ EXPECT_FALSE(dest->GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom));
+ }
array->AddNew<CPDF_Number>(5); // Y
array->AddNew<CPDF_Number>(6); // Zoom.
-
- dest = pdfium::MakeUnique<CPDF_Dest>(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<CPDF_Dest>(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<CPDF_Number>(4, 0);
- dest = pdfium::MakeUnique<CPDF_Dest>(array.get());
- EXPECT_TRUE(dest->GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom));
- EXPECT_FALSE(hasZoom);
-
+ {
+ auto dest = pdfium::MakeUnique<CPDF_Dest>(array.get());
+ EXPECT_TRUE(dest->GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom));
+ EXPECT_FALSE(hasZoom);
+ }
// Set values to null.
array->SetNewAt<CPDF_Null>(2);
array->SetNewAt<CPDF_Null>(3);
array->SetNewAt<CPDF_Null>(4);
- dest = pdfium::MakeUnique<CPDF_Dest>(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<CPDF_Dest>(array.get());
+ EXPECT_TRUE(dest->GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom));
+ EXPECT_FALSE(hasX);
+ EXPECT_FALSE(hasY);
+ EXPECT_FALSE(hasZoom);
+ }
}