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

extern inline int libabort_saprintf(char *str, size_t size, const char *fmt, ...);

#else

int
main(void)
{
	char buf[6];
	int r;

	INIT_TEST_ABORT();

	EXPECT_NO_ABORT(r = libabort_saprintf(buf, sizeof(buf), "%s", "hello"));
	EXPECT(r == 5);
	EXPECT(!buf[r]);
	EXPECT(!strcmp(buf, "hello"));

	EXPECT_ABORT(libabort_saprintf(buf, sizeof(buf), "%s", "hello!"));
	EXPECT_ABORT(libabort_saprintf(buf, 0, "%s", ""));

	return 0;
}

#endif