Mass assert OpenDocument*() in tests
Opening a document is a prerequisite to all tests that open a document,
and success should be tested with an ASSERT instead of an EXPECT.
Done with simple search and replace with
sed -i 's/EXPECT_TRUE(OpenDocument/ASSERT_TRUE(OpenDocument/g'
Change-Id: Ia2ad22a3863b138d9222b821ddec372915c784df
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/71654
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Daniel Hosseinian <dhoss@chromium.org>
diff --git a/fpdfsdk/fpdf_save_embeddertest.cpp b/fpdfsdk/fpdf_save_embeddertest.cpp
index 614b4f4..4b8cfed 100644
--- a/fpdfsdk/fpdf_save_embeddertest.cpp
+++ b/fpdfsdk/fpdf_save_embeddertest.cpp
@@ -18,20 +18,20 @@
class FPDFSaveEmbedderTest : public EmbedderTest {};
TEST_F(FPDFSaveEmbedderTest, SaveSimpleDoc) {
- EXPECT_TRUE(OpenDocument("hello_world.pdf"));
+ ASSERT_TRUE(OpenDocument("hello_world.pdf"));
EXPECT_TRUE(FPDF_SaveAsCopy(document(), this, 0));
EXPECT_THAT(GetString(), testing::StartsWith("%PDF-1.7\r\n"));
EXPECT_EQ(805u, GetString().length());
}
TEST_F(FPDFSaveEmbedderTest, SaveSimpleDocWithVersion) {
- EXPECT_TRUE(OpenDocument("hello_world.pdf"));
+ ASSERT_TRUE(OpenDocument("hello_world.pdf"));
EXPECT_TRUE(FPDF_SaveWithVersion(document(), this, 0, 14));
EXPECT_THAT(GetString(), testing::StartsWith("%PDF-1.4\r\n"));
EXPECT_EQ(805u, GetString().length());
}
TEST_F(FPDFSaveEmbedderTest, SaveSimpleDocWithBadVersion) {
- EXPECT_TRUE(OpenDocument("hello_world.pdf"));
+ ASSERT_TRUE(OpenDocument("hello_world.pdf"));
EXPECT_TRUE(FPDF_SaveWithVersion(document(), this, 0, -1));
EXPECT_THAT(GetString(), testing::StartsWith("%PDF-1.7\r\n"));
@@ -45,7 +45,7 @@
}
TEST_F(FPDFSaveEmbedderTest, SaveCopiedDoc) {
- EXPECT_TRUE(OpenDocument("hello_world.pdf"));
+ ASSERT_TRUE(OpenDocument("hello_world.pdf"));
FPDF_PAGE page = LoadPage(0);
EXPECT_TRUE(page);
@@ -63,7 +63,7 @@
const int kPageCount = 3;
std::string original_md5[kPageCount];
- EXPECT_TRUE(OpenDocument("linearized.pdf"));
+ ASSERT_TRUE(OpenDocument("linearized.pdf"));
for (int i = 0; i < kPageCount; ++i) {
FPDF_PAGE page = LoadPage(i);
ASSERT_TRUE(page);
@@ -104,7 +104,7 @@
#endif // PDF_ENABLE_XFA
TEST_F(FPDFSaveEmbedderTest, BUG_342) {
- EXPECT_TRUE(OpenDocument("hello_world.pdf"));
+ ASSERT_TRUE(OpenDocument("hello_world.pdf"));
EXPECT_TRUE(FPDF_SaveAsCopy(document(), this, 0));
EXPECT_THAT(GetString(), testing::HasSubstr("0000000000 65535 f\r\n"));
EXPECT_THAT(GetString(),
@@ -112,7 +112,7 @@
}
TEST_F(FPDFSaveEmbedderTest, BUG_905142) {
- EXPECT_TRUE(OpenDocument("bug_905142.pdf"));
+ ASSERT_TRUE(OpenDocument("bug_905142.pdf"));
EXPECT_TRUE(FPDF_SaveAsCopy(document(), this, 0));
EXPECT_THAT(GetString(), testing::HasSubstr("/Length 0"));
}