]> git.saurik.com Git - apple/icu.git/blame - icuSources/test/intltest/testidna.h
ICU-62135.0.1.tar.gz
[apple/icu.git] / icuSources / test / intltest / testidna.h
CommitLineData
f3c0d7a5
A
1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
b75a7d8f
A
3/*
4 *******************************************************************************
5 *
46f4442e 6 * Copyright (C) 2003-2006, International Business Machines
b75a7d8f
A
7 * Corporation and others. All Rights Reserved.
8 *
9 *******************************************************************************
10 * file name: testidna.h
f3c0d7a5 11 * encoding: UTF-8
b75a7d8f
A
12 * tab size: 8 (not used)
13 * indentation:4
14 *
15 * created on: 2003feb1
16 * created by: Ram Viswanadha
17 */
18
19#ifndef TESTIDNA_H
20#define TESTIDNA_H
21
22#include "unicode/utypes.h"
23
24#if !UCONFIG_NO_IDNA && !UCONFIG_NO_TRANSLITERATION
25
b75a7d8f
A
26#include "intltest.h"
27#include "unicode/parseerr.h"
374ca955 28#include "unicode/uidna.h"
b75a7d8f
A
29
30U_CDECL_BEGIN
31typedef int32_t
374ca955 32(U_EXPORT2 *TestFunc) ( const UChar *src, int32_t srcLength,
b75a7d8f
A
33 UChar *dest, int32_t destCapacity,
34 int32_t options, UParseError *parseError,
35 UErrorCode *status);
36typedef int32_t
374ca955 37(U_EXPORT2 *CompareFunc) (const UChar *s1, int32_t s1Len,
b75a7d8f
A
38 const UChar *s2, int32_t s2Len,
39 int32_t options,
40 UErrorCode *status);
41
42
43U_CDECL_END
44
45// test the API
46
47class NamePrepTransform;
48
49/**
50 * @test
51 * @summary General test of HexadecimalToUnicodeTransliterator
52 */
53class TestIDNA : public IntlTest {
54public:
55 void runIndexedTest(int32_t index, UBool exec, const char* &name, char* par=NULL);
56 void TestDataFile();
57 void TestToASCII();
58 void TestToUnicode();
59 void TestIDNToUnicode();
60 void TestIDNToASCII();
61 void TestCompare();
62 void TestErrorCases();
63 void TestChaining();
64 void TestRootLabelSeparator();
65 void TestCompareReferenceImpl();
66 void TestRefIDNA();
67 void TestIDNAMonkeyTest();
68 void TestConformance();
69 static NamePrepTransform* getInstance(UErrorCode& status);
374ca955
A
70 static NamePrepTransform* gPrep;
71 virtual ~TestIDNA();
72
b75a7d8f
A
73private:
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);
374ca955 81 void debug(const UChar* src, int32_t srcLength, int32_t options);
b75a7d8f
A
82 // main testing functions
83 void testAPI(const UChar *src, const UChar *expected, const char *testName,
84 UBool useSTD3ASCIIRules, UErrorCode expectedStatus,
374ca955 85 UBool doCompare, UBool testUnassigned, TestFunc func, UBool testSTD3ASCIIRules=TRUE);
b75a7d8f
A
86
87 void testCompare(const UChar* s1, int32_t s1Len,
88 const UChar* s2, int32_t s2Len,
89 const char* testName, CompareFunc func,
90 UBool isEqual);
91
374ca955 92 void testErrorCases(const char* IDNToASCIIName, TestFunc IDNToASCII,
b75a7d8f
A
93 const char* IDNToUnicodeName, TestFunc IDNToUnicode);
94
46f4442e 95 void testChaining(const UChar* src,int32_t numIterations,const char* testName,
b75a7d8f
A
96 UBool useSTD3ASCIIRules, UBool caseInsensitive, TestFunc func);
97
98 void testRootLabelSeparator(const char* testName, CompareFunc func,
99 const char* IDNToASCIIName, TestFunc IDNToASCII,
100 const char* IDNToUnicodeName, TestFunc IDNToUnicode);
101
102 void testCompareReferenceImpl(const UChar* src, int32_t srcLen);
374ca955
A
103
104 UnicodeString testCompareReferenceImpl(UnicodeString& src,
105 TestFunc refIDNA, const char* refIDNAName,
106 TestFunc uIDNA, const char* uIDNAName,
107 int32_t options);
b75a7d8f
A
108
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
113 );
114
115};
116
117// test the TRIE data structure
118int testData(TestIDNA& test);
119
120#endif /* #if !UCONFIG_NO_IDNA */
121
122#endif