10596faeddefbf198de137d5e893708495ab1584cFredrik Roubert// © 2016 and later: Unicode, Inc. and others. 264339d36f8bd4db5025fe2988eda22b491a9219cFredrik Roubert// License & terms of use: http://www.unicode.org/copyright.html 3ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/* 4ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ******************************************************************************* 5ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 6ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Copyright (C) 2003-2006, International Business Machines 7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Corporation and others. All Rights Reserved. 8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ******************************************************************************* 10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * file name: testidna.h 110596faeddefbf198de137d5e893708495ab1584cFredrik Roubert * encoding: UTF-8 12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * tab size: 8 (not used) 13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * indentation:4 14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * created on: 2003feb1 16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * created by: Ram Viswanadha 17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#ifndef TESTIDNA_H 20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define TESTIDNA_H 21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/utypes.h" 23ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if !UCONFIG_NO_IDNA && !UCONFIG_NO_TRANSLITERATION 25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "intltest.h" 27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/parseerr.h" 28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/uidna.h" 29ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CDECL_BEGIN 31ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querutypedef int32_t 32ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru(U_EXPORT2 *TestFunc) ( const UChar *src, int32_t srcLength, 33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UChar *dest, int32_t destCapacity, 34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t options, UParseError *parseError, 35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UErrorCode *status); 36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querutypedef int32_t 37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru(U_EXPORT2 *CompareFunc) (const UChar *s1, int32_t s1Len, 38ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const UChar *s2, int32_t s2Len, 39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t options, 40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UErrorCode *status); 41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 42ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CDECL_END 44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// test the API 46ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 47ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass NamePrepTransform; 48ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 49ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/** 50ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @test 51ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @summary General test of HexadecimalToUnicodeTransliterator 52ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 53ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass TestIDNA : public IntlTest { 54ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic: 55ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void runIndexedTest(int32_t index, UBool exec, const char* &name, char* par=NULL); 56ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void TestDataFile(); 57ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void TestToASCII(); 58ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void TestToUnicode(); 59ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void TestIDNToUnicode(); 60ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void TestIDNToASCII(); 61ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void TestCompare(); 62ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void TestErrorCases(); 63ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void TestChaining(); 64ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void TestRootLabelSeparator(); 65ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void TestCompareReferenceImpl(); 66ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void TestRefIDNA(); 67ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void TestIDNAMonkeyTest(); 68ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void TestConformance(); 69ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static NamePrepTransform* getInstance(UErrorCode& status); 70ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru static NamePrepTransform* gPrep; 71ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual ~TestIDNA(); 72ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 73ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprivate: 74ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void testToASCII(const char* testName, TestFunc func); 75ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void testToUnicode(const char* testName, TestFunc func); 76ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void testIDNToUnicode(const char* testName, TestFunc func); 77ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void testIDNToASCII(const char* testName, TestFunc func); 78ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void testCompare(const char* testName, CompareFunc func); 79ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void testChaining(const char* toASCIIName, TestFunc toASCII, 80ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const char* toUnicodeName, TestFunc toUnicode); 81ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void debug(const UChar* src, int32_t srcLength, int32_t options); 82ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru // main testing functions 83ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void testAPI(const UChar *src, const UChar *expected, const char *testName, 84ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UBool useSTD3ASCIIRules, UErrorCode expectedStatus, 85ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UBool doCompare, UBool testUnassigned, TestFunc func, UBool testSTD3ASCIIRules=TRUE); 86ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 87ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void testCompare(const UChar* s1, int32_t s1Len, 88ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const UChar* s2, int32_t s2Len, 89ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const char* testName, CompareFunc func, 90ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UBool isEqual); 91ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 92ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void testErrorCases(const char* IDNToASCIIName, TestFunc IDNToASCII, 93ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const char* IDNToUnicodeName, TestFunc IDNToUnicode); 94ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 95ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void testChaining(const UChar* src,int32_t numIterations,const char* testName, 96ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UBool useSTD3ASCIIRules, UBool caseInsensitive, TestFunc func); 97ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 98ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void testRootLabelSeparator(const char* testName, CompareFunc func, 99ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const char* IDNToASCIIName, TestFunc IDNToASCII, 100ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const char* IDNToUnicodeName, TestFunc IDNToUnicode); 101ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void testCompareReferenceImpl(const UChar* src, int32_t srcLen); 103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UnicodeString testCompareReferenceImpl(UnicodeString& src, 105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru TestFunc refIDNA, const char* refIDNAName, 106ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru TestFunc uIDNA, const char* uIDNAName, 107ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t options); 108ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 109ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void testConformance(const char* toASCIIName, TestFunc toASCII, 110ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const char* IDNToASCIIName, TestFunc IDNToASCII, 111ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const char* IDNToUnicodeName, TestFunc IDNToUnicode, 112ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const char* toUnicodeName, TestFunc toUnicode 113ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ); 114ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 115ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}; 116ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 117ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// test the TRIE data structure 118ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruint testData(TestIDNA& test); 119ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 120ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif /* #if !UCONFIG_NO_IDNA */ 121ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 122ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif 123