[OptTable] Fix typo VALUE => VALUES (NFCI) (#121523)
[llvm-project.git] / libc / test / src / string / strcpy_test.cpp
blob1a1227aac5d2f80ca3e94cd31c26cfcb3befec02
1 //===-- Unittests for strcpy ----------------------------------------------===//
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/strcpy.h"
10 #include "test/UnitTest/Test.h"
12 TEST(LlvmLibcStrCpyTest, EmptySrc) {
13 const char *empty = "";
14 char dest[4] = {'a', 'b', 'c', '\0'};
16 char *result = LIBC_NAMESPACE::strcpy(dest, empty);
17 ASSERT_EQ(dest, result);
18 ASSERT_STREQ(dest, result);
19 ASSERT_STREQ(dest, empty);
22 TEST(LlvmLibcStrCpyTest, EmptyDest) {
23 const char *abc = "abc";
24 char dest[4];
26 char *result = LIBC_NAMESPACE::strcpy(dest, abc);
27 ASSERT_EQ(dest, result);
28 ASSERT_STREQ(dest, result);
29 ASSERT_STREQ(dest, abc);
32 TEST(LlvmLibcStrCpyTest, OffsetDest) {
33 const char *abc = "abc";
34 char dest[7];
36 dest[0] = 'x';
37 dest[1] = 'y';
38 dest[2] = 'z';
40 char *result = LIBC_NAMESPACE::strcpy(dest + 3, abc);
41 ASSERT_EQ(dest + 3, result);
42 ASSERT_STREQ(dest + 3, result);
43 ASSERT_STREQ(dest, "xyzabc");