summaryrefslogtreecommitdiff
path: root/gui/lang/tests
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@gmail.com>2025-05-23 14:04:27 +0200
committerFelix Morgner <felix.morgner@gmail.com>2025-05-23 14:04:27 +0200
commit5d8f799a1171f92054d4b45ba130cd7fdad0bd01 (patch)
tree0f51290b3a60d71d25d7a49b66d5bd54dd7a4156 /gui/lang/tests
parentc45004b73bb045328a724d1d860df6d1515af6d4 (diff)
downloadturns-5d8f799a1171f92054d4b45ba130cd7fdad0bd01.tar.xz
turns-5d8f799a1171f92054d4b45ba130cd7fdad0bd01.zip
app: prepare restructuring
Diffstat (limited to 'gui/lang/tests')
-rw-r--r--gui/lang/tests/intl_test_init.cpp26
-rw-r--r--gui/lang/tests/messages.cpp72
2 files changed, 98 insertions, 0 deletions
diff --git a/gui/lang/tests/intl_test_init.cpp b/gui/lang/tests/intl_test_init.cpp
new file mode 100644
index 0000000..5438179
--- /dev/null
+++ b/gui/lang/tests/intl_test_init.cpp
@@ -0,0 +1,26 @@
+#include <catch2/reporters/catch_reporter_event_listener.hpp>
+#include <catch2/reporters/catch_reporter_registrars.hpp>
+
+#include <libintl.h>
+
+#include <clocale>
+
+namespace turns::lang::tests
+{
+
+ struct intl_test_init : Catch::EventListenerBase
+ {
+ using Catch::EventListenerBase::EventListenerBase;
+
+ auto testRunStarting(Catch::TestRunInfo const &) -> void override
+ {
+ setlocale(LC_ALL, "");
+ bindtextdomain("turns", TESTLOCALEDIR);
+ bind_textdomain_codeset("turns", "UTF-8");
+ textdomain("turns");
+ }
+ };
+
+ CATCH_REGISTER_LISTENER(intl_test_init);
+
+} // namespace turns::lang::tests \ No newline at end of file
diff --git a/gui/lang/tests/messages.cpp b/gui/lang/tests/messages.cpp
new file mode 100644
index 0000000..cecb038
--- /dev/null
+++ b/gui/lang/tests/messages.cpp
@@ -0,0 +1,72 @@
+#include "turns/lang/messages.hpp"
+
+#include <catch2/catch_test_macros.hpp>
+#include <catch2/generators/catch_generators.hpp>
+
+#include <libintl.h>
+
+#include <clocale>
+#include <format>
+#include <string>
+
+namespace turns::lang::tests
+{
+
+ TEST_CASE("Translated messages")
+ {
+ auto locale = GENERATE("de_CH.UTF-8", "de_DE.UTF-8", "de_AT.UTF-8");
+ setlocale(LC_ALL, locale);
+
+ SECTION(std::format("Locale '{}'", locale))
+ {
+ auto message = GENERATE(add_participant,
+ cancel,
+ clear,
+ delete_participant,
+ disposition,
+ disposition_colors,
+ edit_participant,
+ end_turn_order,
+ finish,
+ flow,
+ friendly,
+ hostile,
+ main_menu,
+ mark_as_defeated,
+ // a better solution is required to test the following entry:
+ // name,
+ new_turn_order_file_name,
+ next_participant,
+ no_active_turn_order,
+ open,
+ preferences,
+ preferences_mnemonic,
+ previous_participant,
+ priority,
+ priority_number,
+ question_clear_turn_order,
+ quit,
+ reset,
+ save,
+ save_as,
+ saving_failed_format,
+ secret,
+ skip_defeated,
+ start_turn_order,
+ stop,
+ stop_and_clear,
+ stop_turn_order,
+ successfully_opened_format,
+ successfully_saved_format,
+ round_number,
+ turns,
+ turns_files);
+
+ SECTION(std::format("has a translation for '{}'", message))
+ {
+ REQUIRE(std::string{gettext(message)} != message);
+ }
+ }
+ }
+
+} // namespace turns::lang::tests \ No newline at end of file