summaryrefslogtreecommitdiff
path: root/tests/libc/test_sprintf.c
blob: b1f25c71e13ac977206e4fac8c91caee58c8724c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "string.h"
#include "stdlib.h"
#include "stdio.h"
#include "string.h"

int main( void )
{
	char *s = "test_string";
	int i = 47;
	char c = 'X';
	char buf[100];
	const char *must = "string 'test_string', decimal 47, hex 0x2F, character 'X'\n";

	snprintf( buf, 100, "string '%s', decimal %d, hex 0x%X, character '%c'\n",
		s, i, i, c );
	if( strncmp( buf, must, strlen( must ) ) != 0 ) exit( 1 );

	exit( 0 );
}