5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsstatic char *rcsid = "$Id: res.tsy,v 1.1 2003/06/04 00:26:59 marka Exp $";
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Copyright (c) 2002 Japan Network Information Center.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * All rights reserved.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * By using this file, you agree to the terms and conditions set forth bellow.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * LICENSE TERMS AND CONDITIONS
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 * 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 * 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 * 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 * 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 * 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#ifndef EUCJP_ENCODING_NAME
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define EUCJP_ENCODING_NAME "eucJP"
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * U+304B: hiragana letter KA
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * U+3099: combining katakana-hiragana voiced sound mark
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * map("U+304B U+3099") -> "U+304C"
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * U+304C: hiragana letter GA
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define UTF8_NAME "A<U+304B><U+3099>"
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define UTF8_REVNAME "a<U+304C>"
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * A4AC: hiragana letter GA (in EUC-JP)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define EUCJP_NAME "\xa4\xac"
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define EUCJP_REVNAME "\xa4\xac"
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Conversion result of "U+304B U+3099 A"
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define PUNYCODE_NAME "xn--a-i8t"
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Conversion result of "A U+304B U+3099" (in EUC-JP).
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define AUX_EUCJP_NAME "xn--a-i\xa3\xb8t"
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//--------------------------------------------------------------------
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// Setups and Teardowns.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//--------------------------------------------------------------------
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// Initialize the `resconf' context.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// Set local encoding to `UTF-8'.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews char to[256];
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_result_t r;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_resconf_t ctx;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews setenv("IDN_LOCAL_CODESET", "UTF-8", 1);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews unsetenv("IDN_DISABLE");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_resconf_initialize();
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_resconf_create(&ctx);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_resconf_setdefaults(ctx);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_resconf_destroy(ctx);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// Set log level to `fatal' to supress log messages.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews int saved_log_level;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews saved_log_level = idn_log_getlevel();
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_log_setlevel(idn_log_level_fatal);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// Restore log level.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_log_setlevel(saved_log_level);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//--------------------------------------------------------------------
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// Testcases.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews//--------------------------------------------------------------------
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: basic conversion by encodename()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_ENCODE_APP, UTF8_NAME, to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, PUNYCODE_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: basic conversion by decodename()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, UTF8_REVNAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: basic conversion by decodename2()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename2(ctx, IDN_DECODE_APP, AUX_EUCJP_NAME, to, sizeof(to),
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews EUCJP_ENCODING_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#ifdef WITHOUT_ICONV
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_failure);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, UTF8_REVNAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call decodename2() with auxencoding=NULL
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#ifdef WITHOUT_ICONV
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews SKIP_TESTCASE;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename2(ctx, IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to),
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, UTF8_REVNAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call encodename() with actions=0
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, 0, UTF8_NAME, to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, UTF8_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call decodename() with actions=0
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, 0, PUNYCODE_NAME, to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, PUNYCODE_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call decodename2() with actions=0
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#ifdef WITHOUT_ICONV
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews SKIP_TESTCASE;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename2(ctx, 0, AUX_EUCJP_NAME, to, sizeof(to),
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews EUCJP_ENCODING_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, AUX_EUCJP_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call encodename() with actions=rtcheck
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_RTCHECK, EUCJP_NAME, to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_action);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call encodename() with actions=decode-query
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_DECODE_QUERY, EUCJP_NAME, to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_action);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call encodename() with actions=decode-app
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_DECODE_APP, EUCJP_NAME, to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_action);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call encodename() with actions=decode-stored
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_DECODE_STORED, EUCJP_NAME, to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_action);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call encodename() with actions=(1<<31)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, 1 << 31, EUCJP_NAME, to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_action);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call decodename() with actions=localmap
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, IDN_LOCALMAP, PUNYCODE_NAME, to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_action);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call decodename2() with actions=localmap
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#ifdef WITHOUT_ICONV
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews SKIP_TESTCASE;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename2(ctx, IDN_LOCALMAP, AUX_EUCJP_NAME, to, sizeof(to),
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews EUCJP_ENCODING_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_action);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call decodename() with actions=lencheck
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, IDN_LENCHECK, PUNYCODE_NAME, to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_action);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call decodename2() with actions=lencheck
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#ifdef WITHOUT_ICONV
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews SKIP_TESTCASE;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename2(ctx, IDN_LENCHECK, AUX_EUCJP_NAME, to, sizeof(to),
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews EUCJP_ENCODING_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_action);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call decodename() with actions=encode-query
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, IDN_ENCODE_QUERY, PUNYCODE_NAME, to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_action);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call decodename2() with actions=encode-query
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#ifdef WITHOUT_ICONV
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews SKIP_TESTCASE;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename2(ctx, IDN_ENCODE_QUERY, AUX_EUCJP_NAME, to, sizeof(to),
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews EUCJP_ENCODING_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_action);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call decodename() with actions=encode-app
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, IDN_ENCODE_APP, PUNYCODE_NAME, to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_action);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call decodename2() with actions=encode-app
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#ifdef WITHOUT_ICONV
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews SKIP_TESTCASE;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename2(ctx, IDN_ENCODE_APP, AUX_EUCJP_NAME, to, sizeof(to),
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews EUCJP_ENCODING_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_action);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call decodename() with actions=encode-stored
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, IDN_ENCODE_STORED, PUNYCODE_NAME, to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_action);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call decodename2() with actions=encode-stored
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#ifdef WITHOUT_ICONV
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews SKIP_TESTCASE;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename2(ctx, IDN_ENCODE_STORED, AUX_EUCJP_NAME, to, sizeof(to),
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews EUCJP_ENCODING_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_action);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call decodename() with actions=(1<<31)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, 1 << 31, PUNYCODE_NAME, to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_action);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call decodename2() with actions=(1<<31)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#ifdef WITHOUT_ICONV
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews SKIP_TESTCASE;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename2(ctx, 1 << 31, AUX_EUCJP_NAME, to, sizeof(to),
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews EUCJP_ENCODING_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_action);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call encodename() with actions=localconv
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#ifndef WITHOUT_ICONV
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews SKIP_TESTCASE;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_LOCALCONV, UTF8_NAME, to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_action);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call decodename() with actions=localconv
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#ifndef WITHOUT_ICONV
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews SKIP_TESTCASE;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, IDN_LOCALCONV, PUNYCODE_NAME, to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_action);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call decodename2() with actions=localconv
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#ifndef WITHOUT_ICONV
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews SKIP_TESTCASE;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename2(ctx, IDN_LOCALCONV, AUX_EUCJP_NAME, to, sizeof(to),
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews EUCJP_ENCODING_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_failure);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call enable(0) and then encodename()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_res_enable(0);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_ENCODE_APP, UTF8_NAME, to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, UTF8_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call decodename() when IDN_DISABLE is defined
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_res_enable(0);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, PUNYCODE_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call decodename() when IDN_DISABLE is defined
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#ifdef WITHOUT_ICONV
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews SKIP_TESTCASE;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_res_enable(0);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename2(ctx, IDN_DECODE_APP, AUX_EUCJP_NAME, to, sizeof(to),
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews EUCJP_ENCODING_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, AUX_EUCJP_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call enable(0) and then encodename()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_res_enable(0);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_ENCODE_APP, UTF8_NAME, to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, UTF8_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call enable(0) and then decodename()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_res_enable(0);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, PUNYCODE_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call enable(0) and then decodename2()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#ifdef WITHOUT_ICONV
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews SKIP_TESTCASE;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_res_enable(0);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename2(ctx, IDN_DECODE_APP, AUX_EUCJP_NAME, to, sizeof(to),
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews EUCJP_ENCODING_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, AUX_EUCJP_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: set IDN_DISABLE and call encodename()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews setenv("IDN_DISABLE", "1", 1);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_ENCODE_APP, UTF8_NAME, to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, UTF8_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: set IDN_DISABLE and call decodename()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews setenv("IDN_DISABLE", "1", 1);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, PUNYCODE_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: set IDN_DISABLE and call decodename2()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#ifdef WITHOUT_ICONV
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews SKIP_TESTCASE;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews setenv("IDN_DISABLE", "1", 1);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename2(ctx, IDN_DECODE_APP, AUX_EUCJP_NAME, to, sizeof(to),
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews EUCJP_ENCODING_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, AUX_EUCJP_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: set IDN_DISABLE, and then call enable(1) and encodename()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews setenv("IDN_DISABLE", "1", 1);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_res_enable(1);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_ENCODE_APP, UTF8_NAME, to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, PUNYCODE_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: set IDN_DISABLE, and then call enable(1) and decodename()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews setenv("IDN_DISABLE", "1", 1);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_res_enable(1);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, UTF8_REVNAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: set IDN_DISABLE, and then call enable(1) and decodename2()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#ifdef WITHOUT_ICONV
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews SKIP_TESTCASE;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews setenv("IDN_DISABLE", "1", 1);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_res_enable(1);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename2(ctx, IDN_DECODE_APP, AUX_EUCJP_NAME, to, sizeof(to),
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews EUCJP_ENCODING_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, UTF8_REVNAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: overrun test for arg `to' of encodename()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* Normal case */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_ENCODE_APP, UTF8_NAME, to,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews strlen(PUNYCODE_NAME) + 1);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, PUNYCODE_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_ENCODE_APP, UTF8_NAME, to,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews strlen(PUNYCODE_NAME));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_buffer_overflow);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* enable(0) case */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_res_enable(0);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_ENCODE_APP, UTF8_NAME, to,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews strlen(UTF8_NAME) + 1);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, UTF8_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_ENCODE_APP, UTF8_NAME, to,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews strlen(UTF8_NAME));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_buffer_overflow);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* actions=0 case */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_res_enable(1);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, 0, UTF8_NAME, to, strlen(UTF8_NAME) + 1);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, UTF8_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, 0, UTF8_NAME, to, strlen(UTF8_NAME));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_buffer_overflow);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: overrun test for arg `to' of decodename()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* Normal case */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, IDN_DECODE_APP, PUNYCODE_NAME, to,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews strlen(UTF8_REVNAME) + 1);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, UTF8_REVNAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, IDN_DECODE_APP, PUNYCODE_NAME, to,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews strlen(UTF8_REVNAME));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_buffer_overflow);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* idn_res_enable(0) case */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_res_enable(0);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, IDN_DECODE_APP, PUNYCODE_NAME, to,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews strlen(PUNYCODE_NAME) + 1);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, PUNYCODE_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, IDN_DECODE_APP, PUNYCODE_NAME, to,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews strlen(PUNYCODE_NAME));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_buffer_overflow);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* actions=0 case */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_res_enable(1);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, 0, PUNYCODE_NAME, to,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews strlen(PUNYCODE_NAME) + 1);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, PUNYCODE_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, 0, PUNYCODE_NAME, to,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews strlen(PUNYCODE_NAME));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_buffer_overflow);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: overrun test for arg `to' of decodename2()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#ifdef WITHOUT_ICONV
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews SKIP_TESTCASE;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* Normal case */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename2(ctx, IDN_DECODE_APP, AUX_EUCJP_NAME, to,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews strlen(UTF8_REVNAME) + 1, EUCJP_ENCODING_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, UTF8_REVNAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename2(ctx, IDN_DECODE_APP, AUX_EUCJP_NAME, to,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews strlen(UTF8_REVNAME), EUCJP_ENCODING_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_buffer_overflow);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* idn_res_enable(0) case */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_res_enable(0);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename2(ctx, IDN_DECODE_APP, AUX_EUCJP_NAME, to,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews strlen(AUX_EUCJP_NAME) + 1, EUCJP_ENCODING_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, AUX_EUCJP_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename2(ctx, IDN_DECODE_APP, AUX_EUCJP_NAME, to,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews strlen(AUX_EUCJP_NAME), EUCJP_ENCODING_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_buffer_overflow);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* actions=0 case */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_res_enable(1);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename2(ctx, 0, AUX_EUCJP_NAME, to,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews strlen(AUX_EUCJP_NAME) + 1, EUCJP_ENCODING_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, AUX_EUCJP_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename2(ctx, 0, AUX_EUCJP_NAME, to,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews strlen(AUX_EUCJP_NAME), EUCJP_ENCODING_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_buffer_overflow);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call encodename() with tolen=0
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_ENCODE_APP, UTF8_NAME, to, 0);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_buffer_overflow);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call decodename() with tolen=0
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, IDN_DECODE_APP, PUNYCODE_NAME, to, 0);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_buffer_overflow);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: call decodename2() with tolen=0
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#ifdef WITHOUT_ICONV
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews SKIP_TESTCASE;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename2(ctx, IDN_DECODE_APP, AUX_EUCJP_NAME, to, 0,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews EUCJP_ENCODING_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_buffer_overflow);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: convert an empty string using encodename()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_ENCODE_APP, "", to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, "");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: convert an empty string using decodename()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, IDN_DECODE_APP, "", to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, "");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: convert an empty string using decodename2()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#ifdef WITHOUT_ICONV
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews SKIP_TESTCASE;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename2(ctx, IDN_DECODE_APP, "", to, sizeof(to),
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews EUCJP_ENCODING_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, "");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: prohcheck by encodename()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* U+1680: prohibited character */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_PROHCHECK, "<U+1680>", to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_prohibited);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: unascheck by encodename()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* U+0221: unassigned codepoint */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_UNASCHECK, "<U+0221>", to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_prohibited);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: bidicheck by encodename()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* U+05D0: bidirectional property is "R" */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* `a': bidirectional property is "L" */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* `0', `-': bidirectional property is "N" */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_BIDICHECK, "<U+05D0>", to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_BIDICHECK, "<U+05D0><U+05D0>",
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_BIDICHECK, "<U+05D0><U+05D0>-a",
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_prohibited);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_BIDICHECK, "<U+05D0>-a-<U+05D0>",
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_prohibited);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_BIDICHECK, "a-<U+05D0><U+05D0>",
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_prohibited);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_BIDICHECK, "<U+05D0><U+05D0>-0",
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_prohibited);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_BIDICHECK, "<U+05D0>-0-<U+05D0>",
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_BIDICHECK, "0-<U+05D0><U+05D0>",
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_prohibited);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: asccheck by encodename()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_ASCCHECK, "-name", to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_prohibited);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_ASCCHECK, "name-", to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_prohibited);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_ASCCHECK, "n ame", to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_prohibited);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: lencheck by encodename()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_LENCHECK,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews "123456789-123456789-123456789-123456789-"
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews "123456789-123456789-123", to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_LENCHECK,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews "123456789-123456789-123456789-123456789-"
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews "123456789-123456789-1234", to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_length);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_LENCHECK, "a..b", to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_length);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: rtcheck non-prohchecked label by decodename()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* "xn--6ue" -> "U+1680" (prohibited character) */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, IDN_RTCHECK, "xn--6ue", to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, "xn--6ue");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: rtcheck non-unaschecked label by decodename()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* "xn--6la" -> "U+0221" (unassigned codepoint) */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, IDN_IDNCONV | IDN_RTCHECK | IDN_UNASCHECK,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews "xn--6la", to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, "xn--6la");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: rtcheck non-ascchecked label by decodename()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* "xn----x7t" -> "- U+3042" */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, IDN_IDNCONV | IDN_RTCHECK | IDN_ASCCHECK,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews "xn----x7t", to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, "xn----x7t");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* "xn----w7t" -> "U+3042 -" */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, IDN_IDNCONV | IDN_RTCHECK | IDN_ASCCHECK,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews "xn----w7t", to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, "xn----w7t");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: rtcheck non-lenchecked label by decodename()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* `s1' has 63 characters */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews const char *s1 =
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews "xn--l8jaa5522a8sj38bzugvvblo3y90fjzgvxlmxscifws3d43odzaq6aj340b";
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews const char *s1rev =
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews "<U+9752><U+68EE><U+5CA9><U+624B><U+5BAE><U+57CE><U+79CB><U+7530>"
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews "<U+5C71><U+5F62><U+798F><U+5CF6><U+6771><U+4EAC><U+795E><U+5948>"
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews "<U+5DDD><U+3042><U+3042><U+3042>";
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* `s2' has 64 characters */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews const char *s2 =
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews "xn--a-w7ta6522a8sj38bzugvvblo3y90fjzgvxlmxscifws3d43odzaq6aj340b";
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* `s3' has an empty label */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews const char *s3 = "a..b";
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, IDN_IDNCONV | IDN_RTCHECK, s1, to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, s1rev);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, IDN_IDNCONV | IDN_RTCHECK, s2, to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, s2);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, IDN_IDNCONV | IDN_RTCHECK, s3, to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, s3);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: rtcheck non-prohchecked label by decodename2()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#ifdef WITHOUT_ICONV
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews SKIP_TESTCASE;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* "xn--6ue" -> "U+1680" (prohibited character) */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename2(ctx, IDN_RTCHECK, "xn--6ue", to, sizeof(to),
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews EUCJP_ENCODING_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, "xn--6ue");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: rtcheck non-unaschecked label by decodename2()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#ifdef WITHOUT_ICONV
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews SKIP_TESTCASE;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* "xn--6la" -> "U+0221" (unassigned codepoint) */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename2(ctx, IDN_IDNCONV | IDN_RTCHECK | IDN_UNASCHECK,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews "xn--6la", to, sizeof(to), EUCJP_ENCODING_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, "xn--6la");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: rtcheck non-ascchecked label by decodename2()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#ifdef WITHOUT_ICONV
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews SKIP_TESTCASE;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* "xn----x7t" -> "- U+3042" */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename2(ctx, IDN_IDNCONV | IDN_RTCHECK | IDN_ASCCHECK,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews "xn----x7t", to, sizeof(to), EUCJP_ENCODING_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, "xn----x7t");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* "xn----w7t" -> "U+3042 -" */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename2(ctx, IDN_IDNCONV | IDN_RTCHECK | IDN_ASCCHECK,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews "xn----w7t", to, sizeof(to), EUCJP_ENCODING_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, "xn----w7t");
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: rtcheck non-lenchecked label by decodename2()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#ifdef WITHOUT_ICONV
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews SKIP_TESTCASE;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* `s1' has 63 characters */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews const char *s1 =
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews "xn--l8jaa5522a8sj38bzugvvblo3y90fjzgvxlmxscifws3d43odzaq6aj340b";
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews const char *s1rev =
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews "<U+9752><U+68EE><U+5CA9><U+624B><U+5BAE><U+57CE><U+79CB><U+7530>"
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews "<U+5C71><U+5F62><U+798F><U+5CF6><U+6771><U+4EAC><U+795E><U+5948>"
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews "<U+5DDD><U+3042><U+3042><U+3042>";
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* `s2' has 64 characters */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews const char *s2 =
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews "xn--a-w7ta6522a8sj38bzugvvblo3y90fjzgvxlmxscifws3d43odzaq6aj340b";
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* `s3' has an empty label */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews const char *s3 = "a..b";
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename2(ctx, IDN_IDNCONV | IDN_RTCHECK, s1, to, sizeof(to),
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews EUCJP_ENCODING_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, s1rev);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename2(ctx, IDN_IDNCONV | IDN_RTCHECK, s2, to, sizeof(to),
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews EUCJP_ENCODING_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, s2);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, IDN_IDNCONV | IDN_RTCHECK, s3, to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_success);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_STRING(to, s3);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: pass broken string as `from' to encodename()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* "\xe3\x21" is not valid UTF-8 string */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_encodename(ctx, IDN_ENCODE_APP, "\xe3\x21", to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_encoding);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: pass broken string as `from' to decodename()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* "\xe3\x21" is not valid UTF-8 string */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename(ctx, IDN_DECODE_APP, "\xe3\x21", to, sizeof(to));
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_encoding);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// title: pass broken string as `from' to decodename2()
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews// group: generic-conversion quiet
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#ifdef WITHOUT_ICONV
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews SKIP_TESTCASE;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* "\xa4\x21" is not valid EUC-JP string */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews r = idn_res_decodename2(ctx, IDN_DECODE_APP, "\xa4\x21", to, sizeof(to),
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews EUCJP_ENCODING_NAME);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_RESULT(r, idn_invalid_encoding);