mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-16 05:51:55 +00:00
Add a unit test for each sample pdf file that currently exists in the anon user's `~/Document/pdf` directory. - linear.pdf - non-linearized.pdf - complex.pdf Each test ensures that the pdf document is parsed and that the page count is the expected one.
31 lines
854 B
C++
31 lines
854 B
C++
/*
|
|
* Copyright (c) 2021, Simon Woertz <simon@woertz.at>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibCore/MappedFile.h>
|
|
#include <LibPDF/Document.h>
|
|
#include <LibTest/Macros.h>
|
|
#include <LibTest/TestCase.h>
|
|
|
|
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);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
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);
|
|
}
|