testmap.c revision 64339d36f8bd4db5025fe2988eda22b491a9219c
1// Copyright (C) 2016 and later: Unicode, Inc. and others. 2// License & terms of use: http://www.unicode.org/copyright.html 3/* 4********************************************************************** 5* Copyright (C) 1998-2012, International Business Machines Corporation 6* and others. All Rights Reserved. 7********************************************************************** 8* 9* File date.c 10* 11* Modification History: 12* 13* Date Name Description 14* 4/26/2000 srl created 15******************************************************************************* 16*/ 17 18#include "unicode/utypes.h" 19#include <stdio.h> 20#include <string.h> 21#include "unicode/udata.h" 22#include "unicode/ucnv.h" 23#include "ucmndata.h" 24 25extern const DataHeader U_DATA_API U_ICUDATA_ENTRY_POINT; 26 27int 28main(int argc, 29 char **argv) 30{ 31 UConverter *c; 32 UErrorCode status = U_ZERO_ERROR; 33 34 udata_setCommonData(NULL, &status); 35 printf("setCommonData(NULL) -> %s [should fail]\n", u_errorName(status)); 36 if(status != U_ILLEGAL_ARGUMENT_ERROR) 37 { 38 printf("*** FAIL: should have returned U_ILLEGAL_ARGUMENT_ERROR\n"); 39 return 1; 40 } 41 42 status = U_ZERO_ERROR; 43 udata_setCommonData(&U_ICUDATA_ENTRY_POINT, &status); 44 printf("setCommonData(%p) -> %s\n", (void*)&U_ICUDATA_ENTRY_POINT, u_errorName(status)); 45 if(U_FAILURE(status)) 46 { 47 printf("*** FAIL: should have returned U_ZERO_ERROR\n"); 48 return 1; 49 } 50 51 status = U_ZERO_ERROR; 52 c = ucnv_open("iso-8859-3", &status); 53 printf("ucnv_open(iso-8859-3)-> %p, err = %s, name=%s\n", 54 (void *)c, u_errorName(status), (!c)?"?":ucnv_getName(c,&status) ); 55 if(status != U_ZERO_ERROR) 56 { 57 printf("\n*** FAIL: should have returned U_ZERO_ERROR;\n"); 58 return 1; 59 } 60 else 61 { 62 ucnv_close(c); 63 } 64 65 status = U_ZERO_ERROR; 66 udata_setCommonData(&U_ICUDATA_ENTRY_POINT, &status); 67 printf("setCommonData(%p) -> %s [should pass]\n", (void*) &U_ICUDATA_ENTRY_POINT, u_errorName(status)); 68 if (U_FAILURE(status) || status == U_USING_DEFAULT_WARNING ) 69 { 70 printf("\n*** FAIL: should pass and not set U_USING_DEFAULT_ERROR\n"); 71 return 1; 72 } 73 74 printf("\n*** PASS PASS PASS, test PASSED!!!!!!!!\n"); 75 return 0; 76} 77