2 static char *rcsid = "Id: resconf.tsy,v 1.1 2003/06/04 00:27:00 marka Exp ";
6 * Copyright (c) 2002 Japan Network Information Center.
9 * By using this file, you agree to the terms and conditions set forth bellow.
11 * LICENSE TERMS AND CONDITIONS
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.
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.
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.
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."
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
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.
53 #include <idn/resconf.h>
54 #include <idn/converter.h>
60 #define CONF_FILENAME "test.conf"
61 #define MAP_FILENAME "test.map"
63 //--------------------------------------------------------------------
64 // Setups and Teardowns.
65 //--------------------------------------------------------------------
68 // group: generic-init
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);
83 // group: generic-init
86 idn_resconf_destroy(ctx);
87 remove(CONF_FILENAME);
92 // group: set-defaults
94 r = idn_resconf_setdefaults(ctx);
95 ASSERT_RESULT(r, idn_success);
99 // group: set-defaults
108 saved_log_level = idn_log_getlevel();
109 idn_log_setlevel(idn_log_level_fatal);
115 idn_log_setlevel(saved_log_level);
119 // group: delimitermap_ctx
121 idn_delimitermap_t delimitermap_ctx1 = NULL;
122 idn_delimitermap_t delimitermap_ctx2 = NULL;
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);
135 // group: idnconverter_ctx
137 idn_converter_t idnconverter_ctx1 = NULL;
138 idn_converter_t idnconverter_ctx2 = NULL;
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);
151 // group: localconverter_ctx
153 idn_converter_t localconverter_ctx1 = NULL;
154 idn_converter_t localconverter_ctx2 = NULL;
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);
167 // group: auxidnconverter_ctx
169 idn_converter_t auxidnconverter_ctx1 = NULL;
170 idn_converter_t auxidnconverter_ctx2 = NULL;
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);
183 // group: mapselector_ctx
185 idn_mapselector_t mapselector_ctx1 = NULL;
186 idn_mapselector_t mapselector_ctx2 = NULL;
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);
201 idn_mapper_t mapper_ctx1 = NULL;
202 idn_mapper_t mapper_ctx2 = NULL;
208 if (mapper_ctx1 != NULL)
209 idn_mapper_destroy(mapper_ctx1);
210 if (mapper_ctx2 != NULL)
211 idn_mapper_destroy(mapper_ctx2);
215 // group: normalizer_ctx
217 idn_normalizer_t normalizer_ctx1 = NULL;
218 idn_normalizer_t normalizer_ctx2 = NULL;
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);
231 // group: prohibitchecker_ctx
233 idn_checker_t prohibitchecker_ctx1 = NULL;
234 idn_checker_t prohibitchecker_ctx2 = NULL;
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);
247 // group: unassignedchecker_ctx
249 idn_checker_t unassignedchecker_ctx1 = NULL;
250 idn_checker_t unassignedchecker_ctx2 = NULL;
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);
263 // group: bidichecker_ctx
265 idn_checker_t bidichecker_ctx1 = NULL;
266 idn_checker_t bidichecker_ctx2 = NULL;
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 //--------------------------------------------------------------------
280 //--------------------------------------------------------------------
283 // title: call create() without initialization.
285 // This must be the first test case.
288 idn_resconf_t ctx = NULL;
290 r = idn_resconf_create(&ctx);
291 ASSERT_RESULT(r, idn_failure);
294 idn_resconf_destroy(ctx);
298 // title: call initialize() twice.
303 r = idn_resconf_initialize();
304 ASSERT_RESULT(r, idn_success);
306 r = idn_resconf_initialize();
307 ASSERT_RESULT(r, idn_success);
311 // title: call create()
316 r = idn_resconf_initialize();
317 ASSERT_RESULT(r, idn_success);
319 r = idn_resconf_create(&ctx);
320 ASSERT_RESULT(r, idn_success);
323 idn_resconf_destroy(ctx);
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",
335 r = idn_resconf_loadfile(ctx, CONF_FILENAME);
336 ASSERT_RESULT(r, idn_success);
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,
348 r = idn_resconf_loadfile(ctx, CONF_FILENAME);
349 ASSERT_RESULT(r, idn_success);
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,
362 r = idn_resconf_loadfile(ctx, CONF_FILENAME);
363 ASSERT_RESULT(r, idn_success);
367 // title: load file (empty)
368 // group: generic-init
370 const char *idn_encoding;
372 create_conf_file(CONF_FILENAME, 0,
374 r = idn_resconf_loadfile(ctx, CONF_FILENAME);
375 ASSERT_RESULT(r, idn_success);
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,
387 create_conf_file(MAP_FILENAME, 0,
391 r = idn_resconf_loadfile(ctx, CONF_FILENAME);
392 ASSERT_RESULT(r, idn_success);
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,
404 r = idn_resconf_loadfile(ctx, CONF_FILENAME);
405 ASSERT_RESULT(r, idn_success);
409 // title: set defaults
410 // group: generic-init set-defaults
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);
423 // title: load file (empty file name)
424 // group: generic-init
426 r = idn_resconf_loadfile(ctx, "");
427 ASSERT_RESULT(r, idn_nofile);
431 // title: load file (unknown command)
432 // group: generic-init quiet
434 create_conf_file(CONF_FILENAME, 0,
435 "unknown-command " IDN_NAMEPREP_CURRENT,
437 r = idn_resconf_loadfile(ctx, CONF_FILENAME);
438 ASSERT_RESULT(r, idn_invalid_syntax);
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,
448 r = idn_resconf_loadfile(ctx, CONF_FILENAME);
449 ASSERT_RESULT(r, idn_success);
453 // title: load file (too long line)
454 // group: generic-init quiet
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);
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);
481 // title: load file (invalid parameter for idn-encoding)
482 // group: generic-init quiet
484 #ifndef WITHOUT_ICONV
487 create_conf_file(CONF_FILENAME, 0,
488 "idn-encoding invalid-encoding-name",
490 r = idn_resconf_loadfile(ctx, CONF_FILENAME);
491 ASSERT_RESULT(r, idn_invalid_name);
496 // title: load file (define idn-encoding twice)
497 // group: generic-init quiet
499 #ifndef WITHOUT_ICONV
502 create_conf_file(CONF_FILENAME, CONF_NO_EOF_NEWLINE,
503 "idn-encoding Punycode",
504 "idn-encoding Punycode",
506 r = idn_resconf_loadfile(ctx, CONF_FILENAME);
507 ASSERT_RESULT(r, idn_invalid_syntax);
512 // title: load file (invalid parameter for nameprep)
513 // group: generic-init quiet
515 create_conf_file(CONF_FILENAME, 0,
516 "nameprep invalid-version",
518 r = idn_resconf_loadfile(ctx, CONF_FILENAME);
519 ASSERT_RESULT(r, idn_invalid_name);
523 // title: load file (define nameprep twice)
524 // group: generic-init quiet
526 #ifndef WITHOUT_ICONV
529 create_conf_file(CONF_FILENAME, CONF_NO_EOF_NEWLINE,
530 "nameprep " IDN_NAMEPREP_CURRENT,
531 "nameprep " IDN_NAMEPREP_CURRENT,
533 r = idn_resconf_loadfile(ctx, CONF_FILENAME);
534 ASSERT_RESULT(r, idn_invalid_syntax);
539 // title: load file (invalid parameter for local-map)
540 // group: generic-init quiet
542 create_conf_file(CONF_FILENAME, 0,
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",
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",
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:",
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",
569 r = idn_resconf_loadfile(ctx, CONF_FILENAME);
570 ASSERT_RESULT(r, idn_nofile);
572 create_conf_file(CONF_FILENAME, 0,
574 "abcdefghijklmnopqrstuvwxyz0123"
575 "abcdefghijklmnopqrstuvwxyz0123"
577 IDN_NAMEPREP_CURRENT,
579 r = idn_resconf_loadfile(ctx, CONF_FILENAME);
580 ASSERT_RESULT(r, idn_invalid_name);
584 // title: load file (pass wrong number of parameters to idn-encoding)
585 // group: generic-init quiet
587 create_conf_file(CONF_FILENAME, 0,
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 ?",
596 r = idn_resconf_loadfile(ctx, CONF_FILENAME);
597 ASSERT_RESULT(r, idn_invalid_syntax);
601 // title: load file (pass wrong number of parameters to nameprep)
602 // group: generic-init quiet
604 create_conf_file(CONF_FILENAME, 0,
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 " ?",
613 r = idn_resconf_loadfile(ctx, CONF_FILENAME);
614 ASSERT_RESULT(r, idn_invalid_syntax);
618 // title: load file (pass wrong number of parameters to local-map)
619 // group: generic-init quiet
621 create_conf_file(CONF_FILENAME, 0,
624 r = idn_resconf_loadfile(ctx, CONF_FILENAME);
625 ASSERT_RESULT(r, idn_invalid_syntax);
627 create_conf_file(CONF_FILENAME, 0,
630 r = idn_resconf_loadfile(ctx, CONF_FILENAME);
631 ASSERT_RESULT(r, idn_invalid_syntax);
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);
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);
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);
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);
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);
700 // title: getlocalconverter
701 // group: generic-init set-defaults localconverter_ctx
703 localconverter_ctx1 = idn_resconf_getlocalconverter(ctx);
705 ASSERT_PTR(localconverter_ctx1, NULL);
707 ASSERT_PTR_NE(localconverter_ctx1, NULL);
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);
722 ASSERT_PTR(localconverter_ctx2, NULL);
724 ASSERT_PTR(localconverter_ctx2, localconverter_ctx1);
725 idn_converter_destroy(localconverter_ctx2);
728 /* set NULL as localconverter context */
729 idn_resconf_setlocalconverter(ctx, NULL);
730 localconverter_ctx2 = idn_resconf_getlocalconverter(ctx);
732 ASSERT_PTR(localconverter_ctx2, NULL);
734 ASSERT_PTR_NE(localconverter_ctx2, NULL);
739 // title: getauxidnconverter
740 // group: generic-init set-defaults auxidnconverter_ctx
742 auxidnconverter_ctx1 = idn_resconf_getauxidnconverter(ctx);
743 ASSERT_PTR(auxidnconverter_ctx1, NULL);
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);
766 // title: getlocalmapselector
767 // group: generic-init set-defaults mapselector_ctx
769 mapselector_ctx1 = idn_resconf_getlocalmapselector(ctx);
770 ASSERT_PTR(mapselector_ctx1, NULL);
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);
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
801 int nnames = sizeof(names) / sizeof(*names);
803 create_conf_file(MAP_FILENAME, 0,
806 r = idn_resconf_addalllocalmapselectornames(ctx, ".jp", names, nnames);
807 ASSERT_RESULT(r, idn_success);
812 // group: generic-init set-defaults mapper_ctx
814 mapper_ctx1 = idn_resconf_getmapper(ctx);
815 ASSERT_PTR_NE(mapper_ctx1, NULL);
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);
838 // title: addallmappernames
839 // group: generic-init set-defaults
841 static const char *names[] = {
842 IDN_NAMEPREP_CURRENT,
843 IDN_NAMEPREP_CURRENT,
846 int nnames = sizeof(names) / sizeof(*names);
848 r = idn_resconf_addallmappernames(ctx, names, nnames);
849 ASSERT_RESULT(r, idn_success);
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);
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);
880 // title: addallnormalizernames
881 // group: generic-init set-defaults
883 static const char *names[] = {
884 IDN_NAMEPREP_CURRENT,
885 IDN_NAMEPREP_CURRENT,
888 int nnames = sizeof(names) / sizeof(*names);
890 r = idn_resconf_addallnormalizernames(ctx, names, nnames);
891 ASSERT_RESULT(r, idn_success);
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);
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);
922 // title: addallprohibitcheckernames
923 // group: generic-init set-defaults
925 static const char *names[] = {
926 IDN_NAMEPREP_CURRENT,
927 IDN_NAMEPREP_CURRENT,
930 int nnames = sizeof(names) / sizeof(*names);
932 r = idn_resconf_addallprohibitcheckernames(ctx, names, nnames);
933 ASSERT_RESULT(r, idn_success);
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);
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);
964 // title: addallunassignedcheckernames
965 // group: generic-init set-defaults
967 static const char *names[] = {
968 IDN_NAMEPREP_CURRENT,
969 IDN_NAMEPREP_CURRENT,
972 int nnames = sizeof(names) / sizeof(*names);
974 r = idn_resconf_addallunassignedcheckernames(ctx, names, nnames);
975 ASSERT_RESULT(r, idn_success);
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);
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);
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
1014 int nnames = sizeof(names) / sizeof(*names);
1016 r = idn_resconf_addallbidicheckernames(ctx, names, nnames);
1017 ASSERT_RESULT(r, idn_success);
1021 // title: setnameprepversion
1022 // group: generic-init set-defaults
1024 idn_resconf_setnameprepversion(ctx, IDN_NAMEPREP_CURRENT);
1025 ASSERT_RESULT(r, idn_success);