File: test_shm.c

package info (click to toggle)
proxychains-ng 4.17-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 456 kB
  • sloc: ansic: 3,651; sh: 376; makefile: 80
file content (39 lines) | stat: -rw-r--r-- 732 bytes parent folder | download | duplicates (4)
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
31
32
33
34
35
36
37
38
39
#include "../src/shm.h"
#include <assert.h>

#define s(A) (sizeof(A) - 1)
#define ss(A) (A), s(A)

int main() {
	char buf4096[4096];
	struct stringpool sp;
	stringpool_init(&sp);
	char *r;
	size_t pos = 0;
	r = stringpool_add(&sp, ss("AAAAA"));
	assert(r == sp.start);
	
	pos += s("AAAAA");
	assert(sp.alloced == 4096);
	assert(sp.used == pos);
	
	r = stringpool_add(&sp, buf4096, sizeof(buf4096));
	assert(r == sp.start + pos);
	
	pos += sizeof(buf4096);
	assert(sp.alloced == 4096 * 2);
	assert(sp.used == pos);
	
	r = stringpool_add(&sp, buf4096, 4096 - s("AAAAA"));
	assert(r == sp.start + pos);
	pos += 4096 - s("AAAAA");
	assert(pos == 4096 * 2);

	assert(sp.alloced == 4096 * 2);
	assert(sp.used == pos);
	
	
	
	return 0;
	
}