mirror of
https://github.com/reactos/reactos.git
synced 2025-04-22 13:10:39 +00:00
[CRT_APITEST]
- Add tests for static initialization and static constructors CORE-10562 svn path=/trunk/; revision=69991
This commit is contained in:
parent
cd1f296855
commit
bfa1295d2b
4 changed files with 68 additions and 0 deletions
|
@ -1261,6 +1261,8 @@ list(APPEND SOURCE_MSVCRT
|
|||
# wprintf_s.c
|
||||
# wscanf.c
|
||||
# wscanf_s.c
|
||||
static_construct.cpp
|
||||
static_init.c
|
||||
)
|
||||
|
||||
if(ARCH STREQUAL "i386")
|
||||
|
|
42
rostests/apitests/crt/static_construct.cpp
Normal file
42
rostests/apitests/crt/static_construct.cpp
Normal file
|
@ -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);
|
||||
}
|
18
rostests/apitests/crt/static_init.c
Normal file
18
rostests/apitests/crt/static_init.c
Normal file
|
@ -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);
|
||||
}
|
|
@ -17,6 +17,9 @@ extern void func_sprintf(void);
|
|||
extern void func_strcpy(void);
|
||||
extern void func_wcstombs(void);
|
||||
|
||||
extern void func_static_construct(void);
|
||||
extern void func_static_init(void);
|
||||
|
||||
const struct test winetest_testlist[] =
|
||||
{
|
||||
{ "_vsnprintf", func__vsnprintf },
|
||||
|
@ -35,6 +38,9 @@ const struct test winetest_testlist[] =
|
|||
#elif defined(TEST_MSVCRT)
|
||||
{ "_vscprintf", func__vscprintf },
|
||||
{ "_vscwprintf", func__vscwprintf },
|
||||
|
||||
{ "static_construct", func_static_construct },
|
||||
{ "static_init", func_static_init },
|
||||
#elif defined(TEST_NTDLL)
|
||||
{ "_vscwprintf", func__vscwprintf },
|
||||
#elif defined(TEST_CRTDLL)
|
||||
|
|
Loading…
Reference in a new issue