1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
6 * Copyright (C) 2003-2014, International Business Machines
7 * Corporation and others. All Rights Reserved.
9 *******************************************************************************
10 * file name: convtest.h
12 * tab size: 8 (not used)
15 * created on: 2003jul15
16 * created by: Markus W. Scherer
18 * Test file for data-driven conversion tests.
21 #ifndef __CONVTEST_H__
22 #define __CONVTEST_H__
24 #include "unicode/utypes.h"
26 #if !UCONFIG_NO_LEGACY_CONVERSION
28 #include "unicode/ucnv.h"
31 struct ConversionCase
{
34 const char *charset
, *cbopt
, *name
;
39 /* input and expected output */
43 int32_t unicodeLength
;
44 const int32_t *offsets
;
46 /* UTF-8 version of unicode[unicodeLength] */
53 UErrorCode outErrorCode
;
54 const uint8_t *invalidChars
;
55 const UChar
*invalidUChars
;
56 int32_t invalidLength
;
59 uint8_t resultBytes
[200];
60 UChar resultUnicode
[200];
61 int32_t resultOffsets
[200];
64 UErrorCode resultErrorCode
;
67 class ConversionTest
: public IntlTest
{
70 virtual ~ConversionTest();
72 void runIndexedTest(int32_t index
, UBool exec
, const char *&name
, char *par
=0);
75 void TestFromUnicode();
76 void TestGetUnicodeSet();
77 void TestGetUnicodeSet2();
78 void TestDefaultIgnorableCallback();
79 void TestUTF8ToUTF8Overflow();
83 ToUnicodeCase(ConversionCase
&cc
, UConverterToUCallback callback
, const char *option
);
86 FromUnicodeCase(ConversionCase
&cc
, UConverterFromUCallback callback
, const char *option
);
89 checkToUnicode(ConversionCase
&cc
, UConverter
*cnv
, const char *name
,
90 const UChar
*result
, int32_t resultLength
,
91 const int32_t *resultOffsets
,
92 UErrorCode resultErrorCode
);
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
);
101 cnv_open(const char *name
, UErrorCode
&errorCode
);
103 /* for testing direct UTF-8 conversion */
107 #endif /* #if !UCONFIG_NO_LEGACY_CONVERSION */