[libc-commits] [libc] [libc] Implemented wmemset and added tests (PR #141691)
Michael Jones via libc-commits
libc-commits at lists.llvm.org
Wed May 28 13:36:05 PDT 2025
================
@@ -0,0 +1,87 @@
+//===-- Unittests for wmemset ---------------------------------------------===//
+//
+// 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 "hdr/types/size_t.h"
+#include "hdr/types/wchar_t.h"
+#include "src/wchar/wmemset.h"
+#include "test/UnitTest/Test.h"
+
+TEST(LlvmLibcWMemsetTest, SmallStringBoundCheck) {
+ wchar_t *str = new wchar_t[5];
----------------
michaelrj-google wrote:
If you use `new` here that puts the data on the heap. When possible, it's preferred to put test variables on the stack to simplify memory management. To do that you define the variable as a local array instead of just a pointer.
Same recommendation on all these tests, but for simplicity I'm just marking this one.
```suggestion
wchar_t str[5];
```
https://github.com/llvm/llvm-project/pull/141691
More information about the libc-commits
mailing list