*** empty log message ***
[libidn.git] / tests / tst_strerror.c
blobfa9b30017deac409a3b843901e3479d7e9bbc583
1 /* tst_strerror.c --- Self tests for *_strerror().
2 * Copyright (C) 2004, 2005, 2006, 2007 Simon Josefsson.
4 * This file is part of GNU Libidn.
6 * GNU Libidn 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 2 of the License, or
9 * (at your option) any later version.
11 * GNU Libidn 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.
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Libidn; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 #ifdef HAVE_CONFIG_H
23 # include "config.h"
24 #endif
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <stdarg.h>
29 #include <string.h>
31 #include <idna.h>
32 #include <pr29.h>
33 #include <punycode.h>
34 #include <stringprep.h>
35 #include <tld.h>
37 #include "utils.h"
39 #define SUCCESS "Success"
40 #define UNKNOWN "Unknown error"
42 void
43 doit (void)
45 const char *p;
47 /* Test success. */
49 p = idna_strerror (0);
50 if (strcmp (p, SUCCESS) != 0)
51 fail ("idna_strerror (0) failed: %s\n", p);
52 if (debug)
53 printf ("idna_strerror (0) OK\n");
55 p = pr29_strerror (0);
56 if (strcmp (p, SUCCESS) != 0)
57 fail ("pr29_strerror (0) failed: %s\n", p);
58 if (debug)
59 printf ("pr29_strerror (0) OK\n");
61 p = punycode_strerror (0);
62 if (strcmp (p, SUCCESS) != 0)
63 fail ("punycode_strerror (0) failed: %s\n", p);
64 if (debug)
65 printf ("punycode_strerror (0) OK\n");
67 p = stringprep_strerror (0);
68 if (strcmp (p, SUCCESS) != 0)
69 fail ("stringprep_strerror (0) failed: %s\n", p);
70 if (debug)
71 printf ("stringprep_strerror (0) OK\n");
73 p = tld_strerror (0);
74 if (strcmp (p, SUCCESS) != 0)
75 fail ("tld_strerror (0) failed: %s\n", p);
76 if (debug)
77 printf ("tld_strerror (0) OK\n");
79 /* Test unknown error. */
81 p = idna_strerror (42);
82 if (strcmp (p, UNKNOWN) != 0)
83 fail ("idna_strerror (42) failed: %s\n", p);
84 if (debug)
85 printf ("idna_strerror (42) OK\n");
87 p = pr29_strerror (42);
88 if (strcmp (p, UNKNOWN) != 0)
89 fail ("pr29_strerror (42) failed: %s\n", p);
90 if (debug)
91 printf ("pr29_strerror (42) OK\n");
93 p = punycode_strerror (42);
94 if (strcmp (p, UNKNOWN) != 0)
95 fail ("punycode_strerror (42) failed: %s\n", p);
96 if (debug)
97 printf ("punycode_strerror (42) OK\n");
99 p = stringprep_strerror (42);
100 if (strcmp (p, UNKNOWN) != 0)
101 fail ("stringprep_strerror (42) failed: %s\n", p);
102 if (debug)
103 printf ("stringprep_strerror (42) OK\n");
105 p = tld_strerror (42);
106 if (strcmp (p, UNKNOWN) != 0)
107 fail ("tld_strerror (42) failed: %s\n", p);
108 if (debug)
109 printf ("tld_strerror (42) OK\n");