mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
Tests: Add base structure for LibPDF unit tests
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.
This commit is contained in:
parent
e687e5ba74
commit
07a557194c
Notes:
sideshowbarker
2024-07-17 21:25:15 +09:00
Author: https://github.com/swoertz Commit: https://github.com/SerenityOS/serenity/commit/07a557194c9 Pull-request: https://github.com/SerenityOS/serenity/pull/10969 Issue: https://github.com/SerenityOS/serenity/issues/8215 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/BenWiederhake Reviewed-by: https://github.com/bcoles Reviewed-by: https://github.com/linusg
3 changed files with 45 additions and 0 deletions
|
@ -11,6 +11,7 @@ add_subdirectory(LibIMAP)
|
|||
add_subdirectory(LibJS)
|
||||
add_subdirectory(LibM)
|
||||
add_subdirectory(LibMarkdown)
|
||||
add_subdirectory(LibPDF)
|
||||
add_subdirectory(LibPthread)
|
||||
add_subdirectory(LibRegex)
|
||||
add_subdirectory(LibSQL)
|
||||
|
|
13
Tests/LibPDF/CMakeLists.txt
Normal file
13
Tests/LibPDF/CMakeLists.txt
Normal file
|
@ -0,0 +1,13 @@
|
|||
set(TEST_SOURCES
|
||||
TestPDF.cpp
|
||||
)
|
||||
|
||||
foreach(source IN LISTS TEST_SOURCES)
|
||||
serenity_test("${source}" LibPDF LIBS LibCore LibPDF)
|
||||
endforeach()
|
||||
|
||||
install(
|
||||
FILES "../../Base/home/anon/Documents/pdf/complex.pdf"
|
||||
"../../Base/home/anon/Documents/pdf/linearized.pdf"
|
||||
"../../Base/home/anon/Documents/pdf/non-linearized.pdf"
|
||||
DESTINATION usr/Tests/LibPDF)
|
31
Tests/LibPDF/TestPDF.cpp
Normal file
31
Tests/LibPDF/TestPDF.cpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* 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);
|
||||
}
|
Loading…
Reference in a new issue