Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: source/test/intltest/genderinfotest.cpp

Issue 2435373002: Delete source/test (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/test/intltest/g7coll.cpp ('k') | source/test/intltest/icusvtst.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /********************************************************************
2 * COPYRIGHT:
3 * Copyright (c) 1997-2014, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 ********************************************************************/
6 /* Modification History:
7 */
8
9 #include "unicode/utypes.h"
10
11 #if !UCONFIG_NO_FORMATTING
12
13 #include <stdlib.h>
14 #include "unicode/gender.h"
15 #include "unicode/unum.h"
16 #include "intltest.h"
17 #include "cmemory.h"
18
19 static const UGender kSingleFemale[] = {UGENDER_FEMALE};
20 static const UGender kSingleMale[] = {UGENDER_MALE};
21 static const UGender kSingleOther[] = {UGENDER_OTHER};
22
23 static const UGender kAllFemale[] = {UGENDER_FEMALE, UGENDER_FEMALE};
24 static const UGender kAllMale[] = {UGENDER_MALE, UGENDER_MALE};
25 static const UGender kAllOther[] = {UGENDER_OTHER, UGENDER_OTHER};
26
27 static const UGender kFemaleMale[] = {UGENDER_FEMALE, UGENDER_MALE};
28 static const UGender kFemaleOther[] = {UGENDER_FEMALE, UGENDER_OTHER};
29 static const UGender kMaleOther[] = {UGENDER_MALE, UGENDER_OTHER};
30
31
32 class GenderInfoTest : public IntlTest {
33 public:
34 GenderInfoTest() {
35 }
36
37 void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par= 0);
38 private:
39 void TestGetListGender();
40 void TestFallback();
41 void check(UGender expected_neutral, UGender expected_mixed, UGender expecte d_taints, const UGender* genderList, int32_t listLength);
42 void checkLocale(const Locale& locale, UGender expected, const UGender* gend erList, int32_t listLength);
43 };
44
45 void GenderInfoTest::runIndexedTest(int32_t index, UBool exec, const char *&name , char * /* par */) {
46 if (exec) {
47 logln("TestSuite GenderInfoTest: ");
48 }
49 TESTCASE_AUTO_BEGIN;
50 TESTCASE_AUTO(TestGetListGender);
51 TESTCASE_AUTO(TestFallback);
52 TESTCASE_AUTO_END;
53 }
54
55 void GenderInfoTest::TestGetListGender() {
56 check(UGENDER_OTHER, UGENDER_OTHER, UGENDER_OTHER, NULL, 0);
57 check(UGENDER_FEMALE, UGENDER_FEMALE, UGENDER_FEMALE, kSingleFemale, UPRV_LE NGTHOF(kSingleFemale));
58 check(UGENDER_MALE, UGENDER_MALE, UGENDER_MALE, kSingleMale, UPRV_LENGTHOF(k SingleMale));
59 check(UGENDER_OTHER, UGENDER_OTHER, UGENDER_OTHER, kSingleOther, UPRV_LENGTH OF(kSingleOther));
60
61 check(UGENDER_OTHER, UGENDER_FEMALE, UGENDER_FEMALE, kAllFemale, UPRV_LENGTH OF(kAllFemale));
62 check(UGENDER_OTHER, UGENDER_MALE, UGENDER_MALE, kAllMale, UPRV_LENGTHOF(kAl lMale));
63 check(UGENDER_OTHER, UGENDER_OTHER, UGENDER_MALE, kAllOther, UPRV_LENGTHOF(k AllOther));
64
65 check(UGENDER_OTHER, UGENDER_OTHER, UGENDER_MALE, kFemaleMale, UPRV_LENGTHOF (kFemaleMale));
66 check(UGENDER_OTHER, UGENDER_OTHER, UGENDER_MALE, kFemaleOther, UPRV_LENGTHO F(kFemaleOther));
67 check(UGENDER_OTHER, UGENDER_OTHER, UGENDER_MALE, kMaleOther, UPRV_LENGTHOF( kMaleOther));
68 }
69
70 void GenderInfoTest::TestFallback() {
71 UErrorCode status = U_ZERO_ERROR;
72 const GenderInfo* actual = GenderInfo::getInstance("xx", status);
73 if (U_FAILURE(status)) {
74 errcheckln(status, "Fail to create GenderInfo - %s", u_errorName(status));
75 return;
76 }
77 const GenderInfo* expected = GenderInfo::getNeutralInstance();
78 if (expected != actual) {
79 errln("For Neutral, expected %d got %d", expected, actual);
80 }
81 actual = GenderInfo::getInstance("fr_CA", status);
82 if (U_FAILURE(status)) {
83 errcheckln(status, "Fail to create GenderInfo - %s", u_errorName(status));
84 return;
85 }
86 expected = GenderInfo::getMaleTaintsInstance();
87 if (expected != actual) {
88 errln("For Male Taints, Expected %d got %d", expected, actual);
89 }
90 }
91
92 void GenderInfoTest::check(
93 UGender expected_neutral, UGender expected_mixed, UGender expected_taints, c onst UGender* genderList, int32_t listLength) {
94 checkLocale(Locale::getUS(), expected_neutral, genderList, listLength);
95 checkLocale("is", expected_mixed, genderList, listLength);
96 checkLocale(Locale::getFrench(), expected_taints, genderList, listLength);
97 }
98
99 void GenderInfoTest::checkLocale(
100 const Locale& locale, UGender expected, const UGender* genderList, int32_t l istLength) {
101 UErrorCode status = U_ZERO_ERROR;
102 const GenderInfo* gi = GenderInfo::getInstance(locale, status);
103 if (U_FAILURE(status)) {
104 errcheckln(status, "Fail to create GenderInfo - %s", u_errorName(status));
105 return;
106 }
107 UGender actual = gi->getListGender(genderList, listLength, status);
108 if (U_FAILURE(status)) {
109 errcheckln(status, "Fail to get gender of list - %s", u_errorName(status));
110 return;
111 }
112 if (actual != expected) {
113 errln("For locale: %s expected: %d got %d", locale.getName(), expected, actu al);
114 }
115 }
116
117 extern IntlTest *createGenderInfoTest() {
118 return new GenderInfoTest();
119 }
120
121 #endif /* #if !UCONFIG_NO_FORMATTING */
OLDNEW
« no previous file with comments | « source/test/intltest/g7coll.cpp ('k') | source/test/intltest/icusvtst.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698