checker.tsy revision 5c526acb82c882e41b655c31f5fa4425c87b671c
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#ifndef lint
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsstatic char *rcsid = "$Id: checker.tsy,v 1.1 2003/06/04 00:26:51 marka Exp $";
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#endif
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Copyright (c) 2002 Japan Network Information Center.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * All rights reserved.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews *
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * By using this file, you agree to the terms and conditions set forth bellow.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews *
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * LICENSE TERMS AND CONDITIONS
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews *
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * The following License Terms and Conditions apply, unless a different
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * license is obtained from Japan Network Information Center ("JPNIC"),
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Chiyoda-ku, Tokyo 101-0047, Japan.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews *
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * 1. Use, Modification and Redistribution (including distribution of any
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * modified or derived work) in source and/or binary forms is permitted
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * under this License Terms and Conditions.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews *
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * 2. Redistribution of source code must retain the copyright notices as they
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * appear in each source code file, this License Terms and Conditions.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews *
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * 3. Redistribution in binary form must reproduce the Copyright Notice,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * this License Terms and Conditions, in the documentation and/or other
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * materials provided with the distribution. For the purposes of binary
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * distribution the "Copyright Notice" refers to the following language:
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews *
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * 4. The name of JPNIC may not be used to endorse or promote products
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * derived from this Software without specific prior written approval of
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * JPNIC.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews *
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#include <stddef.h>
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#include <stdio.h>
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#include <stdlib.h>
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#include <string.h>
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#include <idn/checker.h>
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#include <idn/log.h>
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#include <idn/ucs4.h>
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#include "testutil.h"
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define SIZEOFUCS4(x) (sizeof(x) / sizeof(unsigned long))
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define UCS4_NAME_STR "U+304C" /* hiragana letter ga */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define UCS4_NAME 0x304C
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define BUF_SIZE 128
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define ARRAY_SIZE 9
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define CONF_FILENAME "test.map"
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define LINEBUF_SIZE 2001
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Sample strings for `from' argument of normalize(),
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * and its expected outputs.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsconst unsigned long from[4] = {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews UCS4_NAME,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews 0x00A0, /* no-break space: prohibited character */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews 0x0221, /* unassigned character */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews 0x0000
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews};
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define FROM_UCS4NAME_OFFSET 0
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define FROM_PROH_OFFSET 1
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define FROM_UNAS_OFFSET 2
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsconst unsigned long from2[4] = {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews UCS4_NAME,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews 0x0221, /* unassigned character */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews 0x00A0, /* no-break space: prohibited character */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews 0x0000
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews};
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define FROM2_UCS4NAME_OFFSET 0
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define FROM2_PROH_OFFSET 2
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define FROM2_UNAS_OFFSET 1
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsstatic const unsigned long bidi_from[4] = {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews 0x05BE, /* hebrew punctuation maqaf */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews 0x0041, /* latin capital letter a */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews 0xFEFC, /* arabic ligature lam with alef final form */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews 0x0000
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews};
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define BIDIFROM_OFFSET 1
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsidn_result_t
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewstest_createproc(const char *parameter, void **ctxp)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews return (idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsvoid
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewstest_destroyproc(void *ctx)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define FOUNDPTR_OFFSET 2
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsidn_result_t
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewstest_lookupproc(void *ctx, const unsigned long *ucs4,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews const unsigned long **found)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews *found = ucs4 + FOUNDPTR_OFFSET;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews return (idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//--------------------------------------------------------------------
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// Setups and Teardowns.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//--------------------------------------------------------------------
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//# SETUP
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//--
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// Initialize the module and create context.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_result_t r;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_checker_t ctx = NULL;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews char name[BUF_SIZE];
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_initialize();
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_create(&ctx);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//# TEARDOWN
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//--
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// Destroy context.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (ctx != NULL)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_checker_destroy(ctx);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//# SETUP
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: lookup
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//--
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// Initialize the module and create context.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_result_t r;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_checker_t ctx = NULL;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews char name[BUF_SIZE];
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews const unsigned long *ptr;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_initialize();
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_create(&ctx);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//# TEARDOWN
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: lookup
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//--
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// Destroy context.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (ctx != NULL)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_checker_destroy(ctx);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//# SETUP
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: addall
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//--
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// Initialize the module and create context.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_result_t r;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_checker_t ctx = NULL;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews char *names[ARRAY_SIZE];
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews int i;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews const unsigned long *ptr;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews for (i = 0; i < ARRAY_SIZE; i++) {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews names[i] = malloc(BUF_SIZE);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (names[i] == NULL) {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT("malloc failed\n");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews }
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews }
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_initialize();
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_create(&ctx);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//# TEARDOWN
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: addall
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//--
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// Destroy context and free some blocks.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (ctx != NULL)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_checker_destroy(ctx);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews for (i = 0; i < ARRAY_SIZE; i++) {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews free(names[i]);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews }
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//# SETUP
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//--
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// Set log level to `fatal' to supress log messages.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews int saved_log_level;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews saved_log_level = idn_log_getlevel();
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_log_setlevel(idn_log_level_fatal);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//# TEARDOWN
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//--
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// Restore log level.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_log_setlevel(saved_log_level);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//--------------------------------------------------------------------
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// Testcases.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//--------------------------------------------------------------------
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//# TESTCASE
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: idn_checker_add() - boundary condition
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_add(ctx, "");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_name);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//# TESTCASE
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: idn_checker_add() - builtin schemes, prohibit
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(name, "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_add(ctx, name);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(name, "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "nameprep-01");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_add(ctx, name);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_name);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//# TESTCASE
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: idn_checker_add() - builtin schemes, unassigned
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(name, "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_add(ctx, name);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(name, "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "nameprep-01");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_add(ctx, name);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_name);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//# TESTCASE
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: idn_checker_add() - builtin schemes, bidi
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(name, "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_add(ctx, name);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(name, "%s%s", IDN_CHECKER_BIDI_PREFIX, "nameprep-01");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_add(ctx, name);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_name);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//# TESTCASE
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: idn_checker_add() - file - boundary condition
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(name, "%sfileset:%s", IDN_CHECKER_UNASSIGNED_PREFIX, "");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_add(ctx, name);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_nofile);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(name, "%sfileset:%s", IDN_CHECKER_PROHIBIT_PREFIX, "");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_add(ctx, name);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_nofile);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(name, "%sfileset:%s", IDN_CHECKER_BIDI_PREFIX, "");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_add(ctx, name);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_name);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//# TESTCASE
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: idn_checker_add() - file - long line
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews char line[LINEBUF_SIZE];
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews const char *first_entry = "304C;";
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews const char *other_entry = " 304D";
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews int i;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews int len;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews memcpy(line, first_entry, strlen(first_entry));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews len = strlen(other_entry);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews for (i = len; i < LINEBUF_SIZE - len; i += len) {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews memcpy(line + i, other_entry, len);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews }
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews *(line + i) = '\0';
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews create_conf_file(CONF_FILENAME, 0, line, NULL);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(name, "%sfileset:%s", IDN_CHECKER_UNASSIGNED_PREFIX,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews CONF_FILENAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_add(ctx, name);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_syntax);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(name, "%sfileset:%s", IDN_CHECKER_PROHIBIT_PREFIX,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews CONF_FILENAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_add(ctx, name);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_syntax);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//# TESTCASE
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: idn_checker_add() - file, prohibit
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: lookup
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews create_conf_file(CONF_FILENAME, 0,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews UCS4_NAME_STR,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews NULL);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(name, "%sfileset:%s", IDN_CHECKER_PROHIBIT_PREFIX,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews CONF_FILENAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_add(ctx, name);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_lookup(ctx, from, &ptr);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_PTR(ptr, from + FROM_UCS4NAME_OFFSET);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_lookup(ctx, from2, &ptr);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_PTR(ptr, from2 + FROM2_UCS4NAME_OFFSET);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//# TESTCASE
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: idn_checker_add() - file, unassigned
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: lookup
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews create_conf_file(CONF_FILENAME, 0,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews UCS4_NAME_STR,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews NULL);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(name, "%sfileset:%s", IDN_CHECKER_UNASSIGNED_PREFIX,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews CONF_FILENAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_add(ctx, name);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_lookup(ctx, from, &ptr);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_PTR(ptr, from + FROM_UCS4NAME_OFFSET);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_lookup(ctx, from2, &ptr);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_PTR(ptr, from2 + FROM2_UCS4NAME_OFFSET);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//# TESTCASE
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: idn_checker_add() - file, bidi
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: lookup quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews create_conf_file(CONF_FILENAME, 0,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews UCS4_NAME_STR,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews NULL);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(name, "%sfileset:%s", IDN_CHECKER_BIDI_PREFIX,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews CONF_FILENAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_add(ctx, name);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_name);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//# TESTCASE
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: idn_checker_addall() - boundary condition - scheme name
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: addall quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(names[0], "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(names[1], "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(names[2], "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(names[3], "%s%s", IDN_CHECKER_BIDI_PREFIX, "");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_addall(ctx, (const char **)names, 4);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_name);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//# TESTCASE
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: idn_checker_addall() - boundary condition - nschemes = 0
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: addall quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(names[0], "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "nameprep-01");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(names[1], "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "nameprep-01");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(names[2], "%s%s", IDN_CHECKER_BIDI_PREFIX, "");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(names[3], "%s%s", IDN_CHECKER_BIDI_PREFIX, "nameprep-01");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_addall(ctx, (const char **)names, 0);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_lookup(ctx, from, &ptr);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_PTR(ptr, NULL);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//# TESTCASE
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: idn_checker_addall() - add a lot of schemes #1
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: addall
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(names[0], "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(names[1], "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(names[2], "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(names[3], "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(names[4], "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(names[5], "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(names[6], "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(names[7], "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(names[8], "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_addall(ctx, (const char **)names, 9);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_lookup(ctx, from, &ptr);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_PTR(ptr, from + FROM_PROH_OFFSET);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_lookup(ctx, from2, &ptr);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_PTR(ptr, from2 + FROM2_PROH_OFFSET);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_lookup(ctx, bidi_from, &ptr);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_PTR(ptr, bidi_from + BIDIFROM_OFFSET);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//# TESTCASE
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: idn_checker_addall() - add a lot of schemes #2
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: addall
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(names[0], "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(names[1], "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(names[2], "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(names[3], "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(names[4], "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(names[5], "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(names[6], "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(names[7], "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(names[8], "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_addall(ctx, (const char **)names, 9);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_lookup(ctx, from, &ptr);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_PTR(ptr, from + FROM_UNAS_OFFSET);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_lookup(ctx, from2, &ptr);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_PTR(ptr, from2 + FROM2_UNAS_OFFSET);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_lookup(ctx, bidi_from, &ptr);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_PTR(ptr, bidi_from + BIDIFROM_OFFSET);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//# TESTCASE
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: idn_checker_addall() - add same scheme repetedly
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: addall
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews int i;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(names[0], "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews for (i = 1; i < ARRAY_SIZE; i++) {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews strcpy(names[i], names[0]);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews }
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_addall(ctx, (const char **)names, ARRAY_SIZE);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_lookup(ctx, from, &ptr);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_PTR(ptr, from + FROM_PROH_OFFSET);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_lookup(ctx, from2, &ptr);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_PTR(ptr, from2 + FROM2_PROH_OFFSET);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//# TESTCASE
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: idn_checker_lookup() - builtin schemes - RFC3491 prohibit
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: lookup
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(name, "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_add(ctx, name);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_lookup(ctx, from, &ptr);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_PTR(ptr, from + FROM_PROH_OFFSET);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_lookup(ctx, from2, &ptr);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_PTR(ptr, from2 + FROM2_PROH_OFFSET);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//# TESTCASE
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: idn_checker_lookup() - builtin schemes - RFC3491 unassigned
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: lookup
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(name, "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_add(ctx, name);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_lookup(ctx, from, &ptr);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_PTR(ptr, from + FROM_UNAS_OFFSET);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_lookup(ctx, from2, &ptr);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_PTR(ptr, from2 + FROM2_UNAS_OFFSET);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//# TESTCASE
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: idn_checker_lookup() - builtin schemes - RFC3491 bidi
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: lookup
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(name, "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_add(ctx, name);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_lookup(ctx, bidi_from, &ptr);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_PTR(ptr, bidi_from + BIDIFROM_OFFSET);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_lookup(ctx, from, &ptr);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_PTR(ptr, NULL);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_lookup(ctx, from2, &ptr);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_PTR(ptr, NULL);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//# TESTCASE
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: idn_checker_lookup() - context without procedure
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: lookup
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_lookup(ctx, from, &ptr);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_PTR(ptr, NULL);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//# TESTCASE
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: idn_checker_lookup() - string in ascii
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: lookup
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews char *ascii_str = "test";
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews unsigned long ucs4_str[5];
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_ucs4_utf8toucs4(ascii_str, ucs4_str, SIZEOFUCS4(ucs4_str));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(name, "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_add(ctx, name);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(name, "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_add(ctx, name);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews sprintf(name, "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_add(ctx, name);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_lookup(ctx, ucs4_str, &ptr);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_PTR(ptr, NULL);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//# TESTCASE
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: idn_checker_destroy(), idn_checker_incrref()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group:
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_result_t r;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_checker_t ctx = NULL;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_initialize();
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_create(&ctx);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_checker_incrref(ctx);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_checker_destroy(ctx);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_checker_destroy(ctx);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//# TESTCASE
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: idn_checker_register()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews const unsigned long *ptr = NULL;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_register("test",
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews test_createproc,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews test_destroyproc,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews test_lookupproc);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_add(ctx, "test");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_checker_lookup(ctx, from, &ptr);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_PTR(ptr, from + FOUNDPTR_OFFSET);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}