Revert "[lldb][test] Remove compiler version check and use regex" (#124101)
[llvm-project.git] / libc / test / src / string / strlcpy_test.cpp
blob0914257ecc1f3407f2cd876582b03faa2d7405d4
1 //===-- Unittests for strlcpy ---------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "src/string/strlcpy.h"
10 #include "test/UnitTest/Test.h"
12 TEST(LlvmLibcStrlcpyTest, TooBig) {
13 const char *str = "abc";
14 char buf[2];
15 EXPECT_EQ(LIBC_NAMESPACE::strlcpy(buf, str, 2), size_t(3));
16 EXPECT_STREQ(buf, "a");
18 EXPECT_EQ(LIBC_NAMESPACE::strlcpy(nullptr, str, 0), size_t(3));
21 TEST(LlvmLibcStrlcpyTest, Smaller) {
22 const char *str = "abc";
23 char buf[7]{"111111"};
25 EXPECT_EQ(LIBC_NAMESPACE::strlcpy(buf, str, 7), size_t(3));
26 EXPECT_STREQ(buf, "abc");
27 EXPECT_STREQ(buf + 4, "11");