2 *******************************************************************************
4 * Copyright (C) 2003-2006, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
8 * file name: testidna.h
10 * tab size: 8 (not used)
13 * created on: 2003feb1
14 * created by: Ram Viswanadha
20 #include "unicode/utypes.h"
22 #if !UCONFIG_NO_IDNA && !UCONFIG_NO_TRANSLITERATION
25 #include "unicode/parseerr.h"
26 #include "unicode/uidna.h"
30 (U_EXPORT2
*TestFunc
) ( const UChar
*src
, int32_t srcLength
,
31 UChar
*dest
, int32_t destCapacity
,
32 int32_t options
, UParseError
*parseError
,
35 (U_EXPORT2
*CompareFunc
) (const UChar
*s1
, int32_t s1Len
,
36 const UChar
*s2
, int32_t s2Len
,
45 class NamePrepTransform
;
49 * @summary General test of HexadecimalToUnicodeTransliterator
51 class TestIDNA
: public IntlTest
{
53 void runIndexedTest(int32_t index
, UBool exec
, const char* &name
, char* par
=NULL
);
57 void TestIDNToUnicode();
58 void TestIDNToASCII();
60 void TestErrorCases();
62 void TestRootLabelSeparator();
63 void TestCompareReferenceImpl();
65 void TestIDNAMonkeyTest();
66 void TestConformance();
67 static NamePrepTransform
* getInstance(UErrorCode
& status
);
68 static NamePrepTransform
* gPrep
;
72 void testToASCII(const char* testName
, TestFunc func
);
73 void testToUnicode(const char* testName
, TestFunc func
);
74 void testIDNToUnicode(const char* testName
, TestFunc func
);
75 void testIDNToASCII(const char* testName
, TestFunc func
);
76 void testCompare(const char* testName
, CompareFunc func
);
77 void testChaining(const char* toASCIIName
, TestFunc toASCII
,
78 const char* toUnicodeName
, TestFunc toUnicode
);
79 void debug(const UChar
* src
, int32_t srcLength
, int32_t options
);
80 // main testing functions
81 void testAPI(const UChar
*src
, const UChar
*expected
, const char *testName
,
82 UBool useSTD3ASCIIRules
, UErrorCode expectedStatus
,
83 UBool doCompare
, UBool testUnassigned
, TestFunc func
, UBool testSTD3ASCIIRules
=TRUE
);
85 void testCompare(const UChar
* s1
, int32_t s1Len
,
86 const UChar
* s2
, int32_t s2Len
,
87 const char* testName
, CompareFunc func
,
90 void testErrorCases(const char* IDNToASCIIName
, TestFunc IDNToASCII
,
91 const char* IDNToUnicodeName
, TestFunc IDNToUnicode
);
93 void testChaining(const UChar
* src
,int32_t numIterations
,const char* testName
,
94 UBool useSTD3ASCIIRules
, UBool caseInsensitive
, TestFunc func
);
96 void testRootLabelSeparator(const char* testName
, CompareFunc func
,
97 const char* IDNToASCIIName
, TestFunc IDNToASCII
,
98 const char* IDNToUnicodeName
, TestFunc IDNToUnicode
);
100 void testCompareReferenceImpl(const UChar
* src
, int32_t srcLen
);
102 UnicodeString
testCompareReferenceImpl(UnicodeString
& src
,
103 TestFunc refIDNA
, const char* refIDNAName
,
104 TestFunc uIDNA
, const char* uIDNAName
,
107 void testConformance(const char* toASCIIName
, TestFunc toASCII
,
108 const char* IDNToASCIIName
, TestFunc IDNToASCII
,
109 const char* IDNToUnicodeName
, TestFunc IDNToUnicode
,
110 const char* toUnicodeName
, TestFunc toUnicode
115 // test the TRIE data structure
116 int testData(TestIDNA
& test
);
118 #endif /* #if !UCONFIG_NO_IDNA */