@@ -26,36 +26,55 @@ TEST_CASE("HTML generation")
2626{
2727 SECTION (" generateHtmlFiles" )
2828 {
29- FolderMap fm;
30- MessageDatabase mdb;
29+ SECTION (" single private message" )
30+ {
31+ FolderMap fm;
32+ MessageDatabase mdb;
3133
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." );
34+ PrivateMessage pm;
35+ pm.setDatestamp (" 2007-06-14 12:34" );
36+ pm.setTitle (" This is the title" );
37+ pm.setFromUser (" Hermes" );
38+ pm.setFromUserID (234 );
39+ pm.setToUser (" Poseidon" );
40+ pm.setMessage (" This is a [b]bold[/b] text." );
3941
40- fm.add (pm.getHash (), " Inbox" );
41- mdb.addMessage (pm);
42+ fm.add (pm.getHash (), " Inbox" );
43+ mdb.addMessage (pm);
4244
43- HTMLOptions options;
44- options.standard = HTMLStandard::HTML4_01;
45+ HTMLOptions options;
46+ options.standard = HTMLStandard::HTML4_01;
4547
46- std::filesystem::path html_path = std::filesystem::temp_directory_path () / " pmdb_test_html_directory" ;
48+ std::filesystem::path html_path = std::filesystem::temp_directory_path () / " pmdb_test_html_directory" ;
4749
48- int exit_code = generateHtmlFiles (mdb, fm, options, html_path.string ());
49- REQUIRE ( exit_code == 0 );
50+ int exit_code = generateHtmlFiles (mdb, fm, options, html_path.string ());
51+ REQUIRE ( exit_code == 0 );
5052
51- auto message_path = html_path / (pm.getHash ().toHexString () + " .html" );
52- REQUIRE ( std::filesystem::is_regular_file (message_path) );
53+ auto message_path = html_path / (pm.getHash ().toHexString () + " .html" );
54+ REQUIRE ( std::filesystem::is_regular_file (message_path) );
5355
54- auto folder_path = html_path / " folder_94835ea2fcf775cd77cb9c9cee01b5cbd9bc515467aab1215f48a5ade9ca5274.html" ;
55- REQUIRE ( std::filesystem::is_regular_file (message_path) );
56+ auto folder_path = html_path / " folder_94835ea2fcf775cd77cb9c9cee01b5cbd9bc515467aab1215f48a5ade9ca5274.html" ;
57+ REQUIRE ( std::filesystem::is_regular_file (message_path) );
5658
57- REQUIRE ( std::filesystem::remove (message_path) );
58- REQUIRE ( std::filesystem::remove (folder_path) );
59- REQUIRE ( std::filesystem::remove (html_path) );
59+ REQUIRE ( std::filesystem::remove (message_path) );
60+ REQUIRE ( std::filesystem::remove (folder_path) );
61+ REQUIRE ( std::filesystem::remove (html_path) );
62+ }
63+
64+ SECTION (" no private message" )
65+ {
66+ FolderMap fm;
67+ MessageDatabase mdb;
68+
69+ HTMLOptions options;
70+ options.standard = HTMLStandard::HTML4_01;
71+
72+ std::filesystem::path html_path = std::filesystem::temp_directory_path () / " pmdb_test_html_directory_none" ;
73+
74+ int exit_code = generateHtmlFiles (mdb, fm, options, html_path.string ());
75+ REQUIRE ( exit_code == 0 );
76+
77+ REQUIRE_FALSE ( std::filesystem::exists (html_path) );
78+ }
6079 }
6180}
0 commit comments