1 //===-- Unittests for strcpy ----------------------------------------------===//
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
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";
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";
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");