summaryrefslogtreecommitdiff
path: root/ccan/tal/test/run-named-debug.c
blob: 679e6ec8df4117f3690f16db9a61a50673b6103b (plain)
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
#define CCAN_TAL_DEBUG
#include <ccan/tal/tal.h>
#include <ccan/tal/tal.c>
#include <ccan/tap/tap.h>

int main(void)
{
	int *p;
	char name[] = "test name";

	plan_tests(6);

	p = tal(NULL, int);
	ok1(strcmp(tal_name(p), __FILE__ ":13:int") == 0);

	tal_set_name(p, "some literal");
	ok1(strcmp(tal_name(p), "some literal") == 0);

	tal_set_name(p, name);
	ok1(strcmp(tal_name(p), name) == 0);
	/* You can't reuse my pointer though! */
	ok1(tal_name(p) != name);

	tal_set_name(p, "some other literal");
	ok1(strcmp(tal_name(p), "some other literal") == 0);

	tal_free(p);

	p = tal_arr(NULL, int, 2);
	ok1(strcmp(tal_name(p), __FILE__ ":29:int[]") == 0);
	tal_free(p);

	tal_cleanup();
	return exit_status();
}