[libc-commits] [libc] [libc] Implemented CharacterConverter push/pop for utf32->utf8 conversions (PR #143971)

Michael Jones via libc-commits libc-commits at lists.llvm.org
Fri Jun 13 14:43:33 PDT 2025


================
@@ -0,0 +1,160 @@
+//===-- Unittests for the CharacterConverter class (utf32 -> 8) -----------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/__support/common.h"
+#include "src/__support/wchar/character_converter.h"
+#include "src/__support/wchar/mbstate.h"
+
+#include "test/UnitTest/Test.h"
+
+TEST(LlvmLibcCharacterConverterUTF32To8Test, OneByte) {
+  LIBC_NAMESPACE::internal::mbstate state{0, 0, 0};
+  LIBC_NAMESPACE::internal::CharacterConverter cr(&state);
----------------
michaelrj-google wrote:

it might be useful to add a `clear()` function to `CharacterConverter` so you don't have to manually set the state at the start of the test

https://github.com/llvm/llvm-project/pull/143971


More information about the libc-commits mailing list