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 /* Modification History: | 6 /* Modification History: |
7 */ | 7 */ |
8 | 8 |
9 #include "unicode/utypes.h" | 9 #include "unicode/utypes.h" |
10 | 10 |
11 #if !UCONFIG_NO_FORMATTING | 11 #if !UCONFIG_NO_FORMATTING |
12 | 12 |
13 #include <stdlib.h> | 13 #include <stdlib.h> |
14 #include "unicode/gender.h" | 14 #include "unicode/gender.h" |
15 #include "unicode/unum.h" | 15 #include "unicode/unum.h" |
16 #include "intltest.h" | 16 #include "intltest.h" |
17 | 17 #include "cmemory.h" |
18 #define LENGTHOF(array) (int32_t)(sizeof(array) / sizeof((array)[0])) | |
19 | 18 |
20 static const UGender kSingleFemale[] = {UGENDER_FEMALE}; | 19 static const UGender kSingleFemale[] = {UGENDER_FEMALE}; |
21 static const UGender kSingleMale[] = {UGENDER_MALE}; | 20 static const UGender kSingleMale[] = {UGENDER_MALE}; |
22 static const UGender kSingleOther[] = {UGENDER_OTHER}; | 21 static const UGender kSingleOther[] = {UGENDER_OTHER}; |
23 | 22 |
24 static const UGender kAllFemale[] = {UGENDER_FEMALE, UGENDER_FEMALE}; | 23 static const UGender kAllFemale[] = {UGENDER_FEMALE, UGENDER_FEMALE}; |
25 static const UGender kAllMale[] = {UGENDER_MALE, UGENDER_MALE}; | 24 static const UGender kAllMale[] = {UGENDER_MALE, UGENDER_MALE}; |
26 static const UGender kAllOther[] = {UGENDER_OTHER, UGENDER_OTHER}; | 25 static const UGender kAllOther[] = {UGENDER_OTHER, UGENDER_OTHER}; |
27 | 26 |
28 static const UGender kFemaleMale[] = {UGENDER_FEMALE, UGENDER_MALE}; | 27 static const UGender kFemaleMale[] = {UGENDER_FEMALE, UGENDER_MALE}; |
(...skipping 19 matching lines...) Expand all Loading... |
48 logln("TestSuite GenderInfoTest: "); | 47 logln("TestSuite GenderInfoTest: "); |
49 } | 48 } |
50 TESTCASE_AUTO_BEGIN; | 49 TESTCASE_AUTO_BEGIN; |
51 TESTCASE_AUTO(TestGetListGender); | 50 TESTCASE_AUTO(TestGetListGender); |
52 TESTCASE_AUTO(TestFallback); | 51 TESTCASE_AUTO(TestFallback); |
53 TESTCASE_AUTO_END; | 52 TESTCASE_AUTO_END; |
54 } | 53 } |
55 | 54 |
56 void GenderInfoTest::TestGetListGender() { | 55 void GenderInfoTest::TestGetListGender() { |
57 check(UGENDER_OTHER, UGENDER_OTHER, UGENDER_OTHER, NULL, 0); | 56 check(UGENDER_OTHER, UGENDER_OTHER, UGENDER_OTHER, NULL, 0); |
58 check(UGENDER_FEMALE, UGENDER_FEMALE, UGENDER_FEMALE, kSingleFemale, LENGTHO
F(kSingleFemale)); | 57 check(UGENDER_FEMALE, UGENDER_FEMALE, UGENDER_FEMALE, kSingleFemale, UPRV_LE
NGTHOF(kSingleFemale)); |
59 check(UGENDER_MALE, UGENDER_MALE, UGENDER_MALE, kSingleMale, LENGTHOF(kSingl
eMale)); | 58 check(UGENDER_MALE, UGENDER_MALE, UGENDER_MALE, kSingleMale, UPRV_LENGTHOF(k
SingleMale)); |
60 check(UGENDER_OTHER, UGENDER_OTHER, UGENDER_OTHER, kSingleOther, LENGTHOF(kS
ingleOther)); | 59 check(UGENDER_OTHER, UGENDER_OTHER, UGENDER_OTHER, kSingleOther, UPRV_LENGTH
OF(kSingleOther)); |
61 | 60 |
62 check(UGENDER_OTHER, UGENDER_FEMALE, UGENDER_FEMALE, kAllFemale, LENGTHOF(kA
llFemale)); | 61 check(UGENDER_OTHER, UGENDER_FEMALE, UGENDER_FEMALE, kAllFemale, UPRV_LENGTH
OF(kAllFemale)); |
63 check(UGENDER_OTHER, UGENDER_MALE, UGENDER_MALE, kAllMale, LENGTHOF(kAllMale
)); | 62 check(UGENDER_OTHER, UGENDER_MALE, UGENDER_MALE, kAllMale, UPRV_LENGTHOF(kAl
lMale)); |
64 check(UGENDER_OTHER, UGENDER_OTHER, UGENDER_MALE, kAllOther, LENGTHOF(kAllOt
her)); | 63 check(UGENDER_OTHER, UGENDER_OTHER, UGENDER_MALE, kAllOther, UPRV_LENGTHOF(k
AllOther)); |
65 | 64 |
66 check(UGENDER_OTHER, UGENDER_OTHER, UGENDER_MALE, kFemaleMale, LENGTHOF(kFem
aleMale)); | 65 check(UGENDER_OTHER, UGENDER_OTHER, UGENDER_MALE, kFemaleMale, UPRV_LENGTHOF
(kFemaleMale)); |
67 check(UGENDER_OTHER, UGENDER_OTHER, UGENDER_MALE, kFemaleOther, LENGTHOF(kFe
maleOther)); | 66 check(UGENDER_OTHER, UGENDER_OTHER, UGENDER_MALE, kFemaleOther, UPRV_LENGTHO
F(kFemaleOther)); |
68 check(UGENDER_OTHER, UGENDER_OTHER, UGENDER_MALE, kMaleOther, LENGTHOF(kMale
Other)); | 67 check(UGENDER_OTHER, UGENDER_OTHER, UGENDER_MALE, kMaleOther, UPRV_LENGTHOF(
kMaleOther)); |
69 } | 68 } |
70 | 69 |
71 void GenderInfoTest::TestFallback() { | 70 void GenderInfoTest::TestFallback() { |
72 UErrorCode status = U_ZERO_ERROR; | 71 UErrorCode status = U_ZERO_ERROR; |
73 const GenderInfo* actual = GenderInfo::getInstance("xx", status); | 72 const GenderInfo* actual = GenderInfo::getInstance("xx", status); |
74 if (U_FAILURE(status)) { | 73 if (U_FAILURE(status)) { |
75 errcheckln(status, "Fail to create GenderInfo - %s", u_errorName(status)); | 74 errcheckln(status, "Fail to create GenderInfo - %s", u_errorName(status)); |
76 return; | 75 return; |
77 } | 76 } |
78 const GenderInfo* expected = GenderInfo::getNeutralInstance(); | 77 const GenderInfo* expected = GenderInfo::getNeutralInstance(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 if (actual != expected) { | 112 if (actual != expected) { |
114 errln("For locale: %s expected: %d got %d", locale.getName(), expected, actu
al); | 113 errln("For locale: %s expected: %d got %d", locale.getName(), expected, actu
al); |
115 } | 114 } |
116 } | 115 } |
117 | 116 |
118 extern IntlTest *createGenderInfoTest() { | 117 extern IntlTest *createGenderInfoTest() { |
119 return new GenderInfoTest(); | 118 return new GenderInfoTest(); |
120 } | 119 } |
121 | 120 |
122 #endif /* #if !UCONFIG_NO_FORMATTING */ | 121 #endif /* #if !UCONFIG_NO_FORMATTING */ |
OLD | NEW |