etc/services - sync with NetBSD-8
[minix.git] / external / bsd / bind / dist / contrib / idn / idnkit-1.0-src / lib / tests / resconf.tsy
blob9f2ac9571d012a34a77dd21c0ccb5302a8251114
1 #ifndef lint
2 static char *rcsid = "Id: resconf.tsy,v 1.1 2003/06/04 00:27:00 marka Exp ";
3 #endif
5 /*
6  * Copyright (c) 2002 Japan Network Information Center.
7  * All rights reserved.
8  *  
9  * By using this file, you agree to the terms and conditions set forth bellow.
10  * 
11  *                      LICENSE TERMS AND CONDITIONS 
12  * 
13  * The following License Terms and Conditions apply, unless a different
14  * license is obtained from Japan Network Information Center ("JPNIC"),
15  * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
16  * Chiyoda-ku, Tokyo 101-0047, Japan.
17  * 
18  * 1. Use, Modification and Redistribution (including distribution of any
19  *    modified or derived work) in source and/or binary forms is permitted
20  *    under this License Terms and Conditions.
21  * 
22  * 2. Redistribution of source code must retain the copyright notices as they
23  *    appear in each source code file, this License Terms and Conditions.
24  * 
25  * 3. Redistribution in binary form must reproduce the Copyright Notice,
26  *    this License Terms and Conditions, in the documentation and/or other
27  *    materials provided with the distribution.  For the purposes of binary
28  *    distribution the "Copyright Notice" refers to the following language:
29  *    "Copyright (c) 2000-2002 Japan Network Information Center.  All rights reserved."
30  * 
31  * 4. The name of JPNIC may not be used to endorse or promote products
32  *    derived from this Software without specific prior written approval of
33  *    JPNIC.
34  * 
35  * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
36  *    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
37  *    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
38  *    PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL JPNIC BE LIABLE
39  *    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
40  *    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
41  *    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
42  *    BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
43  *    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
44  *    OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
45  *    ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
46  */
48 #include <stddef.h>
49 #include <stdio.h>
50 #include <stdlib.h>
51 #include <string.h>
52 #include <stdarg.h>
53 #include <idn/resconf.h>
54 #include <idn/converter.h>
55 #include <idn/log.h>
57 #include "setenv.h"
58 #include "testutil.h"
60 #define CONF_FILENAME           "test.conf"
61 #define MAP_FILENAME            "test.map"
63 //--------------------------------------------------------------------
64 // Setups and Teardowns.
65 //--------------------------------------------------------------------
67 //# SETUP
68 //      group: generic-init
70         idn_result_t r;
71         idn_resconf_t ctx = NULL;
73         setenv("IDN_LOCAL_CODESET", "UTF-8", 1);
75         r = idn_resconf_initialize();
76         ASSERT_RESULT(r, idn_success);
78         r = idn_resconf_create(&ctx);
79         ASSERT_RESULT(r, idn_success);
82 //# TEARDOWN
83 //      group: generic-init
85         if (ctx != NULL)
86                 idn_resconf_destroy(ctx);
87         remove(CONF_FILENAME);
88         remove(MAP_FILENAME);
91 //# SETUP
92 //      group: set-defaults
94         r = idn_resconf_setdefaults(ctx);
95         ASSERT_RESULT(r, idn_success);
98 //# TEARDOWN
99 //      group: set-defaults
103 //# SETUP
104 //      group: quiet
106         int saved_log_level;
108         saved_log_level = idn_log_getlevel();
109         idn_log_setlevel(idn_log_level_fatal);
112 //# TEARDOWN
113 //      group: quiet
115         idn_log_setlevel(saved_log_level);
118 //# SETUP
119 //      group: delimitermap_ctx
121         idn_delimitermap_t delimitermap_ctx1 = NULL;
122         idn_delimitermap_t delimitermap_ctx2 = NULL;
125 //# TEARDOWN
126 //      group: delimitermap_ctx
128         if (delimitermap_ctx1 != NULL) 
129                 idn_delimitermap_destroy(delimitermap_ctx1);
130         if (delimitermap_ctx2 != NULL) 
131                 idn_delimitermap_destroy(delimitermap_ctx2);
134 //# SETUP
135 //      group: idnconverter_ctx
137         idn_converter_t idnconverter_ctx1 = NULL;
138         idn_converter_t idnconverter_ctx2 = NULL;
141 //# TEARDOWN
142 //      group: idnconverter_ctx
144         if (idnconverter_ctx1 != NULL) 
145                 idn_converter_destroy(idnconverter_ctx1);
146         if (idnconverter_ctx2 != NULL) 
147                 idn_converter_destroy(idnconverter_ctx2);
150 //# SETUP
151 //      group: localconverter_ctx
153         idn_converter_t localconverter_ctx1 = NULL;
154         idn_converter_t localconverter_ctx2 = NULL;
157 //# TEARDOWN
158 //      group: localconverter_ctx
160         if (localconverter_ctx1 != NULL) 
161                 idn_converter_destroy(localconverter_ctx1);
162         if (localconverter_ctx2 != NULL) 
163                 idn_converter_destroy(localconverter_ctx2);
166 //# SETUP
167 //      group: auxidnconverter_ctx
169         idn_converter_t auxidnconverter_ctx1 = NULL;
170         idn_converter_t auxidnconverter_ctx2 = NULL;
173 //# TEARDOWN
174 //      group: auxidnconverter_ctx
176         if (auxidnconverter_ctx1 != NULL) 
177                 idn_converter_destroy(auxidnconverter_ctx1);
178         if (auxidnconverter_ctx2 != NULL) 
179                 idn_converter_destroy(auxidnconverter_ctx2);
182 //# SETUP
183 //      group: mapselector_ctx
185         idn_mapselector_t mapselector_ctx1 = NULL;
186         idn_mapselector_t mapselector_ctx2 = NULL;
189 //# TEARDOWN
190 //      group: mapselector_ctx
192         if (mapselector_ctx1 != NULL) 
193                 idn_mapselector_destroy(mapselector_ctx1);
194         if (mapselector_ctx2 != NULL) 
195                 idn_mapselector_destroy(mapselector_ctx2);
198 //# SETUP
199 //      group: mapper_ctx
201         idn_mapper_t mapper_ctx1 = NULL;
202         idn_mapper_t mapper_ctx2 = NULL;
205 //# TEARDOWN
206 //      group: mapper_ctx
208         if (mapper_ctx1 != NULL) 
209                 idn_mapper_destroy(mapper_ctx1);
210         if (mapper_ctx2 != NULL) 
211                 idn_mapper_destroy(mapper_ctx2);
214 //# SETUP
215 //      group: normalizer_ctx
217         idn_normalizer_t normalizer_ctx1 = NULL;
218         idn_normalizer_t normalizer_ctx2 = NULL;
221 //# TEARDOWN
222 //      group: normalizer_ctx
224         if (normalizer_ctx1 != NULL) 
225                 idn_normalizer_destroy(normalizer_ctx1);
226         if (normalizer_ctx2 != NULL) 
227                 idn_normalizer_destroy(normalizer_ctx2);
230 //# SETUP
231 //      group: prohibitchecker_ctx
233         idn_checker_t prohibitchecker_ctx1 = NULL;
234         idn_checker_t prohibitchecker_ctx2 = NULL;
237 //# TEARDOWN
238 //      group: prohibitchecker_ctx
240         if (prohibitchecker_ctx1 != NULL) 
241                 idn_checker_destroy(prohibitchecker_ctx1);
242         if (prohibitchecker_ctx2 != NULL) 
243                 idn_checker_destroy(prohibitchecker_ctx2);
246 //# SETUP
247 //      group: unassignedchecker_ctx
249         idn_checker_t unassignedchecker_ctx1 = NULL;
250         idn_checker_t unassignedchecker_ctx2 = NULL;
253 //# TEARDOWN
254 //      group: unassignedchecker_ctx
256         if (unassignedchecker_ctx1 != NULL) 
257                 idn_checker_destroy(unassignedchecker_ctx1);
258         if (unassignedchecker_ctx2 != NULL) 
259                 idn_checker_destroy(unassignedchecker_ctx2);
262 //# SETUP
263 //      group: bidichecker_ctx
265         idn_checker_t bidichecker_ctx1 = NULL;
266         idn_checker_t bidichecker_ctx2 = NULL;
269 //# TEARDOWN
270 //      group: bidichecker_ctx
272         if (bidichecker_ctx1 != NULL) 
273                 idn_checker_destroy(bidichecker_ctx1);
274         if (bidichecker_ctx2 != NULL) 
275                 idn_checker_destroy(bidichecker_ctx2);
278 //--------------------------------------------------------------------
279 // Testcases.
280 //--------------------------------------------------------------------
282 //# TESTCASE
283 //      title: call create() without initialization.
284 //--
285 //      This must be the first test case.
287         idn_result_t r;
288         idn_resconf_t ctx = NULL;
290         r = idn_resconf_create(&ctx);
291         ASSERT_RESULT(r, idn_failure);
293         if (ctx != NULL)
294                 idn_resconf_destroy(ctx);
297 //# TESTCASE
298 //      title: call initialize() twice.
301         idn_result_t r;
303         r = idn_resconf_initialize();
304         ASSERT_RESULT(r, idn_success);
306         r = idn_resconf_initialize();
307         ASSERT_RESULT(r, idn_success);
310 //# TESTCASE
311 //      title: call create()
313         idn_result_t r;
314         idn_resconf_t ctx;
316         r = idn_resconf_initialize();
317         ASSERT_RESULT(r, idn_success);
319         r = idn_resconf_create(&ctx);
320         ASSERT_RESULT(r, idn_success);
322         if (ctx != NULL)
323                 idn_resconf_destroy(ctx);
326 //# TESTCASE
327 //      title: load file (idn-encoding)
328 //      group: generic-init
330         const char *idn_encoding;
332         create_conf_file(CONF_FILENAME, 0,
333                          "idn-encoding  Punycode",
334                          NULL);
335         r = idn_resconf_loadfile(ctx, CONF_FILENAME);
336         ASSERT_RESULT(r, idn_success);
339 //# TESTCASE
340 //      title: load file (nameprep)
341 //      group: generic-init
343         const char *idn_encoding;
345         create_conf_file(CONF_FILENAME, 0,
346                          "nameprep      " IDN_NAMEPREP_CURRENT,
347                          NULL);
348         r = idn_resconf_loadfile(ctx, CONF_FILENAME);
349         ASSERT_RESULT(r, idn_success);
352 //# TESTCASE
353 //      title: load file (idn-encoding & nameprep)
354 //      group: generic-init
356         const char *idn_encoding;
358         create_conf_file(CONF_FILENAME, 0,
359                          "idn-encoding  Punycode",
360                          "nameprep      " IDN_NAMEPREP_CURRENT,
361                          NULL);
362         r = idn_resconf_loadfile(ctx, CONF_FILENAME);
363         ASSERT_RESULT(r, idn_success);
366 //# TESTCASE
367 //      title: load file (empty)
368 //      group: generic-init
370         const char *idn_encoding;
372         create_conf_file(CONF_FILENAME, 0,
373                          NULL);
374         r = idn_resconf_loadfile(ctx, CONF_FILENAME);
375         ASSERT_RESULT(r, idn_success);
378 //# TESTCASE
379 //      title: load file (local-map filemap)
380 //      group: generic-init
382         const char *idn_encoding;
384         create_conf_file(CONF_FILENAME, 0,
385                          "local-map     .jp     filemap:" MAP_FILENAME,
386                          NULL);
387         create_conf_file(MAP_FILENAME, 0,
388                          "2212; FF0D",
389                          NULL);
391         r = idn_resconf_loadfile(ctx, CONF_FILENAME);
392         ASSERT_RESULT(r, idn_success);
395 //# TESTCASE
396 //      title: load file (local-map nameprep)
397 //      group: generic-init
399         const char *idn_encoding;
401         create_conf_file(CONF_FILENAME, 0,
402                          "local-map     .jp     " IDN_NAMEPREP_CURRENT,
403                          NULL);
404         r = idn_resconf_loadfile(ctx, CONF_FILENAME);
405         ASSERT_RESULT(r, idn_success);
408 //# TESTCASE
409 //      title: set defaults
410 //      group: generic-init set-defaults
414 //# TESTCASE
415 //      title: load file (no file)
416 //      group: generic-init
418         r = idn_resconf_loadfile(ctx, "no-such-file");
419         ASSERT_RESULT(r, idn_nofile);
422 //# TESTCASE
423 //      title: load file (empty file name)
424 //      group: generic-init
426         r = idn_resconf_loadfile(ctx, "");
427         ASSERT_RESULT(r, idn_nofile);
430 //# TESTCASE
431 //      title: load file (unknown command)
432 //      group: generic-init quiet
434         create_conf_file(CONF_FILENAME, 0,
435                          "unknown-command       " IDN_NAMEPREP_CURRENT,
436                          NULL);
437         r = idn_resconf_loadfile(ctx, CONF_FILENAME);
438         ASSERT_RESULT(r, idn_invalid_syntax);
441 //# TESTCASE
442 //      title: load file (no newline at the end of file)
443 //      group: generic-init quiet
445         create_conf_file(CONF_FILENAME, CONF_NO_EOF_NEWLINE,
446                          "nameprep      " IDN_NAMEPREP_CURRENT,
447                          NULL);
448         r = idn_resconf_loadfile(ctx, CONF_FILENAME);
449         ASSERT_RESULT(r, idn_success);
452 //# TESTCASE
453 //      title: load file (too long line)
454 //      group: generic-init quiet
456         char arg[1024];
457         char *line;
459         /* arg = "local-map . ////..." */
460         memset(arg, '/', sizeof(arg));
461         arg[sizeof(arg) - 1] = '\0';
462         line = "local-map       .       ";
463         memcpy(arg, line, strlen(line));
465         create_conf_file(CONF_FILENAME, 0, arg, NULL);
467         r = idn_resconf_loadfile(ctx, CONF_FILENAME);
468         ASSERT_RESULT(r, idn_invalid_syntax);
471 //# TESTCASE
472 //      title: load file (empty file)
473 //      group: generic-init
475         create_conf_file(CONF_FILENAME, 0, "", NULL);
476         r = idn_resconf_loadfile(ctx, CONF_FILENAME);
477         ASSERT_RESULT(r, idn_success);
480 //# TESTCASE
481 //      title: load file (invalid parameter for idn-encoding)
482 //      group: generic-init quiet
484 #ifndef WITHOUT_ICONV
485         SKIP_TESTCASE;
486 #else
487         create_conf_file(CONF_FILENAME, 0,
488                          "idn-encoding  invalid-encoding-name",
489                          NULL);
490         r = idn_resconf_loadfile(ctx, CONF_FILENAME);
491         ASSERT_RESULT(r, idn_invalid_name);
492 #endif
495 //# TESTCASE
496 //      title: load file (define idn-encoding twice)
497 //      group: generic-init quiet
499 #ifndef WITHOUT_ICONV
500         SKIP_TESTCASE;
501 #else
502         create_conf_file(CONF_FILENAME, CONF_NO_EOF_NEWLINE,
503                          "idn-encoding  Punycode", 
504                          "idn-encoding  Punycode", 
505                          NULL);
506         r = idn_resconf_loadfile(ctx, CONF_FILENAME);
507         ASSERT_RESULT(r, idn_invalid_syntax);
508 #endif
511 //# TESTCASE
512 //      title: load file (invalid parameter for nameprep)
513 //      group: generic-init quiet
515         create_conf_file(CONF_FILENAME, 0,
516                          "nameprep      invalid-version",
517                          NULL);
518         r = idn_resconf_loadfile(ctx, CONF_FILENAME);
519         ASSERT_RESULT(r, idn_invalid_name);
522 //# TESTCASE
523 //      title: load file (define nameprep twice)
524 //      group: generic-init quiet
526 #ifndef WITHOUT_ICONV
527         SKIP_TESTCASE;
528 #else
529         create_conf_file(CONF_FILENAME, CONF_NO_EOF_NEWLINE,
530                          "nameprep      " IDN_NAMEPREP_CURRENT,
531                          "nameprep      " IDN_NAMEPREP_CURRENT,
532                          NULL);
533         r = idn_resconf_loadfile(ctx, CONF_FILENAME);
534         ASSERT_RESULT(r, idn_invalid_syntax);
535 #endif
538 //# TESTCASE
539 //      title: load file (invalid parameter for local-map)
540 //      group: generic-init quiet
542         create_conf_file(CONF_FILENAME, 0,
543                          "local-map     .jp     :",
544                          NULL);
545         r = idn_resconf_loadfile(ctx, CONF_FILENAME);
546         ASSERT_RESULT(r, idn_invalid_name);
548         create_conf_file(CONF_FILENAME, 0,
549                          "local-map     .jp     invalid:/dev/null",
550                          NULL);
551         r = idn_resconf_loadfile(ctx, CONF_FILENAME);
552         ASSERT_RESULT(r, idn_invalid_name);
554         create_conf_file(CONF_FILENAME, 0,
555                          "local-map     .jp     filemap",
556                          NULL);
557         r = idn_resconf_loadfile(ctx, CONF_FILENAME);
558         ASSERT_RESULT(r, idn_nofile);
560         create_conf_file(CONF_FILENAME, 0,
561                          "local-map     .jp     filemap:",
562                          NULL);
563         r = idn_resconf_loadfile(ctx, CONF_FILENAME);
564         ASSERT_RESULT(r, idn_nofile);
566         create_conf_file(CONF_FILENAME, 0,
567                          "local-map     .jp     filemap:no-such-file",
568                          NULL);
569         r = idn_resconf_loadfile(ctx, CONF_FILENAME);
570         ASSERT_RESULT(r, idn_nofile);
572         create_conf_file(CONF_FILENAME, 0,
573                          "local-map "
574                          "abcdefghijklmnopqrstuvwxyz0123"
575                          "abcdefghijklmnopqrstuvwxyz0123"
576                          "4567 "
577                          IDN_NAMEPREP_CURRENT,
578                          NULL);
579         r = idn_resconf_loadfile(ctx, CONF_FILENAME);
580         ASSERT_RESULT(r, idn_invalid_name);
583 //# TESTCASE
584 //      title: load file (pass wrong number of parameters to idn-encoding)
585 //      group: generic-init quiet
587         create_conf_file(CONF_FILENAME, 0,
588                          "idn-encoding  ",
589                          NULL);
590         r = idn_resconf_loadfile(ctx, CONF_FILENAME);
591         ASSERT_RESULT(r, idn_invalid_syntax);
593         create_conf_file(CONF_FILENAME, 0,
594                          "idn-encoding  Punycode ?",
595                          NULL);
596         r = idn_resconf_loadfile(ctx, CONF_FILENAME);
597         ASSERT_RESULT(r, idn_invalid_syntax);
600 //# TESTCASE
601 //      title: load file (pass wrong number of parameters to nameprep)
602 //      group: generic-init quiet
604         create_conf_file(CONF_FILENAME, 0,
605                          "nameprep      ",
606                          NULL);
607         r = idn_resconf_loadfile(ctx, CONF_FILENAME);
608         ASSERT_RESULT(r, idn_invalid_syntax);
610         create_conf_file(CONF_FILENAME, 0,
611                          "nameprep      " IDN_NAMEPREP_CURRENT " ?",
612                          NULL);
613         r = idn_resconf_loadfile(ctx, CONF_FILENAME);
614         ASSERT_RESULT(r, idn_invalid_syntax);
617 //# TESTCASE
618 //      title: load file (pass wrong number of parameters to local-map)
619 //      group: generic-init quiet
621         create_conf_file(CONF_FILENAME, 0,
622                          "local-map     ",
623                          NULL);
624         r = idn_resconf_loadfile(ctx, CONF_FILENAME);
625         ASSERT_RESULT(r, idn_invalid_syntax);
627         create_conf_file(CONF_FILENAME, 0,
628                          "local-map     .jp     ",
629                          NULL);
630         r = idn_resconf_loadfile(ctx, CONF_FILENAME);
631         ASSERT_RESULT(r, idn_invalid_syntax);
634 //# TESTCASE
635 //      title: getdelimitermap
636 //      group: generic-init set-defaults delimitermap_ctx
638         delimitermap_ctx1 = idn_resconf_getdelimitermap(ctx);
639         ASSERT_PTR_NE(delimitermap_ctx1, NULL);
642 //# TESTCASE
643 //      title: setdelimitermap
644 //      group: generic-init set-defaults delimitermap_ctx
646         r = idn_delimitermap_create(&delimitermap_ctx1);
647         ASSERT_RESULT(r, idn_success);
649         /* set delimitermap context. */
650         idn_resconf_setdelimitermap(ctx, delimitermap_ctx1);
651         delimitermap_ctx2 = idn_resconf_getdelimitermap(ctx);
652         ASSERT_PTR(delimitermap_ctx2, delimitermap_ctx1);
653         idn_delimitermap_destroy(delimitermap_ctx2);
655         /* set NULL as delimitermap context */
656         idn_resconf_setdelimitermap(ctx, NULL);
657         delimitermap_ctx2 = idn_resconf_getdelimitermap(ctx);
658         ASSERT_PTR(delimitermap_ctx2, NULL);
661 //# TESTCASE
662 //      title: addalldelimitermapucs
663 //      group: generic-init set-defaults
665         static unsigned long v[] = {0x002C, 0x3001, 0xFF0C};
666         int nv = sizeof(v) / sizeof(*v);
668         r = idn_resconf_addalldelimitermapucs(ctx, v, nv);
669         ASSERT_RESULT(r, idn_success);
672 //# TESTCASE
673 //      title: getidnconverter
674 //      group: generic-init set-defaults idnconverter_ctx
676         idnconverter_ctx1 = idn_resconf_getidnconverter(ctx);
677         ASSERT_PTR_NE(idnconverter_ctx1, NULL);
680 //# TESTCASE
681 //      title: setidnconverter
682 //      group: generic-init set-defaults idnconverter_ctx
684         r = idn_converter_create("Punycode", &idnconverter_ctx1, 0);
685         ASSERT_RESULT(r, idn_success);
687         /* set idnconverter context. */
688         idn_resconf_setidnconverter(ctx, idnconverter_ctx1);
689         idnconverter_ctx2 = idn_resconf_getidnconverter(ctx);
690         ASSERT_PTR(idnconverter_ctx2, idnconverter_ctx1);
691         idn_converter_destroy(idnconverter_ctx2);
693         /* set NULL as idnconverter context */
694         idn_resconf_setidnconverter(ctx, NULL);
695         idnconverter_ctx2 = idn_resconf_getidnconverter(ctx);
696         ASSERT_PTR(idnconverter_ctx2, NULL);
699 //# TESTCASE
700 //      title: getlocalconverter
701 //      group: generic-init set-defaults localconverter_ctx
703         localconverter_ctx1 = idn_resconf_getlocalconverter(ctx);
704 #ifdef WITHOUT_ICONV
705         ASSERT_PTR(localconverter_ctx1, NULL);
706 #else
707         ASSERT_PTR_NE(localconverter_ctx1, NULL);
708 #endif
711 //# TESTCASE
712 //      title: setlocalconverter
713 //      group: generic-init set-defaults localconverter_ctx
715         r = idn_converter_create("UTF-8", &localconverter_ctx1, 0);
716         ASSERT_RESULT(r, idn_success);
718         /* set localconverter context. */
719         idn_resconf_setlocalconverter(ctx, localconverter_ctx1);
720         localconverter_ctx2 = idn_resconf_getlocalconverter(ctx);
721 #ifdef WITHOUT_ICONV
722         ASSERT_PTR(localconverter_ctx2, NULL);
723 #else
724         ASSERT_PTR(localconverter_ctx2, localconverter_ctx1);
725         idn_converter_destroy(localconverter_ctx2);
726 #endif
728         /* set NULL as localconverter context */
729         idn_resconf_setlocalconverter(ctx, NULL);
730         localconverter_ctx2 = idn_resconf_getlocalconverter(ctx);
731 #ifdef WITHOUT_ICONV
732         ASSERT_PTR(localconverter_ctx2, NULL);
733 #else
734         ASSERT_PTR_NE(localconverter_ctx2, NULL);
735 #endif
738 //# TESTCASE
739 //      title: getauxidnconverter
740 //      group: generic-init set-defaults auxidnconverter_ctx
742         auxidnconverter_ctx1 = idn_resconf_getauxidnconverter(ctx);
743         ASSERT_PTR(auxidnconverter_ctx1, NULL);
746 //# TESTCASE
747 //      title: setauxidnconverter
748 //      group: generic-init set-defaults auxidnconverter_ctx
750         r = idn_converter_create("Punycode", &auxidnconverter_ctx1, 0);
751         ASSERT_RESULT(r, idn_success);
753         /* set auxidnconverter context. */
754         idn_resconf_setauxidnconverter(ctx, auxidnconverter_ctx1);
755         auxidnconverter_ctx2 = idn_resconf_getauxidnconverter(ctx);
756         ASSERT_PTR(auxidnconverter_ctx2, auxidnconverter_ctx1);
757         idn_converter_destroy(auxidnconverter_ctx2);
759         /* set NULL as auxidnconverter context */
760         idn_resconf_setauxidnconverter(ctx, NULL);
761         auxidnconverter_ctx2 = idn_resconf_getauxidnconverter(ctx);
762         ASSERT_PTR(auxidnconverter_ctx2, NULL);
765 //# TESTCASE
766 //      title: getlocalmapselector
767 //      group: generic-init set-defaults mapselector_ctx
769         mapselector_ctx1 = idn_resconf_getlocalmapselector(ctx);
770         ASSERT_PTR(mapselector_ctx1, NULL);
773 //# TESTCASE
774 //      title: setlocalmapselector
775 //      group: generic-init set-defaults mapselector_ctx
777         r = idn_mapselector_create(&mapselector_ctx1);
778         ASSERT_RESULT(r, idn_success);
780         /* set localmapselector context. */
781         idn_resconf_setlocalmapselector(ctx, mapselector_ctx1);
782         mapselector_ctx2 = idn_resconf_getlocalmapselector(ctx);
783         ASSERT_PTR(mapselector_ctx2, mapselector_ctx1);
784         idn_mapselector_destroy(mapselector_ctx2);
786         /* set NULL as localmapselector context */
787         idn_resconf_setlocalmapselector(ctx, NULL);
788         mapselector_ctx2 = idn_resconf_getlocalmapselector(ctx);
789         ASSERT_PTR(mapselector_ctx2, NULL);
792 //# TESTCASE
793 //      title: addalllocalmapselectornames
794 //      group: generic-init set-defaults
796         static const char *names[] = {
797                 "filemap:" MAP_FILENAME,
798                 "filemap:" MAP_FILENAME,
799                 "filemap:" MAP_FILENAME
800         };
801         int nnames = sizeof(names) / sizeof(*names);
803         create_conf_file(MAP_FILENAME, 0,
804                          "2212; FF0D",
805                          NULL);
806         r = idn_resconf_addalllocalmapselectornames(ctx, ".jp", names, nnames);
807         ASSERT_RESULT(r, idn_success);
810 //# TESTCASE
811 //      title: getmapper
812 //      group: generic-init set-defaults mapper_ctx
814         mapper_ctx1 = idn_resconf_getmapper(ctx);
815         ASSERT_PTR_NE(mapper_ctx1, NULL);
818 //# TESTCASE
819 //      title: setmapper
820 //      group: generic-init set-defaults mapper_ctx
822         r = idn_mapper_create(&mapper_ctx1);
823         ASSERT_RESULT(r, idn_success);
825         /* set mapper context. */
826         idn_resconf_setmapper(ctx, mapper_ctx1);
827         mapper_ctx2 = idn_resconf_getmapper(ctx);
828         ASSERT_PTR(mapper_ctx2, mapper_ctx1);
829         idn_mapper_destroy(mapper_ctx2);
831         /* set NULL as mapper context */
832         idn_resconf_setmapper(ctx, NULL);
833         mapper_ctx2 = idn_resconf_getmapper(ctx);
834         ASSERT_PTR(mapper_ctx2, NULL);
837 //# TESTCASE
838 //      title: addallmappernames
839 //      group: generic-init set-defaults
841         static const char *names[] = {
842                 IDN_NAMEPREP_CURRENT,
843                 IDN_NAMEPREP_CURRENT,
844                 IDN_NAMEPREP_CURRENT
845         };
846         int nnames = sizeof(names) / sizeof(*names);
848         r = idn_resconf_addallmappernames(ctx, names, nnames);
849         ASSERT_RESULT(r, idn_success);
852 //# TESTCASE
853 //      title: getnormalizer
854 //      group: generic-init set-defaults normalizer_ctx
856         normalizer_ctx1 = idn_resconf_getnormalizer(ctx);
857         ASSERT_PTR_NE(normalizer_ctx1, NULL);
860 //# TESTCASE
861 //      title: setnormalizer
862 //      group: generic-init set-defaults normalizer_ctx
864         r = idn_normalizer_create(&normalizer_ctx1);
865         ASSERT_RESULT(r, idn_success);
867         /* set normalizer context. */
868         idn_resconf_setnormalizer(ctx, normalizer_ctx1);
869         normalizer_ctx2 = idn_resconf_getnormalizer(ctx);
870         ASSERT_PTR(normalizer_ctx2, normalizer_ctx1);
871         idn_normalizer_destroy(normalizer_ctx2);
873         /* set NULL as normalizer context */
874         idn_resconf_setnormalizer(ctx, NULL);
875         normalizer_ctx2 = idn_resconf_getnormalizer(ctx);
876         ASSERT_PTR(normalizer_ctx2, NULL);
879 //# TESTCASE
880 //      title: addallnormalizernames
881 //      group: generic-init set-defaults
883         static const char *names[] = {
884                 IDN_NAMEPREP_CURRENT,
885                 IDN_NAMEPREP_CURRENT,
886                 IDN_NAMEPREP_CURRENT
887         };
888         int nnames = sizeof(names) / sizeof(*names);
890         r = idn_resconf_addallnormalizernames(ctx, names, nnames);
891         ASSERT_RESULT(r, idn_success);
894 //# TESTCASE
895 //      title: getprohibitchecker
896 //      group: generic-init set-defaults prohibitchecker_ctx
898         prohibitchecker_ctx1 = idn_resconf_getprohibitchecker(ctx);
899         ASSERT_PTR_NE(prohibitchecker_ctx1, NULL);
902 //# TESTCASE
903 //      title: setprohibitchecker
904 //      group: generic-init set-defaults prohibitchecker_ctx
906         r = idn_checker_create(&prohibitchecker_ctx1);
907         ASSERT_RESULT(r, idn_success);
909         /* set checker context. */
910         idn_resconf_setprohibitchecker(ctx, prohibitchecker_ctx1);
911         prohibitchecker_ctx2 = idn_resconf_getprohibitchecker(ctx);
912         ASSERT_PTR(prohibitchecker_ctx2, prohibitchecker_ctx1);
913         idn_checker_destroy(prohibitchecker_ctx2);
915         /* set NULL as checker context */
916         idn_resconf_setprohibitchecker(ctx, NULL);
917         prohibitchecker_ctx2 = idn_resconf_getprohibitchecker(ctx);
918         ASSERT_PTR(prohibitchecker_ctx2, NULL);
921 //# TESTCASE
922 //      title: addallprohibitcheckernames
923 //      group: generic-init set-defaults
925         static const char *names[] = {
926                 IDN_NAMEPREP_CURRENT,
927                 IDN_NAMEPREP_CURRENT,
928                 IDN_NAMEPREP_CURRENT
929         };
930         int nnames = sizeof(names) / sizeof(*names);
932         r = idn_resconf_addallprohibitcheckernames(ctx, names, nnames);
933         ASSERT_RESULT(r, idn_success);
936 //# TESTCASE
937 //      title: getunassignedchecker
938 //      group: generic-init set-defaults unassignedchecker_ctx
940         unassignedchecker_ctx1 = idn_resconf_getunassignedchecker(ctx);
941         ASSERT_PTR_NE(unassignedchecker_ctx1, NULL);
944 //# TESTCASE
945 //      title: setunassignedchecker
946 //      group: generic-init set-defaults unassignedchecker_ctx
948         r = idn_checker_create(&unassignedchecker_ctx1);
949         ASSERT_RESULT(r, idn_success);
951         /* set checker context. */
952         idn_resconf_setunassignedchecker(ctx, unassignedchecker_ctx1);
953         unassignedchecker_ctx2 = idn_resconf_getunassignedchecker(ctx);
954         ASSERT_PTR(unassignedchecker_ctx2, unassignedchecker_ctx1);
955         idn_checker_destroy(unassignedchecker_ctx2);
957         /* set NULL as checker context */
958         idn_resconf_setunassignedchecker(ctx, NULL);
959         unassignedchecker_ctx2 = idn_resconf_getunassignedchecker(ctx);
960         ASSERT_PTR(unassignedchecker_ctx2, NULL);
963 //# TESTCASE
964 //      title: addallunassignedcheckernames
965 //      group: generic-init set-defaults
967         static const char *names[] = {
968                 IDN_NAMEPREP_CURRENT,
969                 IDN_NAMEPREP_CURRENT,
970                 IDN_NAMEPREP_CURRENT
971         };
972         int nnames = sizeof(names) / sizeof(*names);
974         r = idn_resconf_addallunassignedcheckernames(ctx, names, nnames);
975         ASSERT_RESULT(r, idn_success);
978 //# TESTCASE
979 //      title: getbidichecker
980 //      group: generic-init set-defaults bidichecker_ctx
982         bidichecker_ctx1 = idn_resconf_getbidichecker(ctx);
983         ASSERT_PTR_NE(bidichecker_ctx1, NULL);
986 //# TESTCASE
987 //      title: setbidichecker
988 //      group: generic-init set-defaults bidichecker_ctx
990         r = idn_checker_create(&bidichecker_ctx1);
991         ASSERT_RESULT(r, idn_success);
993         /* set checker context. */
994         idn_resconf_setbidichecker(ctx, bidichecker_ctx1);
995         bidichecker_ctx2 = idn_resconf_getbidichecker(ctx);
996         ASSERT_PTR(bidichecker_ctx2, bidichecker_ctx1);
997         idn_checker_destroy(bidichecker_ctx2);
999         /* set NULL as checker context */
1000         idn_resconf_setbidichecker(ctx, NULL);
1001         bidichecker_ctx2 = idn_resconf_getbidichecker(ctx);
1002         ASSERT_PTR(bidichecker_ctx2, NULL);
1005 //# TESTCASE
1006 //      title: addallbidicheckernames
1007 //      group: generic-init set-defaults
1009         static const char *names[] = {
1010                 IDN_NAMEPREP_CURRENT,
1011                 IDN_NAMEPREP_CURRENT,
1012                 IDN_NAMEPREP_CURRENT
1013         };
1014         int nnames = sizeof(names) / sizeof(*names);
1016         r = idn_resconf_addallbidicheckernames(ctx, names, nnames);
1017         ASSERT_RESULT(r, idn_success);
1020 //# TESTCASE
1021 //      title: setnameprepversion
1022 //      group: generic-init set-defaults
1024         idn_resconf_setnameprepversion(ctx, IDN_NAMEPREP_CURRENT);
1025         ASSERT_RESULT(r, idn_success);