2 * This file is part of DisOrder.
3 * Copyright (C) 2008 Richard Kettlewell
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 static void test_charset(void) {
24 check_string(any2any("UTF-8", "ISO-8859-1", "\xC2\xA3"),
26 check_string(any2any("ISO-8859-1", "UTF-8", "\xA3"),
28 fprintf(stderr, "Expect a conversion error:\n");
29 insist(any2any("UTF-8", "ISO-8859-1", "\xC2""a") == 0);
31 #define EL "\xE2\x80\xA6" /* 2026 HORIZONTAL ELLIPSIS */
32 check_string(truncate_for_display("", 0), "");
33 check_string(truncate_for_display("", 1), "");
34 check_string(truncate_for_display("x", 1), "x");
35 check_string(truncate_for_display("xx", 1), EL);
36 check_string(truncate_for_display("xx", 2), "xx");
37 check_string(truncate_for_display("xxx", 2), "x"EL);
38 check_string(truncate_for_display("wibble", 6), "wibble");
39 check_string(truncate_for_display("wibble", 5), "wibb"EL);