From 4037b90f130f5511bfc196d404a3a419ebc06879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bargull?= Date: Tue, 26 Oct 2021 07:21:13 +0000 Subject: [PATCH] Bug 1736805: Register written normalised length. r=platform-i18n-reviewers,gregtatum Differential Revision: https://phabricator.services.mozilla.com/D129428 --- intl/components/gtest/TestString.cpp | 7 +++++++ intl/components/src/String.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/intl/components/gtest/TestString.cpp b/intl/components/gtest/TestString.cpp index f785b5b05851..529f63839350 100644 --- a/intl/components/gtest/TestString.cpp +++ b/intl/components/gtest/TestString.cpp @@ -121,6 +121,13 @@ TEST(IntlString, NormalizeNFD) alreadyNormalized = String::Normalize(NormalizationForm::NFD, u"½"sv, buf); ASSERT_EQ(alreadyNormalized.unwrap(), AlreadyNormalized::Yes); ASSERT_EQ(buf.get_string_view(), u""); + + // Test with inline capacity. + TestBuffer buf2; + + alreadyNormalized = String::Normalize(NormalizationForm::NFD, u" ç"sv, buf2); + ASSERT_EQ(alreadyNormalized.unwrap(), AlreadyNormalized::No); + ASSERT_EQ(buf2.get_string_view(), u" c\u0327"); } TEST(IntlString, NormalizeNFKC) diff --git a/intl/components/src/String.h b/intl/components/src/String.h index 894ef1104d0f..9125c59ce661 100644 --- a/intl/components/src/String.h +++ b/intl/components/src/String.h @@ -150,6 +150,8 @@ class String final { // Copy the already normalized prefix. if (spanLength > 0) { PodCopy(aBuffer.data(), aString.data(), spanLength); + + aBuffer.written(spanLength); } MOZ_TRY(FillBufferWithICUCall(