mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:17:45 +00:00
LibPDF: Propagate errors in Parser and Document
This commit is contained in:
parent
7e1c823725
commit
73cf8205b4
16 changed files with 472 additions and 420 deletions
|
@ -15,33 +15,36 @@ TEST_CASE(linearized_pdf)
|
|||
{
|
||||
auto file = Core::MappedFile::map("linearized.pdf").release_value();
|
||||
auto document = PDF::Document::create(file->bytes());
|
||||
EXPECT_EQ(document->get_page_count(), 1U);
|
||||
EXPECT(!document.is_error());
|
||||
EXPECT_EQ(document.value()->get_page_count(), 1U);
|
||||
}
|
||||
|
||||
TEST_CASE(non_linearized_pdf)
|
||||
{
|
||||
auto file = Core::MappedFile::map("non-linearized.pdf").release_value();
|
||||
auto document = PDF::Document::create(file->bytes());
|
||||
EXPECT_EQ(document->get_page_count(), 1U);
|
||||
EXPECT(!document.is_error());
|
||||
EXPECT_EQ(document.value()->get_page_count(), 1U);
|
||||
}
|
||||
|
||||
TEST_CASE(complex_pdf)
|
||||
{
|
||||
auto file = Core::MappedFile::map("complex.pdf").release_value();
|
||||
auto document = PDF::Document::create(file->bytes());
|
||||
EXPECT_EQ(document->get_page_count(), 3U);
|
||||
EXPECT(!document.is_error());
|
||||
EXPECT_EQ(document.value()->get_page_count(), 3U);
|
||||
}
|
||||
|
||||
TEST_CASE(empty_file_issue_10702)
|
||||
{
|
||||
AK::ReadonlyBytes empty;
|
||||
auto document = PDF::Document::create(empty);
|
||||
EXPECT(document.is_null());
|
||||
EXPECT(document.is_error());
|
||||
}
|
||||
|
||||
TEST_CASE(truncated_pdf_header_issue_10717)
|
||||
{
|
||||
AK::String string { "%PDF-2.11%" };
|
||||
auto document = PDF::Document::create(string.bytes());
|
||||
EXPECT(document.is_null());
|
||||
EXPECT(document.is_error());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue