]> git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/convtest.h
ICU-8.11.2.tar.gz
[apple/icu.git] / icuSources / test / intltest / convtest.h
1 /*
2 *******************************************************************************
3 *
4 * Copyright (C) 2003-2006, International Business Machines
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 */
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 {
30 int32_t caseNr;
31 const char *charset, *cbopt, *name;
32 UChar subString[16];
33 char subchar[8];
34 int8_t setSub;
35
36 const uint8_t *bytes;
37 int32_t bytesLength;
38 const UChar *unicode;
39 int32_t unicodeLength;
40 const int32_t *offsets;
41
42 UBool finalFlush;
43 UBool fallbacks;
44 UErrorCode outErrorCode;
45 const uint8_t *invalidChars;
46 const UChar *invalidUChars;
47 int32_t invalidLength;
48
49 uint8_t resultBytes[200];
50 UChar resultUnicode[200];
51 int32_t resultOffsets[200];
52 int32_t resultLength;
53
54 UErrorCode resultErrorCode;
55 };
56
57 class ConversionTest : public IntlTest {
58 public:
59 ConversionTest() {}
60 virtual ~ConversionTest();
61
62 void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par=0);
63
64 void TestToUnicode();
65 void TestFromUnicode();
66 void TestGetUnicodeSet();
67
68 private:
69 UBool
70 ToUnicodeCase(ConversionCase &cc, UConverterToUCallback callback, const char *option);
71
72 UBool
73 FromUnicodeCase(ConversionCase &cc, UConverterFromUCallback callback, const char *option);
74
75 UBool
76 checkToUnicode(ConversionCase &cc, UConverter *cnv, const char *name,
77 const UChar *result, int32_t resultLength,
78 const int32_t *resultOffsets,
79 UErrorCode resultErrorCode);
80
81 UBool
82 checkFromUnicode(ConversionCase &cc, UConverter *cnv, const char *name,
83 const uint8_t *result, int32_t resultLength,
84 const int32_t *resultOffsets,
85 UErrorCode resultErrorCode);
86
87 UConverter *
88 cnv_open(const char *name, UErrorCode &errorCode);
89 };
90
91 #endif /* #if !UCONFIG_NO_LEGACY_CONVERSION */
92
93 #endif