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