From 1556ec8248fe58e802191662a319c683fe52e3f1 Mon Sep 17 00:00:00 2001 From: Frank Tang Date: Tue, 19 Oct 2021 00:44:41 +0000 Subject: [PATCH] Test ICU status correctly by using U_SUCCESS This correction is needed for ICU70 which lazy build the internal break iterator instead of during constructor therefore shift the return of U_USING_DEFAULT_WARNING in status from usearch_open() to usearch_next(). Instead of explicitly check different possible status code the DCHECK should just use ICU macro U_SUCCESS() instead. This change is needed to land to unblock the landing of ICU70 which have https://github.com/unicode-org/icu/pull/1473 that shift the returning of U_USING_DEFAULT_WARNING in status. Bug: 1260116 Change-Id: Ie5a2f402399b51120214a9ce8c8e4f5c249d0160 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3225781 Reviewed-by: Jungshik Shin Commit-Queue: Frank Tang Cr-Commit-Position: refs/heads/main@{#932782} --- base/i18n/string_search.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/base/i18n/string_search.cc b/base/i18n/string_search.cc index 987272a3fcb019..0cb4aaeff0039e 100644 --- a/base/i18n/string_search.cc +++ b/base/i18n/string_search.cc @@ -119,8 +119,7 @@ RepeatingStringSearch::RepeatingStringSearch(const std::u16string& find_this, search_ = usearch_open(find_this_.data(), find_this_.size(), in_this_.data(), in_this_.size(), locale.data(), /*breakiter=*/nullptr, &status); - DCHECK(status == U_ZERO_ERROR || status == U_USING_FALLBACK_WARNING || - status == U_USING_DEFAULT_WARNING); + DCHECK(U_SUCCESS(status)); if (U_SUCCESS(status)) { // http://icu-project.org/apiref/icu4c40/ucol_8h.html#6a967f36248b0a1bc7654f538ee8ba96 // Set comparison level to UCOL_PRIMARY to ignore secondary and tertiary @@ -147,7 +146,7 @@ bool RepeatingStringSearch::NextMatchResult(int& match_index, const int match_start = usearch_next(search_, &status); if (U_FAILURE(status) || match_start == USEARCH_DONE) return false; - DCHECK_EQ(U_ZERO_ERROR, status); + DCHECK(U_SUCCESS(status)); match_index = match_start; match_length = usearch_getMatchedLength(search_); return true;