2 *******************************************************************************
4 * Copyright (C) 2003-2007, 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();
79 ToUnicodeCase(ConversionCase
&cc
, UConverterToUCallback callback
, const char *option
);
82 FromUnicodeCase(ConversionCase
&cc
, UConverterFromUCallback callback
, const char *option
);
85 checkToUnicode(ConversionCase
&cc
, UConverter
*cnv
, const char *name
,
86 const UChar
*result
, int32_t resultLength
,
87 const int32_t *resultOffsets
,
88 UErrorCode resultErrorCode
);
91 checkFromUnicode(ConversionCase
&cc
, UConverter
*cnv
, const char *name
,
92 const uint8_t *result
, int32_t resultLength
,
93 const int32_t *resultOffsets
,
94 UErrorCode resultErrorCode
);
97 cnv_open(const char *name
, UErrorCode
&errorCode
);
99 /* for testing direct UTF-8 conversion */
103 #endif /* #if !UCONFIG_NO_LEGACY_CONVERSION */