xref: /netbsd-src/external/bsd/libc++/dist/libcxxrt/test/test_guard.cc (revision ccec91a1a97277b5fa1e64b269648792fb078e34)
1 #include <stdio.h>
2 #include "test.h"
3 
4 static int static_count;
5 struct static_struct
6 {
7 	int i;
static_structstatic_struct8 	static_struct()
9 	{
10 		static_count++;
11 		i = 12;
12 	};
13 };
14 
15 static static_struct ss;
16 
init_static(void)17 int init_static(void)
18 {
19 	static static_struct s;
20 	return s.i;
21 }
22 
test_guards(void)23 void test_guards(void)
24 {
25 	init_static();
26 	int i = init_static();
27 	TEST(i == 12, "Static initialized");
28 	TEST(static_count == 2, "Each static only initialized once");
29 }
30