Branch data Line data Source code
1 : : /* tst_toutf8.c --- Self tests for UTF-8 conversion functions.
2 : : * Copyright (C) 2002-2013 Simon Josefsson
3 : : *
4 : : * This file is part of GNU Libidn.
5 : : *
6 : : * This program is free software: you can redistribute it and/or modify
7 : : * it under the terms of the GNU General Public License as published by
8 : : * the Free Software Foundation, either version 3 of the License, or
9 : : * (at your option) any later version.
10 : : *
11 : : * This program is distributed in the hope that it will be useful,
12 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 : : * GNU General Public License for more details.
15 : : *
16 : : * You should have received a copy of the GNU General Public License
17 : : * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 : : *
19 : : */
20 : :
21 : : #ifdef HAVE_CONFIG_H
22 : : # include "config.h"
23 : : #endif
24 : :
25 : : #include <stdio.h>
26 : : #include <stdlib.h>
27 : : #include <stdarg.h>
28 : : #include <string.h>
29 : :
30 : : #include <stringprep.h>
31 : :
32 : : #include "utils.h"
33 : :
34 : : void
35 : 1 : doit (void)
36 : : {
37 : : char *p;
38 : : const char *q;
39 : :
40 : 1 : q = stringprep_locale_charset ();
41 [ - + ]: 1 : if (q == NULL)
42 : 0 : fail ("FAIL: stringprep_locale_charset == NULL\n");
43 [ - + ]: 1 : if (debug)
44 : 0 : printf ("PASS: stringprep_locale_charset == %s\n", q);
45 : :
46 : 1 : p = stringprep_locale_to_utf8 ("foo");
47 [ + - ][ - + ]: 1 : if (!p || memcmp (p, "foo", 4) != 0)
48 : 0 : fail ("FAIL: stringprep_locale_to_utf8(\"foo\") == %s\n", p);
49 [ - + ]: 1 : if (debug)
50 : 0 : printf ("PASS: stringprep_locale_to_utf8(\"foo\") == %s\n", p);
51 : 1 : free (p);
52 : :
53 : 1 : p = stringprep_utf8_to_locale ("foo");
54 [ + - ][ - + ]: 1 : if (!p || memcmp (p, "foo", 4) != 0)
55 : 0 : fail ("FAIL: stringprep_utf8_to_locale(\"foo\") == %s\n", p);
56 [ - + ]: 1 : if (debug)
57 : 0 : printf ("PASS: stringprep_utf8_to_locale(\"foo\") == %s\n", p);
58 : 1 : free (p);
59 : 1 : }
|