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