2017-01-20 00:20:31 +00:00
|
|
|
// © 2016 and later: Unicode, Inc. and others.
|
2016-06-15 18:58:17 +00:00
|
|
|
// License & terms of use: http://www.unicode.org/copyright.html
|
2003-02-28 21:37:55 +00:00
|
|
|
/*
|
|
|
|
*******************************************************************************
|
|
|
|
*
|
2016-05-31 21:45:07 +00:00
|
|
|
* Copyright (C) 2003-2006, International Business Machines
|
|
|
|
* Corporation and others. All Rights Reserved.
|
2003-02-28 21:37:55 +00:00
|
|
|
*
|
|
|
|
*******************************************************************************
|
2003-05-06 01:22:23 +00:00
|
|
|
* file name: testidna.h
|
2017-02-03 18:57:23 +00:00
|
|
|
* encoding: UTF-8
|
2003-02-28 21:37:55 +00:00
|
|
|
* tab size: 8 (not used)
|
|
|
|
* indentation:4
|
|
|
|
*
|
|
|
|
* created on: 2003feb1
|
|
|
|
* created by: Ram Viswanadha
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TESTIDNA_H
|
|
|
|
#define TESTIDNA_H
|
|
|
|
|
2003-05-06 01:22:23 +00:00
|
|
|
#include "unicode/utypes.h"
|
|
|
|
|
2003-05-29 01:15:29 +00:00
|
|
|
#if !UCONFIG_NO_IDNA && !UCONFIG_NO_TRANSLITERATION
|
2003-05-06 01:22:23 +00:00
|
|
|
|
2003-02-28 21:37:55 +00:00
|
|
|
#include "intltest.h"
|
|
|
|
#include "unicode/parseerr.h"
|
2004-04-09 16:39:02 +00:00
|
|
|
#include "unicode/uidna.h"
|
2003-02-28 21:37:55 +00:00
|
|
|
|
2003-03-20 01:11:51 +00:00
|
|
|
U_CDECL_BEGIN
|
2003-02-28 21:37:55 +00:00
|
|
|
typedef int32_t
|
2004-07-16 15:44:52 +00:00
|
|
|
(U_EXPORT2 *TestFunc) ( const UChar *src, int32_t srcLength,
|
2003-02-28 21:37:55 +00:00
|
|
|
UChar *dest, int32_t destCapacity,
|
|
|
|
int32_t options, UParseError *parseError,
|
|
|
|
UErrorCode *status);
|
|
|
|
typedef int32_t
|
2004-07-16 15:44:52 +00:00
|
|
|
(U_EXPORT2 *CompareFunc) (const UChar *s1, int32_t s1Len,
|
2003-02-28 21:37:55 +00:00
|
|
|
const UChar *s2, int32_t s2Len,
|
|
|
|
int32_t options,
|
|
|
|
UErrorCode *status);
|
|
|
|
|
|
|
|
|
2003-03-20 01:11:51 +00:00
|
|
|
U_CDECL_END
|
2003-02-28 21:37:55 +00:00
|
|
|
|
|
|
|
// test the API
|
|
|
|
|
2003-04-22 15:49:53 +00:00
|
|
|
class NamePrepTransform;
|
2003-02-28 21:37:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
* @summary General test of HexadecimalToUnicodeTransliterator
|
|
|
|
*/
|
|
|
|
class TestIDNA : public IntlTest {
|
|
|
|
public:
|
|
|
|
void runIndexedTest(int32_t index, UBool exec, const char* &name, char* par=NULL);
|
|
|
|
void TestDataFile();
|
|
|
|
void TestToASCII();
|
|
|
|
void TestToUnicode();
|
|
|
|
void TestIDNToUnicode();
|
|
|
|
void TestIDNToASCII();
|
|
|
|
void TestCompare();
|
|
|
|
void TestErrorCases();
|
|
|
|
void TestChaining();
|
|
|
|
void TestRootLabelSeparator();
|
|
|
|
void TestCompareReferenceImpl();
|
|
|
|
void TestRefIDNA();
|
|
|
|
void TestIDNAMonkeyTest();
|
2003-04-01 02:00:54 +00:00
|
|
|
void TestConformance();
|
2003-04-23 00:30:02 +00:00
|
|
|
static NamePrepTransform* getInstance(UErrorCode& status);
|
2004-01-06 21:52:08 +00:00
|
|
|
static NamePrepTransform* gPrep;
|
2003-11-26 23:15:27 +00:00
|
|
|
virtual ~TestIDNA();
|
2003-07-28 23:48:47 +00:00
|
|
|
|
2003-02-28 21:37:55 +00:00
|
|
|
private:
|
|
|
|
void testToASCII(const char* testName, TestFunc func);
|
|
|
|
void testToUnicode(const char* testName, TestFunc func);
|
|
|
|
void testIDNToUnicode(const char* testName, TestFunc func);
|
|
|
|
void testIDNToASCII(const char* testName, TestFunc func);
|
|
|
|
void testCompare(const char* testName, CompareFunc func);
|
|
|
|
void testChaining(const char* toASCIIName, TestFunc toASCII,
|
|
|
|
const char* toUnicodeName, TestFunc toUnicode);
|
2003-07-24 23:23:19 +00:00
|
|
|
void debug(const UChar* src, int32_t srcLength, int32_t options);
|
2003-02-28 21:37:55 +00:00
|
|
|
// main testing functions
|
|
|
|
void testAPI(const UChar *src, const UChar *expected, const char *testName,
|
|
|
|
UBool useSTD3ASCIIRules, UErrorCode expectedStatus,
|
2004-04-09 16:39:02 +00:00
|
|
|
UBool doCompare, UBool testUnassigned, TestFunc func, UBool testSTD3ASCIIRules=TRUE);
|
2003-02-28 21:37:55 +00:00
|
|
|
|
|
|
|
void testCompare(const UChar* s1, int32_t s1Len,
|
|
|
|
const UChar* s2, int32_t s2Len,
|
|
|
|
const char* testName, CompareFunc func,
|
|
|
|
UBool isEqual);
|
|
|
|
|
2004-06-15 21:25:06 +00:00
|
|
|
void testErrorCases(const char* IDNToASCIIName, TestFunc IDNToASCII,
|
2003-02-28 21:37:55 +00:00
|
|
|
const char* IDNToUnicodeName, TestFunc IDNToUnicode);
|
|
|
|
|
2006-10-01 06:45:25 +00:00
|
|
|
void testChaining(const UChar* src,int32_t numIterations,const char* testName,
|
2003-02-28 21:37:55 +00:00
|
|
|
UBool useSTD3ASCIIRules, UBool caseInsensitive, TestFunc func);
|
|
|
|
|
|
|
|
void testRootLabelSeparator(const char* testName, CompareFunc func,
|
|
|
|
const char* IDNToASCIIName, TestFunc IDNToASCII,
|
|
|
|
const char* IDNToUnicodeName, TestFunc IDNToUnicode);
|
|
|
|
|
|
|
|
void testCompareReferenceImpl(const UChar* src, int32_t srcLen);
|
2004-04-09 16:39:02 +00:00
|
|
|
|
|
|
|
UnicodeString testCompareReferenceImpl(UnicodeString& src,
|
|
|
|
TestFunc refIDNA, const char* refIDNAName,
|
|
|
|
TestFunc uIDNA, const char* uIDNAName,
|
|
|
|
int32_t options);
|
2003-04-01 02:00:54 +00:00
|
|
|
|
|
|
|
void testConformance(const char* toASCIIName, TestFunc toASCII,
|
|
|
|
const char* IDNToASCIIName, TestFunc IDNToASCII,
|
|
|
|
const char* IDNToUnicodeName, TestFunc IDNToUnicode,
|
|
|
|
const char* toUnicodeName, TestFunc toUnicode
|
|
|
|
);
|
2003-04-22 15:49:53 +00:00
|
|
|
|
2003-02-28 21:37:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// test the TRIE data structure
|
|
|
|
int testData(TestIDNA& test);
|
|
|
|
|
2003-05-06 01:22:23 +00:00
|
|
|
#endif /* #if !UCONFIG_NO_IDNA */
|
|
|
|
|
2003-02-28 21:37:55 +00:00
|
|
|
#endif
|