From b9d1ba87f545744f2b81f1f413484f55a0da3d2f Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Tue, 14 Apr 2020 13:25:41 -0700 Subject: [PATCH] ICU-20936 copy the new direction field --- icu4c/source/common/localematcher.cpp | 2 ++ icu4c/source/test/intltest/localematchertest.cpp | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/icu4c/source/common/localematcher.cpp b/icu4c/source/common/localematcher.cpp index 7f0dceb66ae..85db8c8bf32 100644 --- a/icu4c/source/common/localematcher.cpp +++ b/icu4c/source/common/localematcher.cpp @@ -466,6 +466,7 @@ LocaleMatcher::LocaleMatcher(LocaleMatcher &&src) U_NOEXCEPT : thresholdDistance(src.thresholdDistance), demotionPerDesiredLocale(src.demotionPerDesiredLocale), favorSubtag(src.favorSubtag), + direction(src.direction), supportedLocales(src.supportedLocales), lsrs(src.lsrs), supportedLocalesLength(src.supportedLocalesLength), supportedLsrToIndex(src.supportedLsrToIndex), @@ -502,6 +503,7 @@ LocaleMatcher &LocaleMatcher::operator=(LocaleMatcher &&src) U_NOEXCEPT { thresholdDistance = src.thresholdDistance; demotionPerDesiredLocale = src.demotionPerDesiredLocale; favorSubtag = src.favorSubtag; + direction = src.direction; supportedLocales = src.supportedLocales; lsrs = src.lsrs; supportedLocalesLength = src.supportedLocalesLength; diff --git a/icu4c/source/test/intltest/localematchertest.cpp b/icu4c/source/test/intltest/localematchertest.cpp index 6d7f48da606..683466b3c56 100644 --- a/icu4c/source/test/intltest/localematchertest.cpp +++ b/icu4c/source/test/intltest/localematchertest.cpp @@ -6,6 +6,7 @@ #include #include +#include #include "unicode/utypes.h" #include "unicode/localematcher.h" @@ -333,7 +334,9 @@ void LocaleMatcherTest::testDirection() { { // arz is a close one-way match to ar, and the region matches. // (Egyptian Arabic vs. Arabic) - LocaleMatcher withOneWay = builder.build(errorCode); + // Also explicitly exercise the move copy constructor. + LocaleMatcher built = builder.build(errorCode); + LocaleMatcher withOneWay(std::move(built)); Locale::RangeIterator desiredIter(ARRAY_RANGE(desired)); assertEquals("with one-way", "ar", locString(withOneWay.getBestMatch(desiredIter, errorCode))); @@ -341,8 +344,11 @@ void LocaleMatcherTest::testDirection() { { // nb is a less close two-way match to nn, and the regions differ. // (Norwegian Bokmal vs. Nynorsk) - LocaleMatcher onlyTwoWay = + // Also explicitly exercise the move assignment operator. + LocaleMatcher onlyTwoWay = builder.build(errorCode); + LocaleMatcher built = builder.setDirection(ULOCMATCH_DIRECTION_ONLY_TWO_WAY).build(errorCode); + onlyTwoWay = std::move(built); Locale::RangeIterator desiredIter(ARRAY_RANGE(desired)); assertEquals("only two-way", "nn", locString(onlyTwoWay.getBestMatch(desiredIter, errorCode))); -- 2.40.0