diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 920f64749f..9164ffb885 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -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) diff --git a/Tests/LibPDF/CMakeLists.txt b/Tests/LibPDF/CMakeLists.txt new file mode 100644 index 0000000000..f8769e0905 --- /dev/null +++ b/Tests/LibPDF/CMakeLists.txt @@ -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) diff --git a/Tests/LibPDF/TestPDF.cpp b/Tests/LibPDF/TestPDF.cpp new file mode 100644 index 0000000000..db41e0bcb4 --- /dev/null +++ b/Tests/LibPDF/TestPDF.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2021, Simon Woertz + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include +#include +#include +#include + +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); +}