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