[CRT_APITEST]
[reactos.git] / rostests / apitests / crt / static_construct.cpp
1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
4 * PURPOSE: Test for static C++ object construction
5 * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
6 */
7
8 #include <apitest.h>
9
10 extern "C"
11 {
12 extern int static_init_counter;
13
14 static int static_init_counter_at_startup;
15 static int static_construct_counter_at_startup;
16
17 int static_construct_counter = 789;
18 }
19
20 struct init_static
21 {
22 int m_counter;
23
24 init_static() :
25 m_counter(2)
26 {
27 static_init_counter_at_startup = static_init_counter;
28 static_construct_counter_at_startup = static_construct_counter;
29 static_construct_counter++;
30 }
31 } init_static;
32
33 START_TEST(static_construct)
34 {
35 ok(static_init_counter_at_startup == 123, "static_init_counter at startup: %d\n", static_init_counter_at_startup);
36 ok(static_construct_counter_at_startup == 789, "static_construct_counter at startup: %d\n", static_construct_counter_at_startup);
37
38 ok(static_init_counter == 123, "static_init_counter: %d\n", static_init_counter);
39
40 ok(static_construct_counter == 790, "static_construct_counter: %d\n", static_construct_counter);
41 ok(init_static.m_counter == 2, "init_static.m_counter: %d\n", init_static.m_counter);
42 }