1//===-- Unittests for strcat ----------------------------------------------===//
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//===----------------------------------------------------------------------===//
8
9#include "src/string/strcat.h"
10#include "test/UnitTest/Test.h"
11
12TEST(LlvmLibcStrCatTest, EmptyDest) {
13 const char *abc = "abc";
14 char dest[4];
15
16 dest[0] = '\0';
17
18 char *result = LIBC_NAMESPACE::strcat(dest, src: abc);
19 ASSERT_EQ(dest, result);
20 ASSERT_STREQ(dest, result);
21 ASSERT_STREQ(dest, abc);
22}
23
24TEST(LlvmLibcStrCatTest, NonEmptyDest) {
25 const char *abc = "abc";
26 char dest[7];
27
28 dest[0] = 'x';
29 dest[1] = 'y';
30 dest[2] = 'z';
31 dest[3] = '\0';
32
33 char *result = LIBC_NAMESPACE::strcat(dest, src: abc);
34 ASSERT_EQ(dest, result);
35 ASSERT_STREQ(dest, result);
36 ASSERT_STREQ(dest, "xyzabc");
37}
38

source code of libc/test/src/string/strcat_test.cpp