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