+/* Test message format with a Select option */
+static void TestMsgFormatSelect(void)
+{
+ UChar* str;
+ UChar* str1;
+ UErrorCode status = U_ZERO_ERROR;
+ UChar *result;
+ UChar pattern[100];
+ UChar expected[100];
+ int32_t resultlength,resultLengthOut;
+
+ str=(UChar*)malloc(sizeof(UChar) * 25);
+ u_uastrcpy(str, "Kirti");
+ str1=(UChar*)malloc(sizeof(UChar) * 25);
+ u_uastrcpy(str1, "female");
+ log_verbose("Testing message format with Select test #1\n:");
+ u_uastrcpy(pattern, "{0} est {1, select, female {all\\u00E9e} other {all\\u00E9}} \\u00E0 Paris.");
+ u_uastrcpy(expected, "Kirti est all\\u00E9e \\u00E0 Paris.");
+ resultlength=0;
+ resultLengthOut=u_formatMessage( "fr", pattern, u_strlen(pattern), NULL, resultlength, &status, str , str1);
+ if(status==U_BUFFER_OVERFLOW_ERROR)
+ {
+ status=U_ZERO_ERROR;
+ resultlength=resultLengthOut+1;
+ result=(UChar*)malloc(sizeof(UChar) * resultlength);
+ u_formatMessage( "fr", pattern, u_strlen(pattern), result, resultlength, &status, str , str1);
+ if(u_strcmp(result, expected)==0)
+ log_verbose("PASS: MessagFormat successful on Select test#1\n");
+ else{
+ log_err("FAIL: Error in MessageFormat on Select test#1\n GOT %s EXPECTED %s\n", austrdup(result),
+ austrdup(expected) );
+ }
+ free(result);
+ }
+ if(U_FAILURE(status)){
+ log_data_err("ERROR: failure in message format on Select test#1 : %s \n", myErrorName(status));
+ }
+ free(str);
+ free(str1);
+
+ /*Test a nested pattern*/
+ str=(UChar*)malloc(sizeof(UChar) * 25);
+ u_uastrcpy(str, "Noname");
+ str1=(UChar*)malloc(sizeof(UChar) * 25);
+ u_uastrcpy(str1, "other");
+ log_verbose("Testing message format with Select test #2\n:");
+ u_uastrcpy(pattern, "{0} est {1, select, female {{2,number,integer} all\\u00E9e} other {all\\u00E9}} \\u00E0 Paris.");
+ u_uastrcpy(expected, "Noname est all\\u00E9 \\u00E0 Paris.");
+ resultlength=0;
+ resultLengthOut=u_formatMessage( "fr", pattern, u_strlen(pattern), NULL, resultlength, &status, str , str1,6);
+ if(status==U_BUFFER_OVERFLOW_ERROR)
+ {
+ status=U_ZERO_ERROR;
+ resultlength=resultLengthOut+1;
+ result=(UChar*)malloc(sizeof(UChar) * resultlength);
+ u_formatMessage( "fr", pattern, u_strlen(pattern), result, resultlength, &status, str , str1);
+ if(u_strcmp(result, expected)==0)
+ log_verbose("PASS: MessagFormat successful on Select test#2\n");
+ else{
+ log_err("FAIL: Error in MessageFormat on Select test#2\n GOT %s EXPECTED %s\n", austrdup(result),
+ austrdup(expected) );
+ }
+ free(result);
+ }
+ if(U_FAILURE(status)){
+ log_data_err("ERROR: failure in message format on Select test#2 : %s \n", myErrorName(status));
+ }
+ free(str);
+ free(str1);
+}
+