| 1 | /** |
| 2 | * Copyright (C) 2008 by Dominik Seichter <[email protected]> |
| 3 | * Copyright (C) 2021 by Francesco Pretto <[email protected]> |
| 4 | * |
| 5 | * Licensed under GNU Library General Public 2.0 or later. |
| 6 | * Some rights reserved. See COPYING, AUTHORS. |
| 7 | */ |
| 8 | |
| 9 | #include <PdfTest.h> |
| 10 | |
| 11 | using namespace std; |
| 12 | using namespace PoDoFo; |
| 13 | |
| 14 | /** This class tests the basic integer and other types PoDoFo uses |
| 15 | * to make sure they satisfy its requirements for behaviour, size, etc. |
| 16 | */ |
| 17 | |
| 18 | TEST_CASE("BasicTypeTest") |
| 19 | { |
| 20 | REQUIRE(std::numeric_limits<uint64_t>::max() >= 9999999999); |
| 21 | } |
| 22 | |
| 23 | TEST_CASE("ErrorFilePath") |
| 24 | { |
| 25 | try |
| 26 | { |
| 27 | PdfObject test; |
| 28 | test.GetString(); |
| 29 | } |
| 30 | catch (const PdfError& err) |
| 31 | { |
| 32 | auto path = err.GetCallStack().front().GetFilePath(); |
| 33 | REQUIRE(fs::u8path(path) == fs::u8path("main") / "PdfVariant.cpp"); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | TEST_CASE("TestMetadataSet") |
| 38 | { |
| 39 | PdfMemDocument doc; |
| 40 | auto& metadata = doc.GetMetadata(); |
| 41 | metadata.SetTitle(PdfString("TestTitle")); |
| 42 | REQUIRE(metadata.GetTitle()->GetString() == "TestTitle"); |
| 43 | metadata.SetTitle(PdfString("TestTitle2")); |
| 44 | REQUIRE(metadata.GetTitle()->GetString() == "TestTitle2"); |
| 45 | metadata.SetTitle(nullptr); |
| 46 | REQUIRE(metadata.GetTitle() == nullptr); |
| 47 | } |
| 48 | |
| 49 | TEST_CASE("TestGetDocKeywords") |
| 50 | { |
| 51 | PdfMemDocument doc; |
| 52 | vector<string> keywords = { "one", "two", "three" }; |
| 53 | doc.GetMetadata().SetKeywords(keywords); |
| 54 | REQUIRE(keywords == doc.GetMetadata().GetKeywords()); |
| 55 | } |