]>
Commit | Line | Data |
---|---|---|
374ca955 | 1 | /* |
46f4442e A |
2 | ******************************************************************************* |
3 | * | |
b331163b | 4 | * Copyright (C) 2003-2014, International Business Machines |
46f4442e A |
5 | * Corporation and others. All Rights Reserved. |
6 | * | |
7 | ******************************************************************************* | |
8 | * file name: convtest.h | |
9 | * encoding: US-ASCII | |
10 | * tab size: 8 (not used) | |
11 | * indentation:4 | |
12 | * | |
13 | * created on: 2003jul15 | |
14 | * created by: Markus W. Scherer | |
15 | * | |
16 | * Test file for data-driven conversion tests. | |
17 | */ | |
374ca955 A |
18 | |
19 | #ifndef __CONVTEST_H__ | |
20 | #define __CONVTEST_H__ | |
21 | ||
22 | #include "unicode/utypes.h" | |
23 | ||
24 | #if !UCONFIG_NO_LEGACY_CONVERSION | |
25 | ||
26 | #include "unicode/ucnv.h" | |
27 | #include "intltest.h" | |
28 | ||
29 | struct ConversionCase { | |
46f4442e | 30 | /* setup */ |
374ca955 A |
31 | int32_t caseNr; |
32 | const char *charset, *cbopt, *name; | |
73c04bcf | 33 | UChar subString[16]; |
374ca955 | 34 | char subchar[8]; |
73c04bcf | 35 | int8_t setSub; |
374ca955 | 36 | |
46f4442e | 37 | /* input and expected output */ |
374ca955 A |
38 | const uint8_t *bytes; |
39 | int32_t bytesLength; | |
40 | const UChar *unicode; | |
41 | int32_t unicodeLength; | |
42 | const int32_t *offsets; | |
43 | ||
46f4442e A |
44 | /* UTF-8 version of unicode[unicodeLength] */ |
45 | const char *utf8; | |
46 | int32_t utf8Length; | |
47 | ||
48 | /* options */ | |
374ca955 A |
49 | UBool finalFlush; |
50 | UBool fallbacks; | |
51 | UErrorCode outErrorCode; | |
52 | const uint8_t *invalidChars; | |
53 | const UChar *invalidUChars; | |
54 | int32_t invalidLength; | |
55 | ||
46f4442e | 56 | /* actual output */ |
374ca955 A |
57 | uint8_t resultBytes[200]; |
58 | UChar resultUnicode[200]; | |
59 | int32_t resultOffsets[200]; | |
60 | int32_t resultLength; | |
61 | ||
62 | UErrorCode resultErrorCode; | |
63 | }; | |
64 | ||
65 | class ConversionTest : public IntlTest { | |
66 | public: | |
46f4442e | 67 | ConversionTest(); |
374ca955 A |
68 | virtual ~ConversionTest(); |
69 | ||
70 | void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par=0); | |
71 | ||
72 | void TestToUnicode(); | |
73 | void TestFromUnicode(); | |
74 | void TestGetUnicodeSet(); | |
46f4442e | 75 | void TestGetUnicodeSet2(); |
b331163b | 76 | void TestDefaultIgnorableCallback(); |
374ca955 A |
77 | |
78 | private: | |
79 | UBool | |
80 | ToUnicodeCase(ConversionCase &cc, UConverterToUCallback callback, const char *option); | |
81 | ||
82 | UBool | |
83 | FromUnicodeCase(ConversionCase &cc, UConverterFromUCallback callback, const char *option); | |
84 | ||
85 | UBool | |
86 | checkToUnicode(ConversionCase &cc, UConverter *cnv, const char *name, | |
87 | const UChar *result, int32_t resultLength, | |
88 | const int32_t *resultOffsets, | |
89 | UErrorCode resultErrorCode); | |
90 | ||
91 | UBool | |
92 | checkFromUnicode(ConversionCase &cc, UConverter *cnv, const char *name, | |
93 | const uint8_t *result, int32_t resultLength, | |
94 | const int32_t *resultOffsets, | |
95 | UErrorCode resultErrorCode); | |
96 | ||
97 | UConverter * | |
98 | cnv_open(const char *name, UErrorCode &errorCode); | |
46f4442e A |
99 | |
100 | /* for testing direct UTF-8 conversion */ | |
101 | UConverter *utf8Cnv; | |
374ca955 A |
102 | }; |
103 | ||
104 | #endif /* #if !UCONFIG_NO_LEGACY_CONVERSION */ | |
105 | ||
106 | #endif |