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 <limits.h>
 3#include <stdio.h>
 4#include <stdlib.h>
 5
 6/*
 7output:
 8testing
 9done
10end:
11*/
12
13void
14test(void)
15{
16	long n;
17	char buf[64];
18
19	n = atol("abc");
20	assert(n == 0);
21
22	n = atol(" abc");
23	assert(n == 0);
24
25	n = atol("1234 ");
26	assert(n == 1234);
27
28	n = atol(" 1234 0");
29	assert(n == 1234);
30
31	n = atol("+");
32	assert(n == 0);
33
34	n = atol(" +1");
35	assert(n == 1);
36
37	n = atol("+ 1");
38	assert(n == 0);
39
40	n = atol(" -1");
41	assert(n == -1);
42
43	n = atol("- 1");
44	assert(n == 0);
45
46	sprintf(buf, "%ld", LONG_MAX);
47	n = atol(buf);
48	assert(n == LONG_MAX);
49
50	sprintf(buf, "%ld", LONG_MIN);
51	n = atol(buf);
52	assert(n == LONG_MIN);
53}
54
55int
56main()
57{
58	puts("testing");
59	test();
60	puts("done");
61
62	return 0;
63}