1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /********************************************************************
5 * Copyright (c) 1997-2001, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 ********************************************************************/
8 /********************************************************************************
12 * Modification History:
14 * Madhu Katragadda creation
15 *********************************************************************************
20 #include "unicode/utypes.h"
21 #include "unicode/ucnv.h"
23 /* C API TEST FOR CALL BACK ROUTINES OF CODESET CONVERSION COMPONENT */
27 static void TestSkipCallBack(void);
28 static void TestStopCallBack(void);
29 static void TestSubCallBack(void);
30 static void TestSubWithValueCallBack(void);
31 static void TestLegalAndOtherCallBack(void);
32 static void TestSingleByteCallBack(void);
35 static void TestSkip(int32_t inputsize
, int32_t outputsize
);
37 static void TestStop(int32_t inputsize
, int32_t outputsize
);
39 static void TestSub(int32_t inputsize
, int32_t outputsize
);
41 static void TestSubWithValue(int32_t inputsize
, int32_t outputsize
);
43 static void TestLegalAndOthers(int32_t inputsize
, int32_t outputsize
);
44 static void TestSingleByte(int32_t inputsize
, int32_t outputsize
);
45 static void TestEBCDIC_STATEFUL_Sub(int32_t inputsize
, int32_t outputsize
);
47 /* Following will return FALSE *only* on a mismach. They will return TRUE on any other error OR success, because
48 * the error would have been emitted to log_err separately. */
50 UBool
testConvertFromUnicode(const UChar
*source
, int sourceLen
, const uint8_t *expect
, int expectLen
,
51 const char *codepage
, UConverterFromUCallback callback
, const int32_t *expectOffsets
,
52 const char *mySubChar
, int8_t len
);
55 UBool
testConvertToUnicode( const uint8_t *source
, int sourcelen
, const UChar
*expect
, int expectlen
,
56 const char *codepage
, UConverterToUCallback callback
, const int32_t *expectOffsets
,
57 const char *mySubChar
, int8_t len
);
59 UBool
testConvertFromUnicodeWithContext(const UChar
*source
, int sourceLen
, const uint8_t *expect
, int expectLen
,
60 const char *codepage
, UConverterFromUCallback callback
, const int32_t *expectOffsets
,
61 const char *mySubChar
, int8_t len
, const void* context
, UErrorCode expectedError
);
63 UBool
testConvertToUnicodeWithContext( const uint8_t *source
, int sourcelen
, const UChar
*expect
, int expectlen
,
64 const char *codepage
, UConverterToUCallback callback
, const int32_t *expectOffsets
,
65 const char *mySubChar
, int8_t len
, const void* context
, UErrorCode expectedError
);
67 static void printSeq(const uint8_t* a
, int len
);
68 static void printUSeq(const UChar
* a
, int len
);
69 static void printSeqErr(const uint8_t* a
, int len
);
70 static void printUSeqErr(const UChar
* a
, int len
);
71 static void setNuConvTestName(const char *codepage
, const char *direction
);