|
4 | 4 | #include <variant>
|
5 | 5 |
|
6 | 6 | #include "oicompare.hh"
|
| 7 | +#include "translations.hh" |
7 | 8 |
|
8 | 9 | namespace oicompare::tests
|
9 | 10 | {
|
@@ -53,6 +54,14 @@ struct test_case
|
53 | 54 | std::string_view second;
|
54 | 55 | };
|
55 | 56 |
|
| 57 | +struct test_translation_case |
| 58 | +{ |
| 59 | + oicompare::translations::translation translator; |
| 60 | + std::string_view first; |
| 61 | + std::string_view second; |
| 62 | + std::string_view result; |
| 63 | +}; |
| 64 | + |
56 | 65 | #define REP10(X) X X X X X X X X X X
|
57 | 66 | #define REP100(X) REP10 (REP10 (X))
|
58 | 67 |
|
@@ -102,6 +111,41 @@ constexpr auto test_cases = std::array{
|
102 | 111 | REP100 ("A"sv) "B"sv, REP100 ("A"sv) " B"sv},
|
103 | 112 | };
|
104 | 113 |
|
| 114 | +constexpr auto test_translation_cases = std::array{ |
| 115 | + test_translation_case{ |
| 116 | + translations::english_translation<translations::kind::full>::print, |
| 117 | + ""sv, ""sv, "OK\n"sv}, |
| 118 | + test_translation_case{ |
| 119 | + translations::english_translation<translations::kind::full>::print, |
| 120 | + "ABC"sv, "ABC"sv, "OK\n"sv}, |
| 121 | + test_translation_case{ |
| 122 | + translations::english_translation<translations::kind::full>::print, |
| 123 | + "ABC\nDEF\n"sv, "ABC\nABC\n"sv, |
| 124 | + "WRONG: line 2: expected \"DEF\", got \"ABC\"\n"sv}, |
| 125 | + test_translation_case{ |
| 126 | + translations::english_translation<translations::kind::terse>::print, |
| 127 | + "ABC"sv, "AB"sv, "WRONG\n"sv}, |
| 128 | + test_translation_case{translations::english_translation< |
| 129 | + translations::kind::abbreviated>::print, |
| 130 | + "25"sv, "2"sv, |
| 131 | + "WRONG: line 1: expected \"25\", got \"2\"\n"sv}, |
| 132 | + test_translation_case{ |
| 133 | + translations::english_translation< |
| 134 | + translations::kind::abbreviated>::print, |
| 135 | + "10001"sv REP100 ("0"sv), "10000"sv REP100 ("0"sv), |
| 136 | + "WRONG: line 1: expected \"1000100000000000000000000000000000000000000000000000000000000000000000000000000000000…\", got \"1000000000000000000000000000000000000000000000000000000000000000000000000000000000000…\"\n"sv}, |
| 137 | + test_translation_case{ |
| 138 | + translations::english_translation< |
| 139 | + translations::kind::abbreviated>::print, |
| 140 | + "1"sv REP100 ("0"sv) "0"sv REP100 ("0"sv), |
| 141 | + "1"sv REP100 ("0"sv) "1"sv REP100 ("0"sv), |
| 142 | + "WRONG: line 1: expected \"1000000000000000000000000000000000000000000000000000000000000000000000000000000…000…\", got \"1000000000000000000000000000000000000000000000000000000000000000000000000000000…010…\"\n"sv}, |
| 143 | + test_translation_case{ |
| 144 | + translations::english_translation< |
| 145 | + translations::kind::abbreviated>::print, |
| 146 | + "1"sv REP100 ("0"sv) "0"sv, "1"sv REP100 ("0"sv) "1"sv, |
| 147 | + "WRONG: line 1: expected \"10000000000000000000000000000000000000000000000000000000000000000000000000000000000…00\", got \"10000000000000000000000000000000000000000000000000000000000000000000000000000000000…01\"\n"sv}}; |
| 148 | + |
105 | 149 | #undef REP100
|
106 | 150 | #undef REP10
|
107 | 151 |
|
|
0 commit comments