From d8013f9c3a4888bb9925ffb57ff2cd9c522639fc Mon Sep 17 00:00:00 2001 From: Simon Woertz Date: Tue, 16 Nov 2021 23:51:03 +0100 Subject: [PATCH] Tests: Add test cases for #10702 and #10717 Add test cases for parsing an empty file and a truncated file. --- Tests/LibPDF/TestPDF.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Tests/LibPDF/TestPDF.cpp b/Tests/LibPDF/TestPDF.cpp index db41e0bcb4..38c0e90ceb 100644 --- a/Tests/LibPDF/TestPDF.cpp +++ b/Tests/LibPDF/TestPDF.cpp @@ -4,6 +4,8 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include +#include #include #include #include @@ -29,3 +31,17 @@ TEST_CASE(complex_pdf) auto document = PDF::Document::create(file->bytes()); EXPECT_EQ(document->get_page_count(), 3U); } + +TEST_CASE(empty_file_issue_10702) +{ + AK::ReadonlyBytes empty; + auto document = PDF::Document::create(empty); + EXPECT(document.is_null()); +} + +TEST_CASE(truncated_pdf_header_issue_10717) +{ + AK::String string { "%PDF-2.11%" }; + auto document = PDF::Document::create(string.bytes()); + EXPECT(document.is_null()); +}