1 // Copyright (C) 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
6 * Copyright (C) 2003-2006, International Business Machines
7 * Corporation and others. All Rights Reserved.
9 *******************************************************************************
10 * file name: testidna.h
12 * tab size: 8 (not used)
15 * created on: 2003feb1
16 * created by: Ram Viswanadha
22 #include "unicode/utypes.h"
24 #if !UCONFIG_NO_IDNA && !UCONFIG_NO_TRANSLITERATION
27 #include "unicode/parseerr.h"
28 #include "unicode/uidna.h"
32 (U_EXPORT2 *TestFunc) ( const UChar *src, int32_t srcLength,
33 UChar *dest, int32_t destCapacity,
34 int32_t options, UParseError *parseError,
37 (U_EXPORT2 *CompareFunc) (const UChar *s1, int32_t s1Len,
38 const UChar *s2, int32_t s2Len,
47 class NamePrepTransform;
51 * @summary General test of HexadecimalToUnicodeTransliterator
53 class TestIDNA : public IntlTest {
55 void runIndexedTest(int32_t index, UBool exec, const char* &name, char* par=NULL);
59 void TestIDNToUnicode();
60 void TestIDNToASCII();
62 void TestErrorCases();
64 void TestRootLabelSeparator();
65 void TestCompareReferenceImpl();
67 void TestIDNAMonkeyTest();
68 void TestConformance();
69 static NamePrepTransform* getInstance(UErrorCode& status);
70 static NamePrepTransform* gPrep;
74 void testToASCII(const char* testName, TestFunc func);
75 void testToUnicode(const char* testName, TestFunc func);
76 void testIDNToUnicode(const char* testName, TestFunc func);
77 void testIDNToASCII(const char* testName, TestFunc func);
78 void testCompare(const char* testName, CompareFunc func);
79 void testChaining(const char* toASCIIName, TestFunc toASCII,
80 const char* toUnicodeName, TestFunc toUnicode);
81 void debug(const UChar* src, int32_t srcLength, int32_t options);
82 // main testing functions
83 void testAPI(const UChar *src, const UChar *expected, const char *testName,
84 UBool useSTD3ASCIIRules, UErrorCode expectedStatus,
85 UBool doCompare, UBool testUnassigned, TestFunc func, UBool testSTD3ASCIIRules=TRUE);
87 void testCompare(const UChar* s1, int32_t s1Len,
88 const UChar* s2, int32_t s2Len,
89 const char* testName, CompareFunc func,
92 void testErrorCases(const char* IDNToASCIIName, TestFunc IDNToASCII,
93 const char* IDNToUnicodeName, TestFunc IDNToUnicode);
95 void testChaining(const UChar* src,int32_t numIterations,const char* testName,
96 UBool useSTD3ASCIIRules, UBool caseInsensitive, TestFunc func);
98 void testRootLabelSeparator(const char* testName, CompareFunc func,
99 const char* IDNToASCIIName, TestFunc IDNToASCII,
100 const char* IDNToUnicodeName, TestFunc IDNToUnicode);
102 void testCompareReferenceImpl(const UChar* src, int32_t srcLen);
104 UnicodeString testCompareReferenceImpl(UnicodeString& src,
105 TestFunc refIDNA, const char* refIDNAName,
106 TestFunc uIDNA, const char* uIDNAName,
109 void testConformance(const char* toASCIIName, TestFunc toASCII,
110 const char* IDNToASCIIName, TestFunc IDNToASCII,
111 const char* IDNToUnicodeName, TestFunc IDNToUnicode,
112 const char* toUnicodeName, TestFunc toUnicode
117 // test the TRIE data structure
118 int testData(TestIDNA& test);
120 #endif /* #if !UCONFIG_NO_IDNA */