2 *******************************************************************************
4 * Copyright (C) 2003-2014, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
8 * file name: convtest.h
10 * tab size: 8 (not used)
13 * created on: 2003jul15
14 * created by: Markus W. Scherer
16 * Test file for data-driven conversion tests.
19 #ifndef __CONVTEST_H__
20 #define __CONVTEST_H__
22 #include "unicode/utypes.h"
24 #if !UCONFIG_NO_LEGACY_CONVERSION
26 #include "unicode/ucnv.h"
29 struct ConversionCase
{
32 const char *charset
, *cbopt
, *name
;
37 /* input and expected output */
41 int32_t unicodeLength
;
42 const int32_t *offsets
;
44 /* UTF-8 version of unicode[unicodeLength] */
51 UErrorCode outErrorCode
;
52 const uint8_t *invalidChars
;
53 const UChar
*invalidUChars
;
54 int32_t invalidLength
;
57 uint8_t resultBytes
[200];
58 UChar resultUnicode
[200];
59 int32_t resultOffsets
[200];
62 UErrorCode resultErrorCode
;
65 class ConversionTest
: public IntlTest
{
68 virtual ~ConversionTest();
70 void runIndexedTest(int32_t index
, UBool exec
, const char *&name
, char *par
=0);
73 void TestFromUnicode();
74 void TestGetUnicodeSet();
75 void TestGetUnicodeSet2();
76 void TestDefaultIgnorableCallback();
80 ToUnicodeCase(ConversionCase
&cc
, UConverterToUCallback callback
, const char *option
);
83 FromUnicodeCase(ConversionCase
&cc
, UConverterFromUCallback callback
, const char *option
);
86 checkToUnicode(ConversionCase
&cc
, UConverter
*cnv
, const char *name
,
87 const UChar
*result
, int32_t resultLength
,
88 const int32_t *resultOffsets
,
89 UErrorCode resultErrorCode
);
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
);
98 cnv_open(const char *name
, UErrorCode
&errorCode
);
100 /* for testing direct UTF-8 conversion */
104 #endif /* #if !UCONFIG_NO_LEGACY_CONVERSION */