scc

A fork of https://git.simple-cc.org/scc/ for Qute

git clone https://git.8pit.net/scc.git

 1#include <assert.h>
 2#include <stdio.h>
 3#include <string.h>
 4
 5#define SIZ 6
 6
 7/*
 8output:
 9testing
10test1
11test2
12test3
13done
14end:
15*/
16
17int
18main()
19{
20	char *s, buf[SIZ];
21
22	puts("testing");
23
24	puts("test1");
25	memset(buf, '0', SIZ);
26	s = strncpy(buf, "abc", sizeof(buf));
27	assert(s == buf);
28	assert(!memcmp(s, (char[SIZ]) {"abc"}, sizeof(buf)));
29
30	puts("test2");
31	memset(buf, '0', SIZ);
32	s = strncpy(buf, "", sizeof(buf));
33	assert(s == buf);
34	assert(!memcmp(s, (char[SIZ]) {'\0'}, sizeof(buf)));
35
36	puts("test3");
37	memset(buf, '0', SIZ);
38	s = strncpy(buf, "", 1);
39	assert(s == buf);
40	assert(!memcmp(s,
41	               (char[SIZ]) {'\0', '0', '0', '0', '0', '0'},
42	               sizeof(buf)));
43
44	puts("done");
45
46	return 0;
47}