-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add tests for static initialization and static constructors CORE-10562 svn path=/trunk/; revision=69991
- Loading branch information
Showing
4 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* PROJECT: ReactOS api tests | ||
* LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory | ||
* PURPOSE: Test for static C++ object construction | ||
* PROGRAMMER: Thomas Faber <thomas.faber@reactos.org> | ||
*/ | ||
|
||
#include <apitest.h> | ||
|
||
extern "C" | ||
{ | ||
extern int static_init_counter; | ||
|
||
static int static_init_counter_at_startup; | ||
static int static_construct_counter_at_startup; | ||
|
||
int static_construct_counter = 789; | ||
} | ||
|
||
struct init_static | ||
{ | ||
int m_counter; | ||
|
||
init_static() : | ||
m_counter(2) | ||
{ | ||
static_init_counter_at_startup = static_init_counter; | ||
static_construct_counter_at_startup = static_construct_counter; | ||
static_construct_counter++; | ||
} | ||
} init_static; | ||
|
||
START_TEST(static_construct) | ||
{ | ||
ok(static_init_counter_at_startup == 123, "static_init_counter at startup: %d\n", static_init_counter_at_startup); | ||
ok(static_construct_counter_at_startup == 789, "static_construct_counter at startup: %d\n", static_construct_counter_at_startup); | ||
|
||
ok(static_init_counter == 123, "static_init_counter: %d\n", static_init_counter); | ||
|
||
ok(static_construct_counter == 790, "static_construct_counter: %d\n", static_construct_counter); | ||
ok(init_static.m_counter == 2, "init_static.m_counter: %d\n", init_static.m_counter); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* PROJECT: ReactOS api tests | ||
* LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory | ||
* PURPOSE: Test for static variable initialization | ||
* PROGRAMMER: Thomas Faber <thomas.faber@reactos.org> | ||
*/ | ||
|
||
#include <apitest.h> | ||
|
||
extern int static_construct_counter; | ||
|
||
int static_init_counter = 123; | ||
|
||
START_TEST(static_init) | ||
{ | ||
ok(static_init_counter == 123, "static_init_counter: %d\n", static_init_counter); | ||
ok(static_construct_counter == 790, "static_construct_counter: %d\n", static_construct_counter); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters