OLD | NEW |
1 /******************************************************************** | 1 /******************************************************************** |
2 * COPYRIGHT: | 2 * COPYRIGHT: |
3 * Copyright (c) 1997-2012, International Business Machines Corporation and | 3 * Copyright (c) 1997-2014, International Business Machines Corporation and |
4 * others. All Rights Reserved. | 4 * others. All Rights Reserved. |
5 ********************************************************************/ | 5 ********************************************************************/ |
6 /*******************************************************************************
* | 6 /*******************************************************************************
* |
7 * | 7 * |
8 * File CGENDTST.C | 8 * File CGENDTST.C |
9 ********************************************************************************
* | 9 ********************************************************************************
* |
10 */ | 10 */ |
11 | 11 |
12 /* C API TEST FOR GENDER INFO */ | 12 /* C API TEST FOR GENDER INFO */ |
13 | 13 |
14 #include "unicode/utypes.h" | 14 #include "unicode/utypes.h" |
| 15 #include "cmemory.h" |
15 | 16 |
16 #if !UCONFIG_NO_FORMATTING | 17 #if !UCONFIG_NO_FORMATTING |
17 | 18 |
18 #include "cintltst.h" | 19 #include "cintltst.h" |
19 #include "unicode/ugender.h" | 20 #include "unicode/ugender.h" |
20 | 21 |
21 static const UGender kAllFemale[] = {UGENDER_FEMALE, UGENDER_FEMALE}; | 22 static const UGender kAllFemale[] = {UGENDER_FEMALE, UGENDER_FEMALE}; |
22 | 23 |
23 #define LENGTHOF(array) (int32_t)(sizeof(array) / sizeof((array)[0])) | |
24 | |
25 void addGendInfoForTest(TestNode** root); | 24 void addGendInfoForTest(TestNode** root); |
26 static void TestGenderInfo(void); | 25 static void TestGenderInfo(void); |
27 | 26 |
28 #define TESTCASE(x) addTest(root, &x, "tsformat/cgendtst/" #x) | 27 #define TESTCASE(x) addTest(root, &x, "tsformat/cgendtst/" #x) |
29 | 28 |
30 void addGendInfoForTest(TestNode** root) | 29 void addGendInfoForTest(TestNode** root) |
31 { | 30 { |
32 TESTCASE(TestGenderInfo); | 31 TESTCASE(TestGenderInfo); |
33 } | 32 } |
34 | 33 |
35 static void TestGenderInfo(void) { | 34 static void TestGenderInfo(void) { |
36 UErrorCode status = U_ZERO_ERROR; | 35 UErrorCode status = U_ZERO_ERROR; |
37 const UGenderInfo* actual_gi = ugender_getInstance("fr_CA", &status); | 36 const UGenderInfo* actual_gi = ugender_getInstance("fr_CA", &status); |
38 UGender actual; | 37 UGender actual; |
39 if (U_FAILURE(status)) { | 38 if (U_FAILURE(status)) { |
40 log_err_status(status, "Fail to create UGenderInfo - %s (Are you missing dat
a?)", u_errorName(status)); | 39 log_err_status(status, "Fail to create UGenderInfo - %s (Are you missing dat
a?)", u_errorName(status)); |
41 return; | 40 return; |
42 } | 41 } |
43 actual = ugender_getListGender(actual_gi, kAllFemale, LENGTHOF(kAllFemale), &s
tatus); | 42 actual = ugender_getListGender(actual_gi, kAllFemale, UPRV_LENGTHOF(kAllFemale
), &status); |
44 if (U_FAILURE(status)) { | 43 if (U_FAILURE(status)) { |
45 log_err("Fail to get gender of list - %s\n", u_errorName(status)); | 44 log_err("Fail to get gender of list - %s\n", u_errorName(status)); |
46 return; | 45 return; |
47 } | 46 } |
48 if (actual != UGENDER_FEMALE) { | 47 if (actual != UGENDER_FEMALE) { |
49 log_err("Expected UGENDER_FEMALE got %d\n", actual); | 48 log_err("Expected UGENDER_FEMALE got %d\n", actual); |
50 } | 49 } |
51 } | 50 } |
52 | 51 |
53 #endif /* #if !UCONFIG_NO_FORMATTING */ | 52 #endif /* #if !UCONFIG_NO_FORMATTING */ |
OLD | NEW |