summaryrefslogtreecommitdiff
path: root/lang/tests/messages.cpp
blob: 33c42027d2445ea850ac5f8082f19a3abfb577ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "turns/lang/messages.hpp"

#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>

#include <libintl.h>

#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,
                              clear,
                              disposition,
                              delete_participant,
                              edit_participant,
                              end_turn_order,
                              finish,
                              main_menu,
                              mark_as_defeated,
                              // a better solution is required to test the following entry:
                              // name,
                              next_participant,
                              no_active_turn_order,
                              previous_participant,
                              priority,
                              priority_number,
                              quit,
                              start_turn_order,
                              round_number,
                              turns);

      SECTION(std::format("has a translation for '{}'", message))
      {
        REQUIRE(std::string{gettext(message)} != message);
      }
    }
  }

}  // namespace turns::lang::tests