summaryrefslogtreecommitdiff
path: root/test/test_guard.cc
blob: 1ad5a2f58134ff01874e2d8e266af9fc4af0485d (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
#include <stdio.h>
#include "test.h"

static int static_count;
struct static_struct
{
	int i;
	static_struct()
	{
		static_count++;
		i = 12;
	};
};

static static_struct ss;

int init_static(void)
{
	static static_struct s;
	return s.i;
}

void test_guards(void)
{
	init_static();
	int i = init_static();
	TEST(i == 12, "Static initialized");
	TEST(static_count == 2, "Each static only initialized once");
}