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