aboutsummaryrefslogtreecommitdiffstats
path: root/libabort_stracat.c
blob: a3a32fbfbd7cd1874dfc838d2647230415d49f29 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* See LICENSE file for copyright and license details. */
#include "common.h"
#ifndef TEST

extern inline char *libabort_stracat(char *dst, const char *src, size_t size);

#else

int
main(void)
{
	char buf[16];
	char *p;

	INIT_TEST_ABORT();

	buf[0] = '\0';
	EXPECT_NO_ABORT(p = libabort_stracat(buf, "hello", sizeof(buf)));
	EXPECT(p == buf);
	EXPECT(!buf[5]);
	EXPECT(!strcmp(buf, "hello"));

	EXPECT_NO_ABORT(p = libabort_stracat(buf, " world", sizeof(buf)));
	EXPECT(p == buf);
	EXPECT(!buf[11]);
	EXPECT(!strcmp(buf, "hello world"));

	EXPECT_ABORT(libabort_stracat(buf, " 0123456789abcdef", sizeof(buf)));

	return 0;
}

#endif