[libc-commits] [libc] [libc] wcstok implementation (PR #145989)
Michael Jones via libc-commits
libc-commits at lists.llvm.org
Fri Jun 27 10:25:40 PDT 2025
================
@@ -0,0 +1,181 @@
+//===-- Unittests for wcstok ----------------------------------------------===//
+//
+// 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/wcstok.h"
+#include "test/UnitTest/Test.h"
+
+TEST(LlvmLibcWCSTokReentrantTest, NoTokenFound) {
+ { // Empty source and delimiter string.
+ wchar_t empty[] = L"";
+ wchar_t *reserve = nullptr;
+ ASSERT_EQ(LIBC_NAMESPACE::wcstok(empty, L"", &reserve), nullptr);
+ // Another call to ensure that 'reserve' is not in a bad state.
+ ASSERT_EQ(LIBC_NAMESPACE::wcstok(empty, L"", &reserve), nullptr);
+ ASSERT_EQ(LIBC_NAMESPACE::wcstok(nullptr, L"", &reserve), nullptr);
+ }
+ { // Empty source and single character delimiter string.
+ wchar_t empty[] = L"";
+ wchar_t *reserve = nullptr;
+ ASSERT_EQ(LIBC_NAMESPACE::wcstok(empty, L"_", &reserve), nullptr);
+ // Another call to ensure that 'reserve' is not in a bad state.
+ ASSERT_EQ(LIBC_NAMESPACE::wcstok(empty, L"_", &reserve), nullptr);
+ ASSERT_EQ(LIBC_NAMESPACE::wcstok(nullptr, L"_", &reserve), nullptr);
+ }
+ { // Same wchar_tacter source and delimiter string.
----------------
michaelrj-google wrote:
find/replace error (char -> wchar_t) here and in a few other comments
https://github.com/llvm/llvm-project/pull/145989
More information about the libc-commits
mailing list