1 /* tst_tld.c --- Self tests for tld_*().
2 * Copyright (C) 2004 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #include <stringprep.h>
46 static const struct tld tld
[] = {
48 "Simple valid French domain",
51 {0x00E0, 0x00E2, 0x00E6},
54 "Simple invalid French domain",
57 {0x00E0, 0x00E2, 0x00E6, 0x4711, 0x0042},
66 const Tld_table
*tldtable
;
70 for (i
= 0; i
< sizeof (tld
) / sizeof (tld
[0]); i
++)
73 printf ("TLD entry %d: %s\n", i
, tld
[i
].name
);
78 ucs4print (tld
[i
].in
, tld
[i
].inlen
);
81 tldtable
= tld_default_table (tld
[i
].tld
, NULL
);
84 fail ("TLD entry %d tld_get_table (%s)\n", i
, tld
[i
].tld
);
90 rc
= tld_check_4t (tld
[i
].in
, tld
[i
].inlen
, &errpos
, tldtable
);
93 fail ("TLD entry %d failed: %d\n", i
, rc
);
100 printf ("returned %d expected %d\n", rc
, tld
[i
].rc
);
104 fail ("TLD entry %d failed\n", i
);
108 else if (rc
== TLD_INVALID
)
111 printf ("returned errpos %d expected errpos %d\n",
112 errpos
, tld
[i
].errpos
);
114 if (tld
[i
].errpos
!= errpos
)
116 fail ("TLD entry %d failed because errpos %d != %d\n", i
,
117 tld
[i
].errpos
, errpos
);