configure: Improve detection of ibtool
[vlc.git] / src / test / xmlent.c
blob46c04bb006023917e861ffd031144a3b27c123fc
1 /*****************************************************************************
2 * xmlent.c: Test for XML entities
3 *****************************************************************************
4 * Copyright (C) 2006, 2008 Rémi Denis-Courmont
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
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 Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
21 #ifdef HAVE_CONFIG_H
22 # include "config.h"
23 #endif
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
29 #include <vlc_common.h>
30 #include <vlc_strings.h>
32 static void decode (const char *in, const char *out)
34 char buf[strlen (in) + 1];
36 printf ("\"%s\" -> \"%s\" ?\n", in, out);
37 strcpy (buf, in);
38 vlc_xml_decode (buf);
40 if (strcmp (buf, out))
42 printf (" ERROR: got \"%s\"\n", buf);
43 exit (2);
47 static void encode (const char *in, const char *out)
49 char *buf;
51 printf ("\"%s\" -> \"%s\" ?\n", in, out);
52 buf = vlc_xml_encode (in);
54 if (buf == NULL)
56 puts(" ERROR: got NULL");
57 exit(2);
60 if (strcmp (buf, out))
62 printf (" ERROR: got \"%s\"\n", buf);
63 exit (2);
65 free (buf);
68 int main (void)
70 (void)setvbuf (stdout, NULL, _IONBF, 0);
71 decode ("This should not be modified 1234",
72 "This should not be modified 1234");
74 decode ("R&eacute;mi&nbsp;Fran&ccedil;ois&nbsp;&amp;&nbsp;&Eacute;mile",
75 "Rémi François & Émile");
76 decode ("R&#233;mi&nbsp;Fran&#231;ois&nbsp;&amp;&nbsp;&#201;mile",
77 "Rémi François & Émile");
78 decode ("R&#xe9;mi&nbsp;Fran&#xe7;ois&nbsp;&amp;&nbsp;&#xc9;mile",
79 "Rémi François & Émile");
80 decode ("R&#xE9;mi&nbsp;Fran&#xE7;ois&nbsp;&amp;&nbsp;&#xC9;mile",
81 "Rémi François & Émile");
83 decode ("", "");
85 /* tests with invalid input */
86 decode ("&<\"'", "&<\"'");
87 decode ("&oelig", "&oelig");
89 encode ("", "");
90 encode ("a'àc\"çe&én<ño>ö1:", "a&#39;àc&quot;çe&amp;én&lt;ño&gt;ö1:");
91 encode ("\xC2\x81\xC2\x85", "&#129;\xC2\x85");
92 encode (" \t\r\n", " \t\r\n");
94 return 0;