|
| 1 | +/* |
| 2 | + ------------------------------------------------------------------------------- |
| 3 | + This file is part of the Private Message Database test suite. |
| 4 | + Copyright (C) 2025 Dirk Stolle |
| 5 | +
|
| 6 | + This program is free software: you can redistribute it and/or modify |
| 7 | + it under the terms of the GNU General Public License as published by |
| 8 | + the Free Software Foundation, either version 3 of the License, or |
| 9 | + (at your option) any later version. |
| 10 | +
|
| 11 | + This program is distributed in the hope that it will be useful, |
| 12 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | + GNU General Public License for more details. |
| 15 | +
|
| 16 | + You should have received a copy of the GNU General Public License |
| 17 | + along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | + ------------------------------------------------------------------------------- |
| 19 | +*/ |
| 20 | + |
| 21 | +#include "../locate_catch.hpp" |
| 22 | +#include <filesystem> |
| 23 | +#include "../../code/html_generation.hpp" |
| 24 | + |
| 25 | +TEST_CASE("HTML generation") |
| 26 | +{ |
| 27 | + SECTION("generateHtmlFiles") |
| 28 | + { |
| 29 | + FolderMap fm; |
| 30 | + MessageDatabase mdb; |
| 31 | + |
| 32 | + PrivateMessage pm; |
| 33 | + pm.setDatestamp("2007-06-14 12:34"); |
| 34 | + pm.setTitle("This is the title"); |
| 35 | + pm.setFromUser("Hermes"); |
| 36 | + pm.setFromUserID(234); |
| 37 | + pm.setToUser("Poseidon"); |
| 38 | + pm.setMessage("This is a [b]bold[/b] text."); |
| 39 | + |
| 40 | + fm.add(pm.getHash(), "Inbox"); |
| 41 | + mdb.addMessage(pm); |
| 42 | + |
| 43 | + HTMLOptions options; |
| 44 | + options.standard = HTMLStandard::HTML4_01; |
| 45 | + |
| 46 | + std::filesystem::path html_path = std::filesystem::temp_directory_path() / "pmdb_test_html_directory"; |
| 47 | + |
| 48 | + int exit_code = generateHtmlFiles(mdb, fm, options, html_path.string()); |
| 49 | + REQUIRE( exit_code == 0 ); |
| 50 | + |
| 51 | + auto message_path = html_path / (pm.getHash().toHexString() + ".html"); |
| 52 | + REQUIRE( std::filesystem::is_regular_file(message_path) ); |
| 53 | + |
| 54 | + auto folder_path = html_path / "folder_94835ea2fcf775cd77cb9c9cee01b5cbd9bc515467aab1215f48a5ade9ca5274.html"; |
| 55 | + REQUIRE( std::filesystem::is_regular_file(message_path) ); |
| 56 | + |
| 57 | + REQUIRE( std::filesystem::remove(message_path) ); |
| 58 | + REQUIRE( std::filesystem::remove(folder_path) ); |
| 59 | + REQUIRE( std::filesystem::remove(html_path) ); |
| 60 | + } |
| 61 | +} |
0 commit comments