mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-15 01:42:37 +00:00
ICU-4098 Prevent missing break iterators from crashing the build.
X-SVN-Rev: 16310
This commit is contained in:
parent
276f299cfe
commit
86e489fb77
4 changed files with 48 additions and 6 deletions
|
@ -149,8 +149,8 @@ static void TestBreakIteratorCAPI()
|
|||
/* Use french for fun */
|
||||
word = ubrk_open(UBRK_WORD, "en_US", text, u_strlen(text), &status);
|
||||
if(status == U_FILE_ACCESS_ERROR) {
|
||||
log_data_err("Check your data - it doesn't seem to be around\n");
|
||||
return;
|
||||
log_data_err("Check your data - it doesn't seem to be around\n");
|
||||
return;
|
||||
} else if(U_FAILURE(status)){
|
||||
log_err("FAIL: Error in ubrk_open() for word breakiterator: %s\n", myErrorName(status));
|
||||
}
|
||||
|
@ -161,6 +161,7 @@ static void TestBreakIteratorCAPI()
|
|||
sentence = ubrk_open(UBRK_SENTENCE, "en_US", text, u_strlen(text), &status);
|
||||
if(U_FAILURE(status)){
|
||||
log_err("FAIL: Error in ubrk_open() for sentence breakiterator: %s\n", myErrorName(status));
|
||||
return;
|
||||
}
|
||||
else{
|
||||
log_verbose("PASS: Successfully opened sentence breakiterator\n");
|
||||
|
@ -169,6 +170,7 @@ static void TestBreakIteratorCAPI()
|
|||
line = ubrk_open(UBRK_LINE, "en_US", text, u_strlen(text), &status);
|
||||
if(U_FAILURE(status)){
|
||||
log_err("FAIL: Error in ubrk_open() for line breakiterator: %s\n", myErrorName(status));
|
||||
return;
|
||||
}
|
||||
else{
|
||||
log_verbose("PASS: Successfully opened line breakiterator\n");
|
||||
|
@ -177,6 +179,7 @@ static void TestBreakIteratorCAPI()
|
|||
character = ubrk_open(UBRK_CHARACTER, "en_US", text, u_strlen(text), &status);
|
||||
if(U_FAILURE(status)){
|
||||
log_err("FAIL: Error in ubrk_open() for character breakiterator: %s\n", myErrorName(status));
|
||||
return;
|
||||
}
|
||||
else{
|
||||
log_verbose("PASS: Successfully opened character breakiterator\n");
|
||||
|
|
|
@ -148,6 +148,10 @@ void RBBIAPITest::TestBoilerPlate()
|
|||
UErrorCode status = U_ZERO_ERROR;
|
||||
BreakIterator* a = BreakIterator::createLineInstance(Locale("hi"), status);
|
||||
BreakIterator* b = BreakIterator::createLineInstance(Locale("hi_IN"),status);
|
||||
if (U_FAILURE(status)) {
|
||||
errln("Creation of break iterator failed %s", u_errorName(status));
|
||||
return;
|
||||
}
|
||||
if(*a!=*b){
|
||||
errln("Failed: boilerplate method operator!= does not return correct results");
|
||||
}
|
||||
|
|
|
@ -3176,6 +3176,10 @@ void RBBITest::TestWordBreaks(void)
|
|||
"\\uc30d\\u002e\\U000e002c\\u0c48\\u003a\\ub5a1\\u0661\\u002c",
|
||||
};
|
||||
int loop;
|
||||
if (U_FAILURE(status)) {
|
||||
errln("Creation of break iterator failed %s", u_errorName(status));
|
||||
return;
|
||||
}
|
||||
for (loop = 0; loop < (int)(sizeof(strlist) / sizeof(char *)); loop ++) {
|
||||
// printf("looping %d\n", loop);
|
||||
u_unescape(strlist[loop], str, 25);
|
||||
|
@ -3239,6 +3243,10 @@ void RBBITest::TestWordBoundary(void)
|
|||
"\\u003b\\u0027\\u00b7\\u47a3",
|
||||
};
|
||||
int loop;
|
||||
if (U_FAILURE(status)) {
|
||||
errln("Creation of break iterator failed %s", u_errorName(status));
|
||||
return;
|
||||
}
|
||||
for (loop = 0; loop < (int)(sizeof(strlist) / sizeof(char *)); loop ++) {
|
||||
// printf("looping %d\n", loop);
|
||||
u_unescape(strlist[loop], str, 20);
|
||||
|
@ -3322,6 +3330,10 @@ void RBBITest::TestLineBreaks(void)
|
|||
"\\u2116\\u0ed2\\uff64\\u02cd\\u2001\\u2060",
|
||||
};
|
||||
int loop;
|
||||
if (U_FAILURE(status)) {
|
||||
errln("Creation of break iterator failed %s", u_errorName(status));
|
||||
return;
|
||||
}
|
||||
for (loop = 0; loop < (int)(sizeof(strlist) / sizeof(char *)); loop ++) {
|
||||
// printf("looping %d\n", loop);
|
||||
u_unescape(strlist[loop], str, 20);
|
||||
|
@ -3364,7 +3376,11 @@ void RBBITest::TestSentBreaks(void)
|
|||
};
|
||||
int loop;
|
||||
int forward[100];
|
||||
for (loop = 0; loop < (int)(sizeof(strlist) / sizeof(char *)); loop ++) {
|
||||
if (U_FAILURE(status)) {
|
||||
errln("Creation of break iterator failed %s", u_errorName(status));
|
||||
return;
|
||||
}
|
||||
for (loop = 0; loop < (int)(sizeof(strlist) / sizeof(char *)); loop ++) {
|
||||
u_unescape(strlist[loop], str, 100);
|
||||
UnicodeString ustr(str);
|
||||
|
||||
|
@ -3420,7 +3436,12 @@ void RBBITest::TestMonkey(char *params) {
|
|||
if (breakType == "char" || breakType == "all") {
|
||||
RBBICharMonkey m;
|
||||
BreakIterator *bi = BreakIterator::createCharacterInstance(locale, status);
|
||||
RunMonkey(bi, m, "char", seed, loopCount);
|
||||
if (U_SUCCESS(status)) {
|
||||
RunMonkey(bi, m, "char", seed, loopCount);
|
||||
}
|
||||
else {
|
||||
errln("Creation of character break iterator failed %s", u_errorName(status));
|
||||
}
|
||||
delete bi;
|
||||
}
|
||||
|
||||
|
@ -3428,7 +3449,12 @@ void RBBITest::TestMonkey(char *params) {
|
|||
logln("Word Break Monkey Test");
|
||||
RBBIWordMonkey m;
|
||||
BreakIterator *bi = BreakIterator::createWordInstance(locale, status);
|
||||
RunMonkey(bi, m, "word", seed, loopCount);
|
||||
if (U_SUCCESS(status)) {
|
||||
RunMonkey(bi, m, "word", seed, loopCount);
|
||||
}
|
||||
else {
|
||||
errln("Creation of word break iterator failed %s", u_errorName(status));
|
||||
}
|
||||
delete bi;
|
||||
}
|
||||
|
||||
|
@ -3439,7 +3465,12 @@ void RBBITest::TestMonkey(char *params) {
|
|||
if (params == NULL) {
|
||||
loopCount = 50;
|
||||
}
|
||||
RunMonkey(bi, m, "line", seed, loopCount);
|
||||
if (U_SUCCESS(status)) {
|
||||
RunMonkey(bi, m, "line", seed, loopCount);
|
||||
}
|
||||
else {
|
||||
errln("Creation of line break iterator failed %s", u_errorName(status));
|
||||
}
|
||||
delete bi;
|
||||
}
|
||||
|
||||
|
|
|
@ -1633,6 +1633,10 @@ void StringSearchTest::TestBreakIteratorCanonical()
|
|||
}
|
||||
search = &(BREAKITERATOREXACT[count + 1]);
|
||||
breaker = getBreakIterator(search->breaker);
|
||||
if (breaker == NULL) {
|
||||
errln("Error creating BreakIterator");
|
||||
return;
|
||||
}
|
||||
breaker->setText(strsrch->getText());
|
||||
strsrch->setBreakIterator(breaker, status);
|
||||
if (U_FAILURE(status) || strsrch->getBreakIterator() != breaker) {
|
||||
|
|
Loading…
Add table
Reference in a new issue