[libc-commits] [libc] [libc] Implemented wmempcpy (PR #142067)

Michael Jones via libc-commits libc-commits at lists.llvm.org
Fri May 30 12:57:03 PDT 2025


================
@@ -0,0 +1,50 @@
+//===-- Unittests for wmempcpy --------------------------------------------===//
+//
+// 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/wchar/wmempcpy.h"
+#include "test/UnitTest/Test.h"
+
+TEST(LlvmLibcWMempcpyTest, Simple) {
+  const wchar_t *src = L"12345";
+  wchar_t dest[10] = {};
+  void *result = LIBC_NAMESPACE::wmempcpy(dest, src, 6);
+  ASSERT_EQ(static_cast<wchar_t *>(result), dest + 6);
+
+  ASSERT_TRUE(src[0] == dest[0]);
+  ASSERT_TRUE(src[1] == dest[1]);
+  ASSERT_TRUE(src[2] == dest[2]);
+  ASSERT_TRUE(src[3] == dest[3]);
+  ASSERT_TRUE(src[4] == dest[4]);
+  ASSERT_TRUE(src[5] == dest[5]);
----------------
michaelrj-google wrote:

nit: it's good to be consistent with which side has `src` vs `dest`. In general I'd recommend putting the thing being tested on the left and the expected result on the right, so in this case `dest[n] == src[n]`.

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


More information about the libc-commits mailing list