]> git.saurik.com Git - apple/icu.git/blame - icuSources/test/intltest/testidna.h
ICU-66108.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();
340931cb
A
69 NamePrepTransform* getInstance(UErrorCode& status);
70 NamePrepTransform* gPrep;
71 TestIDNA() : gPrep(nullptr) {}
374ca955
A
72 virtual ~TestIDNA();
73
b75a7d8f
A
74private:
75 void testToASCII(const char* testName, TestFunc func);
76 void testToUnicode(const char* testName, TestFunc func);
77 void testIDNToUnicode(const char* testName, TestFunc func);
78 void testIDNToASCII(const char* testName, TestFunc func);
79 void testCompare(const char* testName, CompareFunc func);
80 void testChaining(const char* toASCIIName, TestFunc toASCII,
81 const char* toUnicodeName, TestFunc toUnicode);
374ca955 82 void debug(const UChar* src, int32_t srcLength, int32_t options);
b75a7d8f
A
83 // main testing functions
84 void testAPI(const UChar *src, const UChar *expected, const char *testName,
85 UBool useSTD3ASCIIRules, UErrorCode expectedStatus,
374ca955 86 UBool doCompare, UBool testUnassigned, TestFunc func, UBool testSTD3ASCIIRules=TRUE);
b75a7d8f
A
87
88 void testCompare(const UChar* s1, int32_t s1Len,
89 const UChar* s2, int32_t s2Len,
90 const char* testName, CompareFunc func,
91 UBool isEqual);
92
374ca955 93 void testErrorCases(const char* IDNToASCIIName, TestFunc IDNToASCII,
b75a7d8f
A
94 const char* IDNToUnicodeName, TestFunc IDNToUnicode);
95
46f4442e 96 void testChaining(const UChar* src,int32_t numIterations,const char* testName,
b75a7d8f
A
97 UBool useSTD3ASCIIRules, UBool caseInsensitive, TestFunc func);
98
99 void testRootLabelSeparator(const char* testName, CompareFunc func,
100 const char* IDNToASCIIName, TestFunc IDNToASCII,
101 const char* IDNToUnicodeName, TestFunc IDNToUnicode);
102
103 void testCompareReferenceImpl(const UChar* src, int32_t srcLen);
374ca955
A
104
105 UnicodeString testCompareReferenceImpl(UnicodeString& src,
106 TestFunc refIDNA, const char* refIDNAName,
107 TestFunc uIDNA, const char* uIDNAName,
108 int32_t options);
b75a7d8f
A
109
110 void testConformance(const char* toASCIIName, TestFunc toASCII,
111 const char* IDNToASCIIName, TestFunc IDNToASCII,
112 const char* IDNToUnicodeName, TestFunc IDNToUnicode,
113 const char* toUnicodeName, TestFunc toUnicode
114 );
115
116};
117
118// test the TRIE data structure
119int testData(TestIDNA& test);
120
121#endif /* #if !UCONFIG_NO_IDNA */
122
123#endif