mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-21 12:40:02 +00:00
ICU-12935 Merge r39109,r39115,r39126,r39142 from #12652 into maint 56.x
X-SVN-Rev: 39567
This commit is contained in:
parent
3543dc96a6
commit
3a4e3778a3
2 changed files with 316 additions and 320 deletions
File diff suppressed because it is too large
Load diff
|
@ -1,3 +1,5 @@
|
|||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/********************************************************************
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 1997-2015, International Business Machines Corporation and
|
||||
|
@ -2742,16 +2744,20 @@ static void TestAcceptLanguage(void) {
|
|||
const char *icuSet; /**< ? */
|
||||
const char *expect; /**< The expected locale result */
|
||||
UAcceptResult res; /**< The expected error code */
|
||||
UErrorCode expectStatus; /**< expected status */
|
||||
} tests[] = {
|
||||
/*0*/{ 0, NULL, "mt_MT", ULOC_ACCEPT_VALID },
|
||||
/*1*/{ 1, NULL, "en", ULOC_ACCEPT_VALID },
|
||||
/*2*/{ 2, NULL, "en", ULOC_ACCEPT_FALLBACK },
|
||||
/*3*/{ 3, NULL, "", ULOC_ACCEPT_FAILED },
|
||||
/*4*/{ 4, NULL, "es", ULOC_ACCEPT_VALID },
|
||||
|
||||
/*5*/{ 5, NULL, "en", ULOC_ACCEPT_VALID }, /* XF */
|
||||
/*6*/{ 6, NULL, "ja", ULOC_ACCEPT_FALLBACK }, /* XF */
|
||||
/*7*/{ 7, NULL, "zh", ULOC_ACCEPT_FALLBACK }, /* XF */
|
||||
/*0*/{ 0, NULL, "mt_MT", ULOC_ACCEPT_VALID, U_ZERO_ERROR},
|
||||
/*1*/{ 1, NULL, "en", ULOC_ACCEPT_VALID, U_ZERO_ERROR},
|
||||
/*2*/{ 2, NULL, "en", ULOC_ACCEPT_FALLBACK, U_ZERO_ERROR},
|
||||
/*3*/{ 3, NULL, "", ULOC_ACCEPT_FAILED, U_ZERO_ERROR},
|
||||
/*4*/{ 4, NULL, "es", ULOC_ACCEPT_VALID, U_ZERO_ERROR},
|
||||
/*5*/{ 5, NULL, "en", ULOC_ACCEPT_VALID, U_ZERO_ERROR}, /* XF */
|
||||
/*6*/{ 6, NULL, "ja", ULOC_ACCEPT_FALLBACK, U_ZERO_ERROR}, /* XF */
|
||||
/*7*/{ 7, NULL, "zh", ULOC_ACCEPT_FALLBACK, U_ZERO_ERROR}, /* XF */
|
||||
/*8*/{ 8, NULL, "", ULOC_ACCEPT_FAILED, U_ZERO_ERROR }, /* */
|
||||
/*9*/{ 9, NULL, "", ULOC_ACCEPT_FAILED, U_ZERO_ERROR }, /* */
|
||||
/*10*/{10, NULL, "", ULOC_ACCEPT_FAILED, U_BUFFER_OVERFLOW_ERROR }, /* */
|
||||
/*11*/{11, NULL, "", ULOC_ACCEPT_FAILED, U_BUFFER_OVERFLOW_ERROR }, /* */
|
||||
};
|
||||
const int32_t numTests = sizeof(tests)/sizeof(tests[0]);
|
||||
static const char *http[] = {
|
||||
|
@ -2767,10 +2773,25 @@ static void TestAcceptLanguage(void) {
|
|||
"xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, "
|
||||
"xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xx-yy;q=.1, "
|
||||
"es",
|
||||
|
||||
/*5*/ "zh-xx;q=0.9, en;q=0.6",
|
||||
/*6*/ "ja-JA",
|
||||
/*7*/ "zh-xx;q=0.9",
|
||||
/*08*/ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", // 156
|
||||
/*09*/ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB", // 157 (this hits U_STRING_NOT_TERMINATED_WARNING )
|
||||
/*10*/ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABC", // 158
|
||||
/*11*/ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", // 163 bytes
|
||||
};
|
||||
|
||||
for(i=0;i<numTests;i++) {
|
||||
|
@ -2785,17 +2806,22 @@ static void TestAcceptLanguage(void) {
|
|||
(void)rc; /* Suppress set but not used warning. */
|
||||
uenum_close(available);
|
||||
log_verbose(" got %s, %s [%s]\n", tmp[0]?tmp:"(EMPTY)", acceptResult(outResult), u_errorName(status));
|
||||
if(outResult != tests[i].res) {
|
||||
if(status != tests[i].expectStatus) {
|
||||
log_err_status(status, "FAIL: expected status %s but got %s\n", u_errorName(tests[i].expectStatus), u_errorName(status));
|
||||
} else if(U_SUCCESS(tests[i].expectStatus)) {
|
||||
/* don't check content if expected failure */
|
||||
if(outResult != tests[i].res) {
|
||||
log_err_status(status, "FAIL: #%d: expected outResult of %s but got %s\n", i,
|
||||
acceptResult( tests[i].res),
|
||||
acceptResult( outResult));
|
||||
log_info("test #%d: http[%s], ICU[%s], expect %s, %s\n",
|
||||
i, http[tests[i].httpSet], tests[i].icuSet, tests[i].expect,acceptResult(tests[i].res));
|
||||
}
|
||||
if((outResult>0)&&uprv_strcmp(tmp, tests[i].expect)) {
|
||||
log_err_status(status, "FAIL: #%d: expected %s but got %s\n", i, tests[i].expect, tmp);
|
||||
log_info("test #%d: http[%s], ICU[%s], expect %s, %s\n",
|
||||
i, http[tests[i].httpSet], tests[i].icuSet, tests[i].expect, acceptResult(tests[i].res));
|
||||
}
|
||||
if((outResult>0)&&uprv_strcmp(tmp, tests[i].expect)) {
|
||||
log_err_status(status, "FAIL: #%d: expected %s but got %s\n", i, tests[i].expect, tmp);
|
||||
log_info("test #%d: http[%s], ICU[%s], expect %s, %s\n",
|
||||
i, http[tests[i].httpSet], tests[i].icuSet, tests[i].expect, acceptResult(tests[i].res));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue