1 /********************************************************************
3 * Copyright (c) 1997-2001, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 ********************************************************************/
6 /********************************************************************************
10 * Modification History:
12 * Madhu Katragadda creation
13 *********************************************************************************
17 /* C API TEST FOR CALL BACK ROUTINES OF CODESET CONVERSION COMPONENT */
19 #include "unicode/utypes.h"
22 static void TestSkipCallBack(void);
23 static void TestStopCallBack(void);
24 static void TestSubCallBack(void);
25 static void TestSubWithValueCallBack(void);
26 static void TestLegalAndOtherCallBack(void);
27 static void TestSingleByteCallBack(void);
30 static void TestSkip(int32_t inputsize
, int32_t outputsize
);
32 static void TestStop(int32_t inputsize
, int32_t outputsize
);
34 static void TestSub(int32_t inputsize
, int32_t outputsize
);
36 static void TestSubWithValue(int32_t inputsize
, int32_t outputsize
);
38 static void TestLegalAndOthers(int32_t inputsize
, int32_t outputsize
);
39 static void TestSingleByte(int32_t inputsize
, int32_t outputsize
);
40 static void TestEBCDIC_STATEFUL_Sub(int32_t inputsize
, int32_t outputsize
);
42 /* Following will return FALSE *only* on a mismach. They will return TRUE on any other error OR success, because
43 * the error would have been emitted to log_err separately. */
45 UBool
testConvertFromUnicode(const UChar
*source
, int sourceLen
, const uint8_t *expect
, int expectLen
,
46 const char *codepage
, UConverterFromUCallback callback
, const int32_t *expectOffsets
,
47 const char *mySubChar
, int8_t len
);
50 UBool
testConvertToUnicode( const uint8_t *source
, int sourcelen
, const UChar
*expect
, int expectlen
,
51 const char *codepage
, UConverterToUCallback callback
, const int32_t *expectOffsets
,
52 const char *mySubChar
, int8_t len
);
54 UBool
testConvertFromUnicodeWithContext(const UChar
*source
, int sourceLen
, const uint8_t *expect
, int expectLen
,
55 const char *codepage
, UConverterFromUCallback callback
, const int32_t *expectOffsets
,
56 const char *mySubChar
, int8_t len
, const void* context
, UErrorCode expectedError
);
58 UBool
testConvertToUnicodeWithContext( const uint8_t *source
, int sourcelen
, const UChar
*expect
, int expectlen
,
59 const char *codepage
, UConverterToUCallback callback
, const int32_t *expectOffsets
,
60 const char *mySubChar
, int8_t len
, const void* context
, UErrorCode expectedError
);
62 static void printSeq(const uint8_t* a
, int len
);
63 static void printUSeq(const UChar
* a
, int len
);
64 static void printSeqErr(const uint8_t* a
, int len
);
65 static void printUSeqErr(const UChar
* a
, int len
);
66 static void setNuConvTestName(const char *codepage
, const char *direction
);