l10n: Update translation catalogues
[libisds.git] / test / offline / utf82locale.c
blob415e1bba4f26968345f2c5da9a9ffca1c4d0e245
1 #include "../test.h"
2 #include "utils.h"
3 #include <locale.h>
5 static int prepare_locale(_Bool utf8) {
6 char *old_locale;
8 if (utf8) {
9 old_locale = setlocale(LC_ALL, "en_US.UTF-8");
10 if (old_locale != NULL) return 0;
12 old_locale = setlocale(LC_ALL, "cs_CZ.UTF-8");
13 if (old_locale != NULL) return 0;
14 } else {
15 old_locale = setlocale(LC_ALL, "C");
16 if (old_locale != NULL) return 0;
19 return -1;
22 static int test_utf82locale(const void *input, const void *correct) {
23 void *output = NULL;
25 output = _isds_utf82locale(input);
26 TEST_DESTRUCTOR(free, output);
28 TEST_STRING_DUPLICITY(correct, output);
30 PASS_TEST;
34 int main(void) {
35 INIT_TEST("utf8locale");
37 if (prepare_locale(1))
38 ABORT_UNIT("Could not set any UTF-8 locale");
40 TEST("NULL input", test_utf82locale, NULL, NULL);
41 TEST("Empty string", test_utf82locale, "", "");
42 TEST("ASCII text", test_utf82locale, "lazy fox", "lazy fox");
43 TEST("non-ASCII text in UTF-8 locale", test_utf82locale, "Šíleně žluťoučký",
44 "Šíleně žluťoučký");
45 TEST("OTP message in UTF-8 locale", test_utf82locale,
46 "Jednorázový kód odeslán.", "Jednorázový kód odeslán.");
48 if (prepare_locale(0))
49 ABORT_UNIT("Could not set C locale");
51 TEST("non-ASCII text in C locale", test_utf82locale, "Šíleně žluťoučký", NULL);
53 SUM_TEST();