aboutsummaryrefslogtreecommitdiffstats
path: root/libabort_stpacat.c
blob: 35d8dd876e27c6853a1363670bf929505dd3aeb9 (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
/* See LICENSE file for copyright and license details. */
#include "common.h"
#ifndef TEST

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

#else

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

	INIT_TEST_ABORT();

	stracpy(buf, "hello", sizeof(buf));
	EXPECT_NO_ABORT(p = stpacat(buf, " world", sizeof(buf)));
	EXPECT(!strcmp(buf, "hello world"));
	EXPECT(p == &buf[11]);
	EXPECT(*p == '\0');

	stracpy(buf, "hello", sizeof(buf));
	EXPECT_ABORT(stpacat(buf, " world", 11));
	EXPECT_ABORT(stpacat(buf, "", 0));

	return 0;
}

#endif