1 // RUN: %clangxx -O0 -g %s -o %t && %run %t
2
3 // UNSUPPORTED: linux
4
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
8
test1()9 void test1() {
10 const char src[] = "abc";
11 char dst[7] = {'x', 'y', 'z', 0};
12 size_t len;
13
14 len = strlcat(dst, src, sizeof(dst));
15 printf("%s %zu ", dst, len);
16 }
17
test2()18 void test2() {
19 const char src[] = "abc";
20 char dst[7] = {0};
21 size_t len;
22
23 len = strlcat(dst, src, sizeof(dst));
24 printf("%s %zu ", dst, len);
25 }
26
test3()27 void test3() {
28 const char src[] = "abc";
29 char dst[4] = {'x', 'y', 'z', 0};
30 size_t len;
31
32 len = strlcat(dst, src, sizeof(dst));
33 printf("%s %zu ", dst, len);
34 }
35
test4()36 void test4() {
37 const char src[] = "";
38 char dst[4] = {'x', 'y', 'z', 0};
39 size_t len;
40
41 len = strlcat(dst, src, sizeof(dst));
42 printf("%s %zu\n", dst, len);
43 }
44
main(void)45 int main(void) {
46 test1();
47 test2();
48 test3();
49 test4();
50
51 // CHECK: xyzabc 6 abc 3 xyz 3 xyz 3
52
53 return 0;
54 }
55