Commit | Line | Data |
---|---|---|
baee3e3a RK |
1 | /* |
2 | * This file is part of DisOrder. | |
3 | * Copyright (C) 2008 Richard Kettlewell | |
4 | * | |
e7eb3a27 | 5 | * This program is free software: you can redistribute it and/or modify |
baee3e3a | 6 | * it under the terms of the GNU General Public License as published by |
e7eb3a27 | 7 | * the Free Software Foundation, either version 3 of the License, or |
baee3e3a | 8 | * (at your option) any later version. |
e7eb3a27 RK |
9 | * |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
baee3e3a | 15 | * You should have received a copy of the GNU General Public License |
e7eb3a27 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
baee3e3a RK |
17 | */ |
18 | #include "test.h" | |
19 | #include "charset.h" | |
20 | ||
21 | static void test_charset(void) { | |
22 | check_string(any2any("UTF-8", "ISO-8859-1", "\xC2\xA3"), | |
23 | "\xA3"); | |
24 | check_string(any2any("ISO-8859-1", "UTF-8", "\xA3"), | |
25 | "\xC2\xA3"); | |
26 | fprintf(stderr, "Expect a conversion error:\n"); | |
27 | insist(any2any("UTF-8", "ISO-8859-1", "\xC2""a") == 0); | |
28 | ||
29 | #define EL "\xE2\x80\xA6" /* 2026 HORIZONTAL ELLIPSIS */ | |
30 | check_string(truncate_for_display("", 0), ""); | |
31 | check_string(truncate_for_display("", 1), ""); | |
32 | check_string(truncate_for_display("x", 1), "x"); | |
33 | check_string(truncate_for_display("xx", 1), EL); | |
34 | check_string(truncate_for_display("xx", 2), "xx"); | |
35 | check_string(truncate_for_display("xxx", 2), "x"EL); | |
36 | check_string(truncate_for_display("wibble", 6), "wibble"); | |
37 | check_string(truncate_for_display("wibble", 5), "wibb"EL); | |
38 | } | |
39 | ||
40 | TEST(charset); | |
41 | ||
42 | /* | |
43 | Local Variables: | |
44 | c-basic-offset:2 | |
45 | comment-column:40 | |
46 | fill-column:79 | |
47 | indent-tabs-mode:nil | |
48 | End: | |
49 | */ |