[libc-commits] [libc] [libc] Add `ctime_s` (PR #110676)
Rajveer Singh Bharadwaj via libc-commits
libc-commits at lists.llvm.org
Sat Nov 23 10:35:36 PST 2024
================
@@ -0,0 +1,66 @@
+//===-- Unittests for ctime_s ---------------------------------------------===//
+//
+// 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/errno_macros.h"
+#include "src/errno/libc_errno.h"
+#include "src/time/ctime_s.h"
+#include "src/time/time_utils.h"
+#include "test/UnitTest/Test.h"
+#include "test/src/time/TmHelper.h"
+
+using LIBC_NAMESPACE::time_utils::TimeConstants;
+
+TEST(LlvmLibcCtimeS, Nullptr) {
+ int result = LIBC_NAMESPACE::ctime_s(nullptr, 0, nullptr);
+ ASSERT_EQ(EINVAL, result);
+
+ char buffer[TimeConstants::ASCTIME_BUFFER_SIZE];
+ result = LIBC_NAMESPACE::ctime_s(buffer, sizeof(buffer), nullptr);
+ ASSERT_EQ(EINVAL, result);
+ ASSERT_EQ('\0', buffer[0]);
----------------
Rajveer100 wrote:
I didn't catch this since this surprisingly didn't fail for me.
https://github.com/llvm/llvm-project/pull/110676
More information about the libc-commits
mailing list