diff --git a/test/src/pdf2htmlEX_wrapper_test.cpp b/test/src/pdf2htmlEX_wrapper_test.cpp new file mode 100644 index 00000000..14ab038b --- /dev/null +++ b/test/src/pdf2htmlEX_wrapper_test.cpp @@ -0,0 +1,62 @@ +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +using namespace odr; +using namespace odr::test; +using namespace odr::internal; +using namespace odr::test; +namespace fs = std::filesystem; + +using pdf2htmlEXWrapperTests = ::testing::TestWithParam; + +TEST_P(pdf2htmlEXWrapperTests, html) { + const std::string test_file_path = GetParam(); + const TestFile test_file = TestData::test_file(test_file_path); + + const std::string test_repo = *common::Path(test_file_path).begin(); + const std::string output_path_prefix = + common::Path("output").join(test_repo).join("output").join("pdf2htmlEX").string(); + const std::string output_path = + common::Path(output_path_prefix) + .join(common::Path(test_file_path).rebase(test_repo)) + .string(); + + std::cout << test_file.path << " to " << output_path << std::endl; + + if (!util::string::ends_with(test_file.path, ".pdf") && test_file.type != FileType::portable_document_format) { + GTEST_SKIP(); + } + + fs::create_directories(output_path); + HtmlConfig config; + std::optional password; + Html html = odr::internal::html::pdf2htmlEX_wrapper(test_file.path, output_path, config, password); + + for (const HtmlPage &html_page : html.pages()) { + EXPECT_TRUE(fs::is_regular_file(html_page.path)); + EXPECT_LT(0, fs::file_size(html_page.path)); + } +} + +INSTANTIATE_TEST_SUITE_P(all_test_files, pdf2htmlEXWrapperTests, + testing::ValuesIn(TestData::test_file_paths()), + [](const ::testing::TestParamInfo &info) { + std::string path = info.param; + internal::util::string::replace_all(path, "/", "_"); + internal::util::string::replace_all(path, "-", "_"); + internal::util::string::replace_all(path, "+", "_"); + internal::util::string::replace_all(path, ".", "_"); + internal::util::string::replace_all(path, " ", "_"); + internal::util::string::replace_all(path, "$", ""); + return path; + });