mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
remove msvcrt winetests
svn path=/trunk/; revision=17104
This commit is contained in:
parent
f2272e8e74
commit
8704e1ebff
11 changed files with 0 additions and 1903 deletions
|
@ -1,21 +0,0 @@
|
|||
TOPSRCDIR = @top_srcdir@
|
||||
TOPOBJDIR = ../../..
|
||||
SRCDIR = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
TESTDLL = msvcrt.dll
|
||||
IMPORTS = msvcrt
|
||||
EXTRAINCL = -I$(TOPSRCDIR)/include/msvcrt -I$(SRCDIR)/..
|
||||
|
||||
CTESTS = \
|
||||
cpp.c \
|
||||
environ.c \
|
||||
file.c \
|
||||
heap.c \
|
||||
printf.c \
|
||||
scanf.c \
|
||||
string.c \
|
||||
time.c
|
||||
|
||||
@MAKE_TEST_RULES@
|
||||
|
||||
### Dependencies:
|
|
@ -1,831 +0,0 @@
|
|||
/* Unit test suite for msvcrt C++ objects
|
||||
*
|
||||
* Copyright 2003 Jon Griffiths
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* NOTES
|
||||
* This tests is only valid for ix86 platforms, on others it's a no-op.
|
||||
* Some tests cannot be checked with ok(), for example the dtors. We simply
|
||||
* call them to ensure we don't crash ;-)
|
||||
*
|
||||
* If we build this test with VC++ in debug mode, we will fail in _chkstk()
|
||||
* or at program exit malloc() checking if these methods haven't been
|
||||
* implemented correctly (they have).
|
||||
*
|
||||
* Tested with a range of native msvcrt's from v4 -> v7.
|
||||
*/
|
||||
#include "wine/test.h"
|
||||
#include "winbase.h"
|
||||
#include "winnt.h"
|
||||
|
||||
#ifndef __i386__
|
||||
/* Skip these tests for non x86 platforms */
|
||||
START_TEST(cpp)
|
||||
{
|
||||
}
|
||||
#else
|
||||
|
||||
typedef struct __exception
|
||||
{
|
||||
void *vtable;
|
||||
char *name;
|
||||
int do_free;
|
||||
} exception;
|
||||
|
||||
typedef struct __type_info
|
||||
{
|
||||
void *vtable;
|
||||
char *name;
|
||||
char mangled[16];
|
||||
} type_info;
|
||||
|
||||
/* Function pointers. We need to use these to call these funcs as __thiscall */
|
||||
static HMODULE hMsvcrt;
|
||||
|
||||
static void* (*poperator_new)(unsigned int);
|
||||
static void (*poperator_delete)(void*);
|
||||
static void* (*pmalloc)(unsigned int);
|
||||
static void (*pfree)(void*);
|
||||
|
||||
/* exception */
|
||||
static void (WINAPI *pexception_ctor)(exception*,LPCSTR*);
|
||||
static void (WINAPI *pexception_copy_ctor)(exception*,exception*);
|
||||
static void (WINAPI *pexception_default_ctor)(exception*);
|
||||
static void (WINAPI *pexception_dtor)(exception*);
|
||||
static exception* (WINAPI *pexception_opequals)(exception*,exception*);
|
||||
static char* (WINAPI *pexception_what)(exception*);
|
||||
static void* (WINAPI *pexception_vtable)(exception*);
|
||||
static void (WINAPI *pexception_vector_dtor)(exception*,unsigned int);
|
||||
static void (WINAPI *pexception_scalar_dtor)(exception*,unsigned int);
|
||||
|
||||
/* bad_typeid */
|
||||
static void (WINAPI *pbad_typeid_ctor)(exception*,LPCSTR);
|
||||
static void (WINAPI *pbad_typeid_ctor_closure)(exception*);
|
||||
static void (WINAPI *pbad_typeid_copy_ctor)(exception*,exception*);
|
||||
static void (WINAPI *pbad_typeid_dtor)(exception*);
|
||||
static exception* (WINAPI *pbad_typeid_opequals)(exception*,exception*);
|
||||
static char* (WINAPI *pbad_typeid_what)(exception*);
|
||||
static void* (WINAPI *pbad_typeid_vtable)(exception*);
|
||||
static void (WINAPI *pbad_typeid_vector_dtor)(exception*,unsigned int);
|
||||
static void (WINAPI *pbad_typeid_scalar_dtor)(exception*,unsigned int);
|
||||
|
||||
/* bad_cast */
|
||||
static void (WINAPI *pbad_cast_ctor)(exception*,LPCSTR*);
|
||||
static void (WINAPI *pbad_cast_ctor2)(exception*,LPCSTR);
|
||||
static void (WINAPI *pbad_cast_ctor_closure)(exception*);
|
||||
static void (WINAPI *pbad_cast_copy_ctor)(exception*,exception*);
|
||||
static void (WINAPI *pbad_cast_dtor)(exception*);
|
||||
static exception* (WINAPI *pbad_cast_opequals)(exception*,exception*);
|
||||
static char* (WINAPI *pbad_cast_what)(exception*);
|
||||
static void* (WINAPI *pbad_cast_vtable)(exception*);
|
||||
static void (WINAPI *pbad_cast_vector_dtor)(exception*,unsigned int);
|
||||
static void (WINAPI *pbad_cast_scalar_dtor)(exception*,unsigned int);
|
||||
|
||||
/* __non_rtti_object */
|
||||
static void (WINAPI *p__non_rtti_object_ctor)(exception*,LPCSTR);
|
||||
static void (WINAPI *p__non_rtti_object_copy_ctor)(exception*,exception*);
|
||||
static void (WINAPI *p__non_rtti_object_dtor)(exception*);
|
||||
static exception* (WINAPI *p__non_rtti_object_opequals)(exception*,exception*);
|
||||
static char* (WINAPI *p__non_rtti_object_what)(exception*);
|
||||
static void* (WINAPI *p__non_rtti_object_vtable)(exception*);
|
||||
static void (WINAPI *p__non_rtti_object_vector_dtor)(exception*,unsigned int);
|
||||
static void (WINAPI *p__non_rtti_object_scalar_dtor)(exception*,unsigned int);
|
||||
|
||||
/* type_info */
|
||||
static void (WINAPI *ptype_info_dtor)(type_info*);
|
||||
static char* (WINAPI *ptype_info_raw_name)(type_info*);
|
||||
static char* (WINAPI *ptype_info_name)(type_info*);
|
||||
static int (WINAPI *ptype_info_before)(type_info*,type_info*);
|
||||
static int (WINAPI *ptype_info_opequals_equals)(type_info*,type_info*);
|
||||
static int (WINAPI *ptype_info_opnot_equals)(type_info*,type_info*);
|
||||
|
||||
/* RTTI */
|
||||
static type_info* (*p__RTtypeid)(void*);
|
||||
static void* (*p__RTCastToVoid)(void*);
|
||||
static void* (*p__RTDynamicCast)(void*,int,void*,void*,int);
|
||||
|
||||
/* _very_ early native versions have serious RTTI bugs, so we check */
|
||||
static void* bAncientVersion;
|
||||
|
||||
/* Emulate a __thiscall */
|
||||
#ifdef _MSC_VER
|
||||
inline static void* do_call_func1(void *func, void *_this)
|
||||
{
|
||||
volatile void* retval = 0;
|
||||
__asm
|
||||
{
|
||||
push ecx
|
||||
mov ecx, _this
|
||||
call func
|
||||
mov retval, eax
|
||||
pop ecx
|
||||
}
|
||||
return (void*)retval;
|
||||
}
|
||||
|
||||
inline static void* do_call_func2(void *func, void *_this, void* arg)
|
||||
{
|
||||
volatile void* retval = 0;
|
||||
__asm
|
||||
{
|
||||
push ecx
|
||||
push arg
|
||||
mov ecx, _this
|
||||
call func
|
||||
mov retval, eax
|
||||
pop ecx
|
||||
}
|
||||
return (void*)retval;
|
||||
}
|
||||
#else
|
||||
static void* do_call_func1(void *func, void *_this)
|
||||
{
|
||||
void* ret;
|
||||
__asm__ __volatile__ ("call *%1"
|
||||
: "=a" (ret)
|
||||
: "g" (func), "c" (_this)
|
||||
: "memory" );
|
||||
return ret;
|
||||
}
|
||||
static void* do_call_func2(void *func, void *_this, void* arg)
|
||||
{
|
||||
void* ret;
|
||||
__asm__ __volatile__ ("pushl %2\n\tcall *%1"
|
||||
: "=a" (ret)
|
||||
: "r" (func), "g" (arg), "c" (_this)
|
||||
: "memory" );
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define call_func1(x,y) do_call_func1((void*)x,(void*)y)
|
||||
#define call_func2(x,y,z) do_call_func2((void*)x,(void*)y,(void*)z)
|
||||
|
||||
/* Some exports are only available in later versions */
|
||||
#define SETNOFAIL(x,y) x = (void*)GetProcAddress(hMsvcrt,y)
|
||||
#define SET(x,y) SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y)
|
||||
|
||||
static void InitFunctionPtrs()
|
||||
{
|
||||
hMsvcrt = LoadLibraryA("msvcrt.dll");
|
||||
ok(hMsvcrt != 0, "LoadLibraryA failed\n");
|
||||
if (hMsvcrt)
|
||||
{
|
||||
SETNOFAIL(poperator_new, "??_U@YAPAXI@Z");
|
||||
SETNOFAIL(poperator_delete, "??_V@YAXPAX@Z");
|
||||
SET(pmalloc, "malloc");
|
||||
SET(pfree, "free");
|
||||
|
||||
if (!poperator_new)
|
||||
poperator_new = pmalloc;
|
||||
if (!poperator_delete)
|
||||
poperator_delete = pfree;
|
||||
|
||||
SET(pexception_ctor, "??0exception@@QAE@ABQBD@Z");
|
||||
SET(pexception_copy_ctor, "??0exception@@QAE@ABV0@@Z");
|
||||
SET(pexception_default_ctor, "??0exception@@QAE@XZ");
|
||||
SET(pexception_dtor, "??1exception@@UAE@XZ");
|
||||
SET(pexception_opequals, "??4exception@@QAEAAV0@ABV0@@Z");
|
||||
SET(pexception_what, "?what@exception@@UBEPBDXZ");
|
||||
SET(pexception_vtable, "??_7exception@@6B@");
|
||||
SET(pexception_vector_dtor, "??_Eexception@@UAEPAXI@Z");
|
||||
SET(pexception_scalar_dtor, "??_Gexception@@UAEPAXI@Z");
|
||||
|
||||
SET(pbad_typeid_ctor, "??0bad_typeid@@QAE@PBD@Z");
|
||||
SETNOFAIL(pbad_typeid_ctor_closure, "??_Fbad_typeid@@QAEXXZ");
|
||||
SET(pbad_typeid_copy_ctor, "??0bad_typeid@@QAE@ABV0@@Z");
|
||||
SET(pbad_typeid_dtor, "??1bad_typeid@@UAE@XZ");
|
||||
SET(pbad_typeid_opequals, "??4bad_typeid@@QAEAAV0@ABV0@@Z");
|
||||
SET(pbad_typeid_what, "?what@exception@@UBEPBDXZ");
|
||||
SET(pbad_typeid_vtable, "??_7bad_typeid@@6B@");
|
||||
SET(pbad_typeid_vector_dtor, "??_Ebad_typeid@@UAEPAXI@Z");
|
||||
SET(pbad_typeid_scalar_dtor, "??_Gbad_typeid@@UAEPAXI@Z");
|
||||
|
||||
SETNOFAIL(pbad_cast_ctor, "??0bad_cast@@QAE@ABQBD@Z");
|
||||
if (!pbad_cast_ctor)
|
||||
SET(pbad_cast_ctor, "??0bad_cast@@AAE@PBQBD@Z");
|
||||
SETNOFAIL(pbad_cast_ctor2, "??0bad_cast@@QAE@PBD@Z");
|
||||
SETNOFAIL(pbad_cast_ctor_closure, "??_Fbad_cast@@QAEXXZ");
|
||||
SET(pbad_cast_copy_ctor, "??0bad_cast@@QAE@ABV0@@Z");
|
||||
SET(pbad_cast_dtor, "??1bad_cast@@UAE@XZ");
|
||||
SET(pbad_cast_opequals, "??4bad_cast@@QAEAAV0@ABV0@@Z");
|
||||
SET(pbad_cast_what, "?what@exception@@UBEPBDXZ");
|
||||
SET(pbad_cast_vtable, "??_7bad_cast@@6B@");
|
||||
SET(pbad_cast_vector_dtor, "??_Ebad_cast@@UAEPAXI@Z");
|
||||
SET(pbad_cast_scalar_dtor, "??_Gbad_cast@@UAEPAXI@Z");
|
||||
|
||||
SET(p__non_rtti_object_ctor, "??0__non_rtti_object@@QAE@PBD@Z");
|
||||
SET(p__non_rtti_object_copy_ctor, "??0__non_rtti_object@@QAE@ABV0@@Z");
|
||||
SET(p__non_rtti_object_dtor, "??1__non_rtti_object@@UAE@XZ");
|
||||
SET(p__non_rtti_object_opequals, "??4__non_rtti_object@@QAEAAV0@ABV0@@Z");
|
||||
SET(p__non_rtti_object_what, "?what@exception@@UBEPBDXZ");
|
||||
SET(p__non_rtti_object_vtable, "??_7__non_rtti_object@@6B@");
|
||||
SET(p__non_rtti_object_vector_dtor, "??_E__non_rtti_object@@UAEPAXI@Z");
|
||||
SET(p__non_rtti_object_scalar_dtor, "??_G__non_rtti_object@@UAEPAXI@Z");
|
||||
|
||||
SET(ptype_info_dtor, "??1type_info@@UAE@XZ");
|
||||
SET(ptype_info_raw_name, "?raw_name@type_info@@QBEPBDXZ");
|
||||
#ifndef __REACTOS__
|
||||
SET(ptype_info_name, "?name@type_info@@QBEPBDXZ");
|
||||
#endif
|
||||
SET(ptype_info_before, "?before@type_info@@QBEHABV1@@Z");
|
||||
SET(ptype_info_opequals_equals, "??8type_info@@QBEHABV0@@Z");
|
||||
SET(ptype_info_opnot_equals, "??9type_info@@QBEHABV0@@Z");
|
||||
|
||||
SET(p__RTtypeid, "__RTtypeid");
|
||||
SET(p__RTCastToVoid, "__RTCastToVoid");
|
||||
SET(p__RTDynamicCast, "__RTDynamicCast");
|
||||
|
||||
/* Extremely early versions export logic_error, and crash in RTTI */
|
||||
SETNOFAIL(bAncientVersion, "??0logic_error@@QAE@ABQBD@Z");
|
||||
}
|
||||
}
|
||||
|
||||
static void test_exception(void)
|
||||
{
|
||||
static const char* e_name = "An exception name";
|
||||
char* name;
|
||||
exception e, e2, e3, *pe;
|
||||
|
||||
if (!poperator_new || !poperator_delete ||
|
||||
!pexception_ctor || !pexception_copy_ctor || !pexception_default_ctor ||
|
||||
!pexception_dtor || !pexception_opequals || !pexception_what ||
|
||||
!pexception_vtable || !pexception_vector_dtor || !pexception_scalar_dtor)
|
||||
return;
|
||||
|
||||
/* 'const char*&' ctor */
|
||||
memset(&e, 0, sizeof(e));
|
||||
call_func2(pexception_ctor, &e, &e_name);
|
||||
ok(e.vtable != NULL, "Null exception vtable for e\n");
|
||||
ok(e.name && e.name != e_name && !strcmp(e.name, "An exception name"), "Bad name '%s' for e\n", e.name);
|
||||
ok(e.do_free == 1, "do_free set to %d for e\n", e.do_free);
|
||||
|
||||
/* Copy ctor */
|
||||
memset(&e2, 0, sizeof(e2));
|
||||
call_func2(pexception_copy_ctor, &e2, &e);
|
||||
ok(e2.vtable != NULL, "Null exception vtable for e2\n");
|
||||
ok(e2.name && e2.name != e.name && !strcmp(e2.name, "An exception name"), "Bad exception name for e2\n");
|
||||
ok(e2.do_free == 1, "do_free set to %d for e2\n", e2.do_free);
|
||||
|
||||
/* Default ctor */
|
||||
memset(&e3, 1, sizeof(e3));
|
||||
call_func1(pexception_default_ctor, &e3);
|
||||
ok(e3.vtable != NULL, "Null exception vtable for e3\n");
|
||||
ok(e3.name == NULL, "Bad exception name for e3\n");
|
||||
ok(e3.do_free == 0, "do_free set to %d for e3\n", e3.do_free);
|
||||
|
||||
ok(e.vtable == e2.vtable && e.vtable == e3.vtable, "exception vtables differ!\n");
|
||||
|
||||
/* Test calling the dtors */
|
||||
call_func1(pexception_dtor, &e2);
|
||||
call_func1(pexception_dtor, &e3);
|
||||
|
||||
/* Operator equals */
|
||||
memset(&e2, 0, sizeof(e2));
|
||||
pe = call_func2(pexception_opequals, &e2, &e);
|
||||
ok(e2.vtable != NULL, "Null exception vtable for e2\n");
|
||||
ok(e2.name && e2.name != e.name && !strcmp(e2.name, "An exception name"), "Bad exception name for e2\n");
|
||||
ok(e2.do_free == 1, "do_free set to %d for e2\n", e2.do_free);
|
||||
ok(pe == &e2, "opequals didn't return e2\n");
|
||||
|
||||
/* what() */
|
||||
name = call_func1(pexception_what, &e2);
|
||||
ok(e2.name == name, "Bad exception name from e2::what()\n");
|
||||
|
||||
/* vtable ptr */
|
||||
ok(e2.vtable == pexception_vtable, "Bad vtable for e2\n");
|
||||
call_func1(pexception_dtor, &e2);
|
||||
|
||||
/* new() */
|
||||
pe = poperator_new(sizeof(exception));
|
||||
ok(pe != NULL, "new() failed\n");
|
||||
if (pe)
|
||||
{
|
||||
call_func2(pexception_ctor, pe, &e_name);
|
||||
/* scalar dtor */
|
||||
call_func2(pexception_scalar_dtor, pe, 0); /* Shouldn't delete pe */
|
||||
pe->name = NULL;
|
||||
pe->do_free = 0;
|
||||
call_func2(pexception_scalar_dtor, pe, 1); /* Should delete pe */
|
||||
}
|
||||
|
||||
pe = poperator_new(sizeof(exception));
|
||||
ok(pe != NULL, "new() failed\n");
|
||||
if (pe)
|
||||
{
|
||||
/* vector dtor, single element */
|
||||
call_func2(pexception_ctor, pe, &e_name);
|
||||
call_func2(pexception_vector_dtor, pe, 1); /* Should delete pe as single element*/
|
||||
}
|
||||
|
||||
pe = poperator_new(sizeof(exception) * 4 + sizeof(int));
|
||||
ok(pe != NULL, "new() failed\n");
|
||||
if (pe)
|
||||
{
|
||||
/* vector dtor, multiple elements */
|
||||
char name[] = "a constant";
|
||||
*((int*)pe) = 3;
|
||||
pe = (exception*)((int*)pe + 1);
|
||||
call_func2(pexception_ctor, &pe[0], &e_name);
|
||||
call_func2(pexception_ctor, &pe[1], &e_name);
|
||||
call_func2(pexception_ctor, &pe[2], &e_name);
|
||||
pe[3].name = name;
|
||||
pe[3].do_free = 1; /* Crash if we try to free this */
|
||||
call_func2(pexception_vector_dtor, pe, 3); /* Should delete all 3 and then pe block */
|
||||
}
|
||||
|
||||
/* test our exported vtable is kosher */
|
||||
pe = (void*)pexception_vtable; /* Use the exception struct to get vtable ptrs */
|
||||
pexception_vector_dtor = (void*)pe->vtable;
|
||||
pexception_what = (void*)pe->name;
|
||||
|
||||
name = call_func1(pexception_what, &e);
|
||||
ok(e.name == name, "Bad exception name from vtable e::what()\n");
|
||||
|
||||
if (p__RTtypeid && !bAncientVersion)
|
||||
{
|
||||
/* Check the rtti */
|
||||
type_info *ti = p__RTtypeid(&e);
|
||||
ok (ti && ti->mangled &&
|
||||
!strcmp(ti->mangled, ".?AVexception@@"), "bad rtti for e\n");
|
||||
|
||||
if (ti)
|
||||
{
|
||||
/* Check the returned type_info has rtti too */
|
||||
type_info *ti2 = p__RTtypeid(ti);
|
||||
ok (ti2 != NULL && !strcmp(ti2->mangled, ".?AVtype_info@@"), "bad rtti for e's type_info\n");
|
||||
}
|
||||
}
|
||||
|
||||
call_func2(pexception_vector_dtor, &e, 0); /* Should delete e.name, but not e */
|
||||
}
|
||||
|
||||
/* This test is basically a cut 'n' paste of the exception test. but it verifies that
|
||||
* bad_typeid works the exact same way... */
|
||||
static void test_bad_typeid(void)
|
||||
{
|
||||
static const char* e_name = "A bad_typeid name";
|
||||
char* name;
|
||||
exception e, e2, e3, *pe;
|
||||
|
||||
if (!poperator_new || !poperator_delete ||
|
||||
!pbad_typeid_ctor || !pbad_typeid_copy_ctor ||
|
||||
!pbad_typeid_dtor || !pbad_typeid_opequals || !pbad_typeid_what ||
|
||||
!pbad_typeid_vtable || !pbad_typeid_vector_dtor || !pbad_typeid_scalar_dtor)
|
||||
return;
|
||||
|
||||
/* 'const char*' ctor */
|
||||
memset(&e, 0, sizeof(e));
|
||||
call_func2(pbad_typeid_ctor, &e, e_name);
|
||||
ok(e.vtable != NULL, "Null bad_typeid vtable for e\n");
|
||||
ok(e.name && e.name != e_name && !strcmp(e.name, "A bad_typeid name"), "Bad name '%s' for e\n", e.name);
|
||||
ok(e.do_free == 1, "do_free set to %d for e\n", e.do_free);
|
||||
|
||||
/* Copy ctor */
|
||||
memset(&e2, 0, sizeof(e2));
|
||||
call_func2(pbad_typeid_copy_ctor, &e2, &e);
|
||||
ok(e2.vtable != NULL, "Null bad_typeid vtable for e2\n");
|
||||
ok(e2.name && e2.name != e.name && !strcmp(e2.name, "A bad_typeid name"), "Bad name '%s' for e2\n", e2.name);
|
||||
ok(e2.do_free == 1, "do_free set to %d for e2\n", e2.do_free);
|
||||
|
||||
/* Ctor closure */
|
||||
if (pbad_typeid_ctor_closure)
|
||||
{
|
||||
memset(&e3, 1, sizeof(e3));
|
||||
call_func1(pbad_typeid_ctor_closure, &e3);
|
||||
ok(e3.vtable != NULL, "Null bad_typeid vtable for e3\n");
|
||||
ok(e3.name && !strcmp(e3.name, "bad typeid"), "Bad bad_typeid name for e3\n");
|
||||
ok(e3.do_free == 1, "do_free set to %d for e3\n", e3.do_free);
|
||||
ok(e.vtable == e3.vtable, "bad_typeid closure vtables differ!\n");
|
||||
call_func1(pbad_typeid_dtor, &e3);
|
||||
}
|
||||
ok(e.vtable == e2.vtable, "bad_typeid vtables differ!\n");
|
||||
|
||||
/* Test calling the dtors */
|
||||
call_func1(pbad_typeid_dtor, &e2);
|
||||
|
||||
/* Operator equals */
|
||||
memset(&e2, 1, sizeof(e2));
|
||||
pe = call_func2(pbad_typeid_opequals, &e2, &e);
|
||||
ok(e2.vtable != NULL, "Null bad_typeid vtable for e2\n");
|
||||
ok(e2.name && e2.name != e.name && !strcmp(e2.name, "A bad_typeid name"), "Bad bad_typeid name for e2\n");
|
||||
ok(e2.do_free == 1, "do_free set to %d for e2\n", e2.do_free);
|
||||
ok(pe == &e2, "opequals didn't return e2\n");
|
||||
|
||||
/* what() */
|
||||
name = call_func1(pbad_typeid_what, &e2);
|
||||
ok(e2.name == name, "Bad bad_typeid name from e2::what()\n");
|
||||
|
||||
/* vtable ptr */
|
||||
ok(e2.vtable == pexception_vtable, "Bad vtable for e2\n");
|
||||
call_func1(pbad_typeid_dtor, &e2);
|
||||
|
||||
/* new() */
|
||||
pe = poperator_new(sizeof(exception));
|
||||
ok(pe != NULL, "new() failed\n");
|
||||
if (pe)
|
||||
{
|
||||
call_func2(pbad_typeid_ctor, pe, e_name);
|
||||
/* scalar dtor */
|
||||
call_func2(pbad_typeid_scalar_dtor, pe, 0); /* Shouldn't delete pe */
|
||||
pe->name = NULL;
|
||||
pe->do_free = 0;
|
||||
call_func2(pbad_typeid_scalar_dtor, pe, 1); /* Should delete pe */
|
||||
}
|
||||
|
||||
pe = poperator_new(sizeof(exception));
|
||||
ok(pe != NULL, "new() failed\n");
|
||||
if (pe)
|
||||
{
|
||||
/* vector dtor, single element */
|
||||
call_func2(pbad_typeid_ctor, pe, e_name);
|
||||
call_func2(pbad_typeid_vector_dtor, pe, 1); /* Should delete pe as single element*/
|
||||
}
|
||||
|
||||
pe = poperator_new(sizeof(exception) * 4 + sizeof(int));
|
||||
ok(pe != NULL, "new() failed\n");
|
||||
if (pe)
|
||||
{
|
||||
/* vector dtor, multiple elements */
|
||||
*((int*)pe) = 3;
|
||||
pe = (exception*)((int*)pe + 1);
|
||||
call_func2(pbad_typeid_ctor, &pe[0], e_name);
|
||||
call_func2(pbad_typeid_ctor, &pe[1], e_name);
|
||||
call_func2(pbad_typeid_ctor, &pe[2], e_name);
|
||||
pe[3].name = 0;
|
||||
pe[3].do_free = 1; /* Crash if we try to free this element */
|
||||
call_func2(pbad_typeid_vector_dtor, pe, 3); /* Should delete all 3 and then pe block */
|
||||
}
|
||||
|
||||
/* test our exported vtable is kosher */
|
||||
pe = (void*)pbad_typeid_vtable; /* Use the exception struct to get vtable ptrs */
|
||||
pbad_typeid_vector_dtor = (void*)pe->vtable;
|
||||
pbad_typeid_what = (void*)pe->name;
|
||||
|
||||
name = call_func1(pbad_typeid_what, &e);
|
||||
ok(e.name == name, "Bad bad_typeid name from vtable e::what()\n");
|
||||
|
||||
if (p__RTtypeid && !bAncientVersion)
|
||||
{
|
||||
/* Check the rtti */
|
||||
type_info *ti = p__RTtypeid(&e);
|
||||
ok (ti != NULL && !strcmp(ti->mangled, ".?AVbad_typeid@@"), "bad rtti for e (%s)\n",
|
||||
!ti ? "null" : ti->mangled);
|
||||
}
|
||||
|
||||
call_func2(pbad_typeid_vector_dtor, &e, 0); /* Should delete e.name, but not e */
|
||||
}
|
||||
|
||||
|
||||
/* Ditto for this test... */
|
||||
static void test_bad_cast(void)
|
||||
{
|
||||
static const char* e_name = "A bad_cast name";
|
||||
char* name;
|
||||
exception e, e2, e3, *pe;
|
||||
|
||||
if (!poperator_new || !poperator_delete ||
|
||||
!pbad_cast_ctor || !pbad_cast_copy_ctor ||
|
||||
!pbad_cast_dtor || !pbad_cast_opequals || !pbad_cast_what ||
|
||||
!pbad_cast_vtable || !pbad_cast_vector_dtor || !pbad_cast_scalar_dtor)
|
||||
return;
|
||||
|
||||
if (pbad_cast_ctor2)
|
||||
{
|
||||
/* 'const char*' ctor */
|
||||
memset(&e, 0, sizeof(e));
|
||||
call_func2(pbad_cast_ctor2, &e, e_name);
|
||||
ok(e.vtable != NULL, "Null bad_cast vtable for e\n");
|
||||
ok(e.name && e.name != e_name && !strcmp(e.name, "A bad_cast name"), "Bad name '%s' for e\n", e.name);
|
||||
ok(e.do_free == 1, "do_free set to %d for e\n", e.do_free);
|
||||
call_func1(pbad_cast_dtor, &e);
|
||||
}
|
||||
|
||||
/* 'const char*&' ctor */
|
||||
memset(&e, 0, sizeof(e));
|
||||
call_func2(pbad_cast_ctor, &e, &e_name);
|
||||
ok(e.vtable != NULL, "Null bad_cast vtable for e\n");
|
||||
ok(e.name && e.name != e_name && !strcmp(e.name, "A bad_cast name"), "Bad name '%s' for e\n", e.name);
|
||||
ok(e.do_free == 1, "do_free set to %d for e\n", e.do_free);
|
||||
|
||||
/* Copy ctor */
|
||||
memset(&e2, 0, sizeof(e2));
|
||||
call_func2(pbad_cast_copy_ctor, &e2, &e);
|
||||
ok(e2.vtable != NULL, "Null bad_cast vtable for e2\n");
|
||||
ok(e2.name && e2.name != e.name && !strcmp(e2.name, "A bad_cast name"), "Bad name '%s' for e2\n", e2.name);
|
||||
ok(e2.do_free == 1, "do_free set to %d for e2\n", e2.do_free);
|
||||
|
||||
/* Ctor closure */
|
||||
if (pbad_cast_ctor_closure)
|
||||
{
|
||||
memset(&e3, 1, sizeof(e3));
|
||||
call_func1(pbad_cast_ctor_closure, &e3);
|
||||
ok(e3.vtable != NULL, "Null bad_cast vtable for e3\n");
|
||||
ok(e3.name && !strcmp(e3.name, "bad cast"), "Bad bad_cast name for e3\n");
|
||||
ok(e3.do_free == 1, "do_free set to %d for e3\n", e3.do_free);
|
||||
ok(e.vtable == e3.vtable, "bad_cast closure vtables differ!\n");
|
||||
call_func1(pbad_cast_dtor, &e3);
|
||||
}
|
||||
ok(e.vtable == e2.vtable, "bad_cast vtables differ!\n");
|
||||
|
||||
/* Test calling the dtors */
|
||||
call_func1(pbad_cast_dtor, &e2);
|
||||
|
||||
/* Operator equals */
|
||||
memset(&e2, 1, sizeof(e2));
|
||||
pe = call_func2(pbad_cast_opequals, &e2, &e);
|
||||
ok(e2.vtable != NULL, "Null bad_cast vtable for e2\n");
|
||||
ok(e2.name && e2.name != e.name && !strcmp(e2.name, "A bad_cast name"), "Bad bad_cast name for e2\n");
|
||||
ok(e2.do_free == 1, "do_free set to %d for e2\n", e2.do_free);
|
||||
ok(pe == &e2, "opequals didn't return e2\n");
|
||||
|
||||
/* what() */
|
||||
name = call_func1(pbad_cast_what, &e2);
|
||||
ok(e2.name == name, "Bad bad_cast name from e2::what()\n");
|
||||
|
||||
/* vtable ptr */
|
||||
ok(e2.vtable == pexception_vtable, "Bad vtable for e2\n");
|
||||
call_func1(pbad_cast_dtor, &e2);
|
||||
|
||||
/* new() */
|
||||
pe = poperator_new(sizeof(exception));
|
||||
ok(pe != NULL, "new() failed\n");
|
||||
if (pe)
|
||||
{
|
||||
call_func2(pbad_cast_ctor, pe, &e_name);
|
||||
/* scalar dtor */
|
||||
call_func2(pbad_cast_scalar_dtor, pe, 0); /* Shouldn't delete pe */
|
||||
pe->name = NULL;
|
||||
pe->do_free = 0;
|
||||
call_func2(pbad_cast_scalar_dtor, pe, 1); /* Should delete pe */
|
||||
}
|
||||
|
||||
pe = poperator_new(sizeof(exception));
|
||||
ok(pe != NULL, "new() failed\n");
|
||||
if (pe)
|
||||
{
|
||||
/* vector dtor, single element */
|
||||
call_func2(pbad_cast_ctor, pe, &e_name);
|
||||
call_func2(pbad_cast_vector_dtor, pe, 1); /* Should delete pe as single element*/
|
||||
}
|
||||
|
||||
pe = poperator_new(sizeof(exception) * 4 + sizeof(int));
|
||||
ok(pe != NULL, "new() failed\n");
|
||||
if (pe)
|
||||
{
|
||||
/* vector dtor, multiple elements */
|
||||
*((int*)pe) = 3;
|
||||
pe = (exception*)((int*)pe + 1);
|
||||
call_func2(pbad_cast_ctor, &pe[0], &e_name);
|
||||
call_func2(pbad_cast_ctor, &pe[1], &e_name);
|
||||
call_func2(pbad_cast_ctor, &pe[2], &e_name);
|
||||
pe[3].name = 0;
|
||||
pe[3].do_free = 1; /* Crash if we try to free this element */
|
||||
call_func2(pbad_cast_vector_dtor, pe, 3); /* Should delete all 3 and then pe block */
|
||||
}
|
||||
|
||||
/* test our exported vtable is kosher */
|
||||
pe = (void*)pbad_cast_vtable; /* Use the exception struct to get vtable ptrs */
|
||||
pbad_cast_vector_dtor = (void*)pe->vtable;
|
||||
pbad_cast_what = (void*)pe->name;
|
||||
|
||||
name = call_func1(pbad_cast_what, &e);
|
||||
ok(e.name == name, "Bad bad_cast name from vtable e::what()\n");
|
||||
|
||||
if (p__RTtypeid && !bAncientVersion)
|
||||
{
|
||||
/* Check the rtti */
|
||||
type_info *ti = p__RTtypeid(&e);
|
||||
ok (ti != NULL && !strcmp(ti->mangled, ".?AVbad_cast@@"), "bad rtti for e\n");
|
||||
}
|
||||
call_func2(pbad_cast_vector_dtor, &e, 0); /* Should delete e.name, but not e */
|
||||
}
|
||||
|
||||
/* ... and this one */
|
||||
static void test___non_rtti_object(void)
|
||||
{
|
||||
static const char* e_name = "A __non_rtti_object name";
|
||||
char* name;
|
||||
exception e, e2, *pe;
|
||||
|
||||
if (!poperator_new || !poperator_delete ||
|
||||
!p__non_rtti_object_ctor || !p__non_rtti_object_copy_ctor ||
|
||||
!p__non_rtti_object_dtor || !p__non_rtti_object_opequals || !p__non_rtti_object_what ||
|
||||
!p__non_rtti_object_vtable || !p__non_rtti_object_vector_dtor || !p__non_rtti_object_scalar_dtor)
|
||||
return;
|
||||
|
||||
/* 'const char*' ctor */
|
||||
memset(&e, 0, sizeof(e));
|
||||
call_func2(p__non_rtti_object_ctor, &e, e_name);
|
||||
ok(e.vtable != NULL, "Null __non_rtti_object vtable for e\n");
|
||||
ok(e.name && e.name != e_name && !strcmp(e.name, "A __non_rtti_object name"), "Bad name '%s' for e\n", e.name);
|
||||
ok(e.do_free == 1, "do_free set to %d for e\n", e.do_free);
|
||||
|
||||
/* Copy ctor */
|
||||
memset(&e2, 0, sizeof(e2));
|
||||
call_func2(p__non_rtti_object_copy_ctor, &e2, &e);
|
||||
ok(e2.vtable != NULL, "Null __non_rtti_object vtable for e2\n");
|
||||
ok(e2.name && e2.name != e.name && !strcmp(e2.name, "A __non_rtti_object name"), "Bad name '%s' for e2\n", e2.name);
|
||||
ok(e2.do_free == 1, "do_free set to %d for e2\n", e2.do_free);
|
||||
ok(e.vtable == e2.vtable, "__non_rtti_object vtables differ!\n");
|
||||
|
||||
/* Test calling the dtors */
|
||||
call_func1(p__non_rtti_object_dtor, &e2);
|
||||
|
||||
/* Operator equals */
|
||||
memset(&e2, 1, sizeof(e2));
|
||||
pe = call_func2(p__non_rtti_object_opequals, &e2, &e);
|
||||
ok(e2.vtable != NULL, "Null __non_rtti_object vtable for e2\n");
|
||||
ok(e2.name && e2.name != e.name && !strcmp(e2.name, "A __non_rtti_object name"), "Bad __non_rtti_object name for e2\n");
|
||||
ok(e2.do_free == 1, "do_free set to %d for e2\n", e2.do_free);
|
||||
ok(pe == &e2, "opequals didn't return e2\n");
|
||||
|
||||
/* what() */
|
||||
name = call_func1(p__non_rtti_object_what, &e2);
|
||||
ok(e2.name == name, "Bad __non_rtti_object name from e2::what()\n");
|
||||
|
||||
/* vtable ptr */
|
||||
ok(e2.vtable == pexception_vtable, "Bad vtable for e2\n");
|
||||
call_func1(p__non_rtti_object_dtor, &e2);
|
||||
|
||||
/* new() */
|
||||
pe = poperator_new(sizeof(exception));
|
||||
ok(pe != NULL, "new() failed\n");
|
||||
if (pe)
|
||||
{
|
||||
call_func2(p__non_rtti_object_ctor, pe, e_name);
|
||||
/* scalar dtor */
|
||||
call_func2(p__non_rtti_object_scalar_dtor, pe, 0); /* Shouldn't delete pe */
|
||||
pe->name = NULL;
|
||||
pe->do_free = 0;
|
||||
call_func2(p__non_rtti_object_scalar_dtor, pe, 1); /* Should delete pe */
|
||||
}
|
||||
|
||||
pe = poperator_new(sizeof(exception));
|
||||
ok(pe != NULL, "new() failed\n");
|
||||
if (pe)
|
||||
{
|
||||
/* vector dtor, single element */
|
||||
call_func2(p__non_rtti_object_ctor, pe, e_name);
|
||||
call_func2(p__non_rtti_object_vector_dtor, pe, 1); /* Should delete pe as single element*/
|
||||
}
|
||||
|
||||
pe = poperator_new(sizeof(exception) * 4 + sizeof(int));
|
||||
ok(pe != NULL, "new() failed\n");
|
||||
if (pe)
|
||||
{
|
||||
/* vector dtor, multiple elements */
|
||||
*((int*)pe) = 3;
|
||||
pe = (exception*)((int*)pe + 1);
|
||||
call_func2(p__non_rtti_object_ctor, &pe[0], e_name);
|
||||
call_func2(p__non_rtti_object_ctor, &pe[1], e_name);
|
||||
call_func2(p__non_rtti_object_ctor, &pe[2], e_name);
|
||||
pe[3].name = 0;
|
||||
pe[3].do_free = 1; /* Crash if we try to free this element */
|
||||
call_func2(p__non_rtti_object_vector_dtor, pe, 3); /* Should delete all 3 and then pe block */
|
||||
}
|
||||
|
||||
/* test our exported vtable is kosher */
|
||||
pe = (void*)p__non_rtti_object_vtable; /* Use the exception struct to get vtable ptrs */
|
||||
p__non_rtti_object_vector_dtor = (void*)pe->vtable;
|
||||
p__non_rtti_object_what = (void*)pe->name;
|
||||
|
||||
name = call_func1(p__non_rtti_object_what, &e);
|
||||
ok(e.name == name, "Bad __non_rtti_object name from vtable e::what()\n");
|
||||
|
||||
if (p__RTtypeid && !bAncientVersion)
|
||||
{
|
||||
/* Check the rtti */
|
||||
type_info *ti = p__RTtypeid(&e);
|
||||
ok (ti != NULL && !strcmp(ti->mangled, ".?AV__non_rtti_object@@"), "bad rtti for e\n");
|
||||
}
|
||||
call_func2(p__non_rtti_object_vector_dtor, &e, 0); /* Should delete e.name, but not e */
|
||||
}
|
||||
|
||||
|
||||
static void test_type_info(void)
|
||||
{
|
||||
static type_info t1 = { NULL, NULL,{'.','?','A','V','t','e','s','t','1','@','@',0,0,0,0,0 } };
|
||||
static type_info t1_1 = { NULL, NULL,{'?','?','A','V','t','e','s','t','1','@','@',0,0,0,0,0 } };
|
||||
static type_info t2 = { NULL, NULL, {'.','?','A','V','t','e','s','t','2','@','@',0,0,0,0,0 } };
|
||||
char* name;
|
||||
int res;
|
||||
|
||||
if (!pmalloc || !pfree || !ptype_info_dtor || !ptype_info_raw_name ||
|
||||
!ptype_info_name || !ptype_info_before ||
|
||||
!ptype_info_opequals_equals || !ptype_info_opnot_equals)
|
||||
return;
|
||||
|
||||
/* Test calling the dtors */
|
||||
call_func1(ptype_info_dtor, &t1); /* No effect, since name is NULL */
|
||||
t1.name = pmalloc(64);
|
||||
strcpy(t1.name, "foo");
|
||||
call_func1(ptype_info_dtor, &t1); /* Frees t1.name using 'free' */
|
||||
|
||||
/* raw_name */
|
||||
t1.name = NULL;
|
||||
name = call_func1(ptype_info_raw_name, &t1);
|
||||
|
||||
/* FIXME: This fails on native; it shouldn't though - native bug?
|
||||
* ok(name && !strcmp(name, t1.mangled), "bad raw_name '%s' for t1 (expected '%s')\n", name, t1.mangled);
|
||||
*/
|
||||
ok(t1.name == NULL, "raw_name() set name for t1\n");
|
||||
|
||||
/* name */
|
||||
t1.name = NULL;
|
||||
name = call_func1(ptype_info_name, &t1);
|
||||
ok(name && t1.name && !strcmp(name, t1.name), "bad name '%s' for t1\n", name);
|
||||
|
||||
ok(t1.name && !strcmp(t1.name, "class test1"), "demangled to '%s' for t1\n", t1.name);
|
||||
call_func1(ptype_info_dtor, &t1);
|
||||
|
||||
/* before */
|
||||
t1.name = NULL;
|
||||
res = (int)call_func2(ptype_info_before, &t1, &t1);
|
||||
ok(res == 0, "expected 0, got %d\n", res);
|
||||
res = (int)call_func2(ptype_info_before, &t2, &t1);
|
||||
ok(res == 0, "expected 0, got %d\n", res);
|
||||
res = (int)call_func2(ptype_info_before, &t1, &t2);
|
||||
ok(res == 1, "expected 1, got %d\n", res);
|
||||
/* Doesn't check first char */
|
||||
res = (int)call_func2(ptype_info_before, &t1, &t1_1);
|
||||
ok(res == 0, "expected 0, got %d\n", res);
|
||||
|
||||
/* opequals_equals */
|
||||
t1.name = NULL;
|
||||
res = (int)call_func2(ptype_info_opequals_equals, &t1, &t1);
|
||||
ok(res == 1, "expected 1, got %d\n", res);
|
||||
res = (int)call_func2(ptype_info_opequals_equals, &t1, &t2);
|
||||
ok(res == 0, "expected 0, got %d\n", res);
|
||||
res = (int)call_func2(ptype_info_opequals_equals, &t2, &t1);
|
||||
ok(res == 0, "expected 0, got %d\n", res);
|
||||
|
||||
/* opnot_equals */
|
||||
t1.name = NULL;
|
||||
res = (int)call_func2(ptype_info_opnot_equals, &t1, &t1);
|
||||
ok(res == 0, "expected 0, got %d\n", res);
|
||||
res = (int)call_func2(ptype_info_opnot_equals, &t1, &t2);
|
||||
ok(res == 1, "expected 1, got %d\n", res);
|
||||
res = (int)call_func2(ptype_info_opnot_equals, &t2, &t1);
|
||||
ok(res == 1, "expected 1, got %d\n", res);
|
||||
}
|
||||
|
||||
/* Test RTTI functions */
|
||||
static void test_rtti(void)
|
||||
{
|
||||
static const char* e_name = "name";
|
||||
type_info *ti,*bti;
|
||||
exception e,b;
|
||||
void *casted;
|
||||
|
||||
if (bAncientVersion ||
|
||||
!p__RTCastToVoid || !p__RTtypeid || !pexception_ctor || !pbad_typeid_ctor || !p__RTDynamicCast)
|
||||
return;
|
||||
|
||||
call_func2(pexception_ctor, &e, &e_name);
|
||||
call_func2(pbad_typeid_ctor, &b, e_name);
|
||||
|
||||
/* dynamic_cast to void* */
|
||||
casted = p__RTCastToVoid(&e);
|
||||
ok (casted == (void*)&e, "failed cast to void\n");
|
||||
|
||||
/* dynamic_cast up */
|
||||
ti = p__RTtypeid(&e);
|
||||
bti = p__RTtypeid(&b);
|
||||
|
||||
casted = p__RTDynamicCast(&b, 0, NULL, ti, 0);
|
||||
ok (casted == (void*)&b, "failed cast from bad_cast to exception\n");
|
||||
|
||||
/* dynamic_cast down */
|
||||
casted = p__RTDynamicCast(&e, 0, NULL, bti, 0);
|
||||
ok (casted == NULL, "Cast succeeded\n");
|
||||
}
|
||||
|
||||
START_TEST(cpp)
|
||||
{
|
||||
InitFunctionPtrs();
|
||||
|
||||
test_exception();
|
||||
test_bad_typeid();
|
||||
test_bad_cast();
|
||||
test___non_rtti_object();
|
||||
test_type_info();
|
||||
test_rtti();
|
||||
|
||||
if (hMsvcrt)
|
||||
FreeLibrary(hMsvcrt);
|
||||
}
|
||||
#endif /* __i386__ */
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* Unit tests for C library environment routines
|
||||
*
|
||||
* Copyright 2004 Mike Hearn <mh@codeweavers.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "wine/test.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
START_TEST(environ)
|
||||
{
|
||||
#ifndef __REACTOS__
|
||||
ok( _putenv("cat=") == 0, "_putenv failed on deletion of non-existent environment variable\n" );
|
||||
#endif
|
||||
ok( _putenv("cat=dog") == 0, "failed setting cat=dog\n" );
|
||||
ok( strcmp(getenv("cat"), "dog") == 0, "getenv did not return 'dog'\n" );
|
||||
ok( _putenv("cat=") == 0, "failed deleting cat\n" );
|
||||
|
||||
ok( _putenv("=") == -1, "should not accept '=' as input\n" );
|
||||
#ifndef __REACTOS__
|
||||
ok( _putenv("=dog") == -1, "should not accept '=dog' as input\n" );
|
||||
#endif
|
||||
ok( getenv("nonexistent") == NULL, "getenv should fail with nonexistent var name\n" );
|
||||
}
|
|
@ -1,331 +0,0 @@
|
|||
/*
|
||||
* Unit test suite for file functions
|
||||
*
|
||||
* Copyright 2002 Bill Currie
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "wine/test.h"
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <io.h>
|
||||
#include <windef.h>
|
||||
#include <winbase.h>
|
||||
#include <winnls.h>
|
||||
#include <process.h>
|
||||
#include <errno.h>
|
||||
|
||||
static void test_fdopen( void )
|
||||
{
|
||||
static const char buffer[] = {0,1,2,3,4,5,6,7,8,9};
|
||||
char ibuf[10];
|
||||
int fd;
|
||||
FILE *file;
|
||||
|
||||
fd = open ("fdopen.tst", O_WRONLY | O_CREAT | O_BINARY, _S_IREAD |_S_IWRITE);
|
||||
write (fd, buffer, sizeof (buffer));
|
||||
close (fd);
|
||||
|
||||
fd = open ("fdopen.tst", O_RDONLY | O_BINARY);
|
||||
lseek (fd, 5, SEEK_SET);
|
||||
file = fdopen (fd, "rb");
|
||||
ok (fread (ibuf, 1, sizeof (buffer), file) == 5, "read wrong byte count\n");
|
||||
ok (memcmp (ibuf, buffer + 5, 5) == 0, "read wrong bytes\n");
|
||||
fclose (file);
|
||||
unlink ("fdopen.tst");
|
||||
}
|
||||
|
||||
static void test_fileops( void )
|
||||
{
|
||||
static const char outbuffer[] = "0,1,2,3,4,5,6,7,8,9";
|
||||
char buffer[256];
|
||||
WCHAR wbuffer[256];
|
||||
int fd;
|
||||
FILE *file;
|
||||
|
||||
fd = open ("fdopen.tst", O_WRONLY | O_CREAT | O_BINARY, _S_IREAD |_S_IWRITE);
|
||||
write (fd, outbuffer, sizeof (outbuffer));
|
||||
close (fd);
|
||||
|
||||
fd = open ("fdopen.tst", O_RDONLY | O_BINARY);
|
||||
file = fdopen (fd, "rb");
|
||||
ok(strlen(outbuffer) == (sizeof(outbuffer)-1),"strlen/sizeof error\n");
|
||||
ok(fgets(buffer,sizeof(buffer),file) !=0,"fgets failed unexpected\n");
|
||||
ok(fgets(buffer,sizeof(buffer),file) ==0,"fgets didn't signal EOF\n");
|
||||
ok(feof(file) !=0,"feof doesn't signal EOF\n");
|
||||
rewind(file);
|
||||
ok(fgets(buffer,strlen(outbuffer),file) !=0,"fgets failed unexpected\n");
|
||||
ok(lstrlenA(buffer) == strlen(outbuffer) -1,"fgets didn't read right size\n");
|
||||
ok(fgets(buffer,sizeof(outbuffer),file) !=0,"fgets failed unexpected\n");
|
||||
ok(strlen(buffer) == 1,"fgets dropped chars\n");
|
||||
ok(buffer[0] == outbuffer[strlen(outbuffer)-1],"fgets exchanged chars\n");
|
||||
fclose (file);
|
||||
fd = open ("fdopen.tst", O_RDONLY | O_TEXT);
|
||||
file = fdopen (fd, "rt"); /* open in TEXT mode */
|
||||
ok(fgetws(wbuffer,sizeof(wbuffer),file) !=0,"fgetws failed unexpected\n");
|
||||
ok(fgetws(wbuffer,sizeof(wbuffer),file) ==0,"fgetws didn't signal EOF\n");
|
||||
ok(feof(file) !=0,"feof doesn't signal EOF\n");
|
||||
rewind(file);
|
||||
ok(fgetws(wbuffer,strlen(outbuffer),file) !=0,"fgetws failed unexpected\n");
|
||||
ok(lstrlenW(wbuffer) == (strlen(outbuffer) -1),"fgetws didn't read right size\n");
|
||||
ok(fgetws(wbuffer,sizeof(outbuffer),file) !=0,"fgets failed unexpected\n");
|
||||
ok(lstrlenW(wbuffer) == 1,"fgets dropped chars\n");
|
||||
fclose (file);
|
||||
unlink ("fdopen.tst");
|
||||
}
|
||||
|
||||
static WCHAR* AtoW( char* p )
|
||||
{
|
||||
WCHAR* buffer;
|
||||
DWORD len = MultiByteToWideChar( CP_ACP, 0, p, -1, NULL, 0 );
|
||||
buffer = malloc( len * sizeof(WCHAR) );
|
||||
MultiByteToWideChar( CP_ACP, 0, p, -1, buffer, len );
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static void test_fgetwc( void )
|
||||
{
|
||||
#define LLEN 512
|
||||
|
||||
char* tempf;
|
||||
FILE *tempfh;
|
||||
static const char mytext[]= "This is test_fgetwc\n";
|
||||
WCHAR wtextW[LLEN+1];
|
||||
WCHAR *mytextW = NULL, *aptr, *wptr;
|
||||
BOOL diff_found = FALSE;
|
||||
unsigned int i;
|
||||
|
||||
tempf=_tempnam(".","wne");
|
||||
tempfh = fopen(tempf,"wt"); /* open in TEXT mode */
|
||||
fputs(mytext,tempfh);
|
||||
fclose(tempfh);
|
||||
tempfh = fopen(tempf,"rt");
|
||||
fgetws(wtextW,LLEN,tempfh);
|
||||
mytextW = AtoW ((char*)mytext);
|
||||
aptr = mytextW;
|
||||
wptr = wtextW;
|
||||
|
||||
for (i=0; i<strlen(mytext); i++, aptr++, wptr++)
|
||||
{
|
||||
diff_found |= (*aptr != *wptr);
|
||||
}
|
||||
ok(!(diff_found), "fgetwc difference found in TEXT mode\n");
|
||||
if(mytextW) free (mytextW);
|
||||
fclose(tempfh);
|
||||
unlink(tempf);
|
||||
}
|
||||
|
||||
static void test_file_put_get( void )
|
||||
{
|
||||
char* tempf;
|
||||
FILE *tempfh;
|
||||
static const char mytext[]= "This is a test_file_put_get\n";
|
||||
static const char dostext[]= "This is a test_file_put_get\r\n";
|
||||
char btext[LLEN];
|
||||
WCHAR wtextW[LLEN+1];
|
||||
WCHAR *mytextW = NULL, *aptr, *wptr;
|
||||
BOOL diff_found = FALSE;
|
||||
unsigned int i;
|
||||
|
||||
tempf=_tempnam(".","wne");
|
||||
tempfh = fopen(tempf,"wt"); /* open in TEXT mode */
|
||||
fputs(mytext,tempfh);
|
||||
fclose(tempfh);
|
||||
tempfh = fopen(tempf,"rb"); /* open in TEXT mode */
|
||||
fgets(btext,LLEN,tempfh);
|
||||
ok( strlen(mytext) + 1 == strlen(btext),"TEXT/BINARY mode not handled for write\n");
|
||||
ok( btext[strlen(mytext)-1] == '\r', "CR not written\n");
|
||||
fclose(tempfh);
|
||||
tempfh = fopen(tempf,"wb"); /* open in BINARY mode */
|
||||
fputs(dostext,tempfh);
|
||||
fclose(tempfh);
|
||||
tempfh = fopen(tempf,"rt"); /* open in TEXT mode */
|
||||
fgets(btext,LLEN,tempfh);
|
||||
ok(strcmp(btext, mytext) == 0,"_O_TEXT read doesn't strip CR\n");
|
||||
fclose(tempfh);
|
||||
tempfh = fopen(tempf,"rb"); /* open in TEXT mode */
|
||||
fgets(btext,LLEN,tempfh);
|
||||
ok(strcmp(btext, dostext) == 0,"_O_BINARY read doesn't preserve CR\n");
|
||||
|
||||
fclose(tempfh);
|
||||
tempfh = fopen(tempf,"rt"); /* open in TEXT mode */
|
||||
fgetws(wtextW,LLEN,tempfh);
|
||||
mytextW = AtoW ((char*)mytext);
|
||||
aptr = mytextW;
|
||||
wptr = wtextW;
|
||||
|
||||
for (i=0; i<strlen(mytext); i++, aptr++, wptr++)
|
||||
{
|
||||
diff_found |= (*aptr != *wptr);
|
||||
}
|
||||
ok(!(diff_found), "fgetwc doesn't strip CR in TEXT mode\n");
|
||||
if(mytextW) free (mytextW);
|
||||
fclose(tempfh);
|
||||
unlink(tempf);
|
||||
}
|
||||
|
||||
static void test_file_write_read( void )
|
||||
{
|
||||
char* tempf;
|
||||
int tempfd;
|
||||
static const char mytext[]= "This is test_file_write_read\nsecond line\n";
|
||||
static const char dostext[]= "This is test_file_write_read\r\nsecond line\r\n";
|
||||
char btext[LLEN];
|
||||
|
||||
tempf=_tempnam(".","wne");
|
||||
ok((tempfd = _open(tempf,_O_CREAT|_O_TRUNC|_O_TEXT|_O_RDWR,
|
||||
_S_IREAD | _S_IWRITE)) != -1,
|
||||
"Can't open '%s': %d\n", tempf, errno); /* open in TEXT mode */
|
||||
ok(_write(tempfd,mytext,strlen(mytext)) == lstrlenA(mytext),
|
||||
"_write _O_TEXT bad return value\n");
|
||||
_close(tempfd);
|
||||
tempfd = _open(tempf,_O_RDONLY|_O_BINARY,0); /* open in BINARY mode */
|
||||
ok(_read(tempfd,btext,LLEN) == lstrlenA(dostext),
|
||||
"_read _O_BINARY got bad length\n");
|
||||
ok( memcmp(dostext,btext,strlen(dostext)) == 0,
|
||||
"problems with _O_TEXT _write / _O_BINARY _read\n");
|
||||
ok( btext[strlen(dostext)-2] == '\r', "CR not written or read\n");
|
||||
_close(tempfd);
|
||||
tempfd = _open(tempf,_O_RDONLY|_O_TEXT); /* open in TEXT mode */
|
||||
ok(_read(tempfd,btext,LLEN) == lstrlenA(mytext),
|
||||
"_read _O_TEXT got bad length\n");
|
||||
ok( memcmp(mytext,btext,strlen(mytext)) == 0,
|
||||
"problems with _O_TEXT _write / _read\n");
|
||||
_close(tempfd);
|
||||
ok(unlink(tempf) !=-1 ,"Can't unlink '%s': %d\n", tempf, errno);
|
||||
|
||||
tempf=_tempnam(".","wne");
|
||||
ok((tempfd = _open(tempf,_O_CREAT|_O_TRUNC|_O_BINARY|_O_RDWR,0)) != -1,
|
||||
"Can't open '%s': %d\n", tempf, errno); /* open in BINARY mode */
|
||||
ok(_write(tempfd,dostext,strlen(dostext)) == lstrlenA(dostext),
|
||||
"_write _O_BINARY bad return value\n");
|
||||
_close(tempfd);
|
||||
tempfd = _open(tempf,_O_RDONLY|_O_BINARY,0); /* open in BINARY mode */
|
||||
ok(_read(tempfd,btext,LLEN) == lstrlenA(dostext),
|
||||
"_read _O_BINARY got bad length\n");
|
||||
ok( memcmp(dostext,btext,strlen(dostext)) == 0,
|
||||
"problems with _O_BINARY _write / _read\n");
|
||||
ok( btext[strlen(dostext)-2] == '\r', "CR not written or read\n");
|
||||
_close(tempfd);
|
||||
tempfd = _open(tempf,_O_RDONLY|_O_TEXT); /* open in TEXT mode */
|
||||
ok(_read(tempfd,btext,LLEN) == lstrlenA(mytext),
|
||||
"_read _O_TEXT got bad length\n");
|
||||
ok( memcmp(mytext,btext,strlen(mytext)) == 0,
|
||||
"problems with _O_BINARY _write / _O_TEXT _read\n");
|
||||
_close(tempfd);
|
||||
|
||||
ok(_chmod (tempf, _S_IREAD | _S_IWRITE) == 0,
|
||||
"Can't chmod '%s' to read-write: %d\n", tempf, errno);
|
||||
ok(unlink(tempf) !=-1 ,"Can't unlink '%s': %d\n", tempf, errno);
|
||||
}
|
||||
|
||||
static void test_file_inherit_child(const char* fd_s)
|
||||
{
|
||||
int fd = atoi(fd_s);
|
||||
char buffer[32];
|
||||
|
||||
ok(write(fd, "Success", 8) == 8, "Couldn't write in child process on %d (%s)\n", fd, strerror(errno));
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
ok(read(fd, buffer, sizeof (buffer)) == 8, "Couldn't read back the data\n");
|
||||
ok(memcmp(buffer, "Success", 8) == 0, "Couldn't read back the data\n");
|
||||
}
|
||||
|
||||
static void test_file_inherit_child_no(const char* fd_s)
|
||||
{
|
||||
int fd = atoi(fd_s);
|
||||
|
||||
ok(write(fd, "Success", 8) == -1 && errno == EBADF,
|
||||
"Wrong write result in child process on %d (%s)\n", fd, strerror(errno));
|
||||
}
|
||||
|
||||
static void test_file_inherit( const char* selfname )
|
||||
{
|
||||
int fd;
|
||||
const char* arg_v[5];
|
||||
char buffer[16];
|
||||
|
||||
fd = open ("fdopen.tst", O_CREAT | O_RDWR | O_BINARY, _S_IREAD |_S_IWRITE);
|
||||
ok(fd != -1, "Couldn't create test file\n ");
|
||||
arg_v[0] = selfname;
|
||||
arg_v[1] = "tests/file.c";
|
||||
arg_v[2] = buffer; sprintf(buffer, "%d", fd);
|
||||
arg_v[3] = 0;
|
||||
_spawnvp(_P_WAIT, selfname, arg_v);
|
||||
ok(tell(fd) == 8, "bad position %lu expecting 8\n", tell(fd));
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
ok(read(fd, buffer, sizeof (buffer)) == 8 && memcmp(buffer, "Success", 8) == 0, "Couldn't read back the data\n");
|
||||
close (fd);
|
||||
ok(unlink("fdopen.tst") != 1, "Couldn't unlink\n");
|
||||
|
||||
fd = open ("fdopen.tst", O_CREAT | O_RDWR | O_BINARY | O_NOINHERIT, _S_IREAD |_S_IWRITE);
|
||||
ok(fd != -1, "Couldn't create test file\n ");
|
||||
arg_v[0] = selfname;
|
||||
arg_v[1] = "tests/file.c";
|
||||
arg_v[2] = buffer; sprintf(buffer, "%d", fd);
|
||||
arg_v[3] = buffer;
|
||||
arg_v[4] = 0;
|
||||
_spawnvp(_P_WAIT, selfname, arg_v);
|
||||
ok(tell(fd) == 0, "bad position %lu expecting 0\n", tell(fd));
|
||||
ok(read(fd, buffer, sizeof (buffer)) == 0, "Found unexpected data (%s)\n", buffer);
|
||||
close (fd);
|
||||
ok(unlink("fdopen.tst") != 1, "Couldn't unlink\n");
|
||||
}
|
||||
|
||||
static void test_tmpnam( void )
|
||||
{
|
||||
char name[MAX_PATH] = "abc";
|
||||
char *res;
|
||||
|
||||
res = tmpnam(NULL);
|
||||
ok(res != NULL, "tmpnam returned NULL\n");
|
||||
ok(res[0] == '\\', "first character is not a backslash\n");
|
||||
ok(strchr(res+1, '\\') == 0, "file not in the root directory\n");
|
||||
ok(res[strlen(res)-1] == '.', "first call - last character is not a dot\n");
|
||||
|
||||
res = tmpnam(name);
|
||||
ok(res != NULL, "tmpnam returned NULL\n");
|
||||
ok(res == name, "supplied buffer was not used\n");
|
||||
ok(res[0] == '\\', "first character is not a backslash\n");
|
||||
ok(strchr(res+1, '\\') == 0, "file not in the root directory\n");
|
||||
ok(res[strlen(res)-1] != '.', "second call - last character is a dot\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
START_TEST(file)
|
||||
{
|
||||
int arg_c;
|
||||
char** arg_v;
|
||||
|
||||
arg_c = winetest_get_mainargs( &arg_v );
|
||||
|
||||
if (arg_c >= 3)
|
||||
{
|
||||
if (arg_c == 3) test_file_inherit_child(arg_v[2]); else test_file_inherit_child_no(arg_v[2]);
|
||||
return;
|
||||
}
|
||||
|
||||
test_fdopen();
|
||||
test_fileops();
|
||||
test_fgetwc();
|
||||
test_file_put_get();
|
||||
test_file_write_read();
|
||||
test_file_inherit(arg_v[0]);
|
||||
test_tmpnam();
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* Unit test suite for memory functions
|
||||
*
|
||||
* Copyright 2003 Dimitrie O. Paun
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "wine/test.h"
|
||||
|
||||
START_TEST(heap)
|
||||
{
|
||||
void *mem;
|
||||
|
||||
mem = malloc(0);
|
||||
ok(mem != NULL, "memory not allocated for size 0\n");
|
||||
|
||||
mem = realloc(NULL, 10);
|
||||
ok(mem != NULL, "memory not allocated\n");
|
||||
|
||||
mem = realloc(mem, 20);
|
||||
ok(mem != NULL, "memory not reallocated\n");
|
||||
|
||||
mem = realloc(mem, 0);
|
||||
ok(mem == NULL, "memory not freed\n");
|
||||
|
||||
mem = realloc(NULL, 0);
|
||||
ok(mem != NULL, "memory not (re)allocated for size 0\n");
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
# Microsoft Developer Studio Project File - Name="msvcrt_test" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=msvcrt_test - Win32 Wine Headers
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "msvcrt_test.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "msvcrt_test.mak" CFG="msvcrt_test - Win32 Wine Headers"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "msvcrt_test - Win32 MSVC Headers" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "msvcrt_test - Win32 Wine Headers" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
!IF "$(CFG)" == "msvcrt_test - Win32 MSVC Headers"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Output\Win32_MSVC_Headers"
|
||||
# PROP BASE Intermediate_Dir "Output\Win32_MSVC_Headers"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Output\Win32_MSVC_Headers"
|
||||
# PROP Intermediate_Dir "Output\Win32_MSVC_Headers"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WINVER=0x0501" /D "_WIN32_WINNT=0x0501" /D "_WIN32_IE=0x0600" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I ..\..\..\Output\\Win32_MSVC_Headers /D "WINVER=0x0501" /D "_WIN32_WINNT=0x0501" /D "_WIN32_IE=0x0600" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_MSVCRT_TEST_" /D "__WINE_USE_NATIVE_HEADERS" /D __WINETEST_OUTPUT_DIR=\"Output\\Win32_MSVC_Headers\" /D "__i386__" /D "_X86_" /D inline=__inline /FR /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x41d /d "_DEBUG"
|
||||
# ADD RSC /l 0x41d /i "..\..\..\Output\\Win32_MSVC_Headers" /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
!ELSEIF "$(CFG)" == "msvcrt_test - Win32 Wine Headers"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Output\Win32_Wine_Headers"
|
||||
# PROP BASE Intermediate_Dir "Output\Win32_Wine_Headers"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Output\Win32_Wine_Headers"
|
||||
# PROP Intermediate_Dir "Output\Win32_Wine_Headers"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WINVER=0x0501" /D "_WIN32_WINNT=0x0501" /D "_WIN32_IE=0x0600" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I ..\..\..\Output\\Win32_Wine_Headers /I ..\..\..\include /D "WINVER=0x0501" /D "_WIN32_WINNT=0x0501" /D "_WIN32_IE=0x0600" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_MSVCRT_TEST_" /D __WINETEST_OUTPUT_DIR=\"Output\\Win32_Wine_Headers\" /D "__i386__" /D "_X86_" /D inline=__inline /FR /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x41d /d "_DEBUG"
|
||||
# ADD RSC /l 0x41d /i "..\..\..\Output\\Win32_Wine_Headers" /i "..\..\..\include" /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "msvcrt_test - Win32 MSVC Headers"
|
||||
# Name "msvcrt_test - Win32 Wine Headers"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\cpp.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\\
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\testlist.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
|
@ -1,151 +0,0 @@
|
|||
/*
|
||||
* Conformance tests for *printf functions.
|
||||
*
|
||||
* Copyright 2002 Uwe Bonnes
|
||||
* Copyright 2004 Aneurin Price
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
static void test_sprintf( void )
|
||||
{
|
||||
char buffer[100];
|
||||
const char *I64d = "%I64d";
|
||||
const char *O4c = "%04c";
|
||||
const char *O4s = "%04s";
|
||||
const char *hash012p = "%#012p";
|
||||
double pnumber=789456123;
|
||||
/** WCHAR widestring[]={'w','i','d','e','s','t','r','i','n','g',0};**/
|
||||
sprintf(buffer,"%+#23.15e",pnumber);
|
||||
todo_wine
|
||||
{
|
||||
ok(strstr(buffer,"e+008") != 0,"Sprintf different \"%s\"\n",buffer);
|
||||
}
|
||||
sprintf(buffer,I64d,((ULONGLONG)0xffffffff)*0xffffffff);
|
||||
todo_wine
|
||||
{
|
||||
ok(strlen(buffer) == 11,"Problem with long long \"%s\"\n",buffer);
|
||||
}
|
||||
sprintf(buffer,"%lld",((ULONGLONG)0xffffffff)*0xffffffff);
|
||||
todo_wine
|
||||
{
|
||||
ok(strlen(buffer) == 1,"Problem with \"ll\" interpretation \"%s\"\n",buffer);
|
||||
}
|
||||
/** This one actually crashes WINE at the moment, when using builtin msvcrt.dll.
|
||||
sprintf(buffer,"%S",widestring);
|
||||
todo_wine
|
||||
{
|
||||
ok(strlen(buffer) == 10,"Problem with \"%%S\" interpretation \"%s\"\n",buffer);
|
||||
}
|
||||
**/
|
||||
sprintf(buffer,O4c,'1');
|
||||
todo_wine
|
||||
{
|
||||
ok(!strcmp(buffer,"0001"),"Character not zero-prefixed \"%s\"\n",buffer);
|
||||
}
|
||||
sprintf(buffer,"%p",(void *)57);
|
||||
todo_wine
|
||||
{
|
||||
ok(!strcmp(buffer,"00000039"),"Pointer formatted incorrectly \"%s\"\n",buffer);
|
||||
}
|
||||
sprintf(buffer,hash012p,(void *)57);
|
||||
todo_wine
|
||||
{
|
||||
ok(!strcmp(buffer," 0X00000039"),"Pointer formatted incorrectly \"%s\"\n",buffer);
|
||||
}
|
||||
sprintf(buffer,O4s,"foo");/**Warning again**/
|
||||
todo_wine
|
||||
{
|
||||
ok(!strcmp(buffer,"0foo"),"String not zero-prefixed \"%s\"\n",buffer);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_swprintf( void )
|
||||
{
|
||||
wchar_t buffer[100];
|
||||
const wchar_t I64d[] = {'%','I','6','4','d',0};
|
||||
double pnumber=789456123;
|
||||
const wchar_t TwentyThreePoint15e[]= {'%','+','#','2','3','.','1','5','e',0};
|
||||
const wchar_t e008[] = {'e','+','0','0','8',0};
|
||||
const char string[]={'s','t','r','i','n','g',0};
|
||||
const wchar_t S[]={'%','S',0};
|
||||
swprintf(buffer,TwentyThreePoint15e,pnumber);
|
||||
todo_wine
|
||||
{
|
||||
ok(wcsstr(buffer,e008) != 0,"Sprintf different\n");
|
||||
}
|
||||
swprintf(buffer,I64d,((ULONGLONG)0xffffffff)*0xffffffff);
|
||||
todo_wine
|
||||
{
|
||||
ok(wcslen(buffer) == 11,"Problem with long long\n");
|
||||
}
|
||||
swprintf(buffer,S,string);
|
||||
ok(wcslen(buffer) == 6,"Problem with \"%%S\" interpretation\n");
|
||||
}
|
||||
|
||||
static void test_fwprintf( void )
|
||||
{
|
||||
const char *string="not a wide string";
|
||||
todo_wine
|
||||
{
|
||||
ok(fwprintf(fopen("nul","r+"),(wchar_t *)string) == -1,"Non-wide string should not be printed by fwprintf\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void test_snprintf (void)
|
||||
{
|
||||
struct snprintf_test {
|
||||
const char *format;
|
||||
int expected;
|
||||
struct {
|
||||
int retval;
|
||||
int render;
|
||||
} todo;
|
||||
};
|
||||
/* Pre-2.1 libc behaviour, not C99 compliant. */
|
||||
const struct snprintf_test tests[] = {{"short", 5, {0, 0}},
|
||||
{"justfit", 7, {0, 0}},
|
||||
{"justfits", 8, {0, 1}},
|
||||
{"muchlonger", -1, {1, 1}}};
|
||||
char buffer[8];
|
||||
const int bufsiz = sizeof buffer;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < sizeof tests / sizeof tests[0]; i++) {
|
||||
const char *fmt = tests[i].format;
|
||||
const int expect = tests[i].expected;
|
||||
const int n = _snprintf (buffer, bufsiz, fmt);
|
||||
const int valid = n < 0 ? bufsiz : (n == bufsiz ? n : n+1);
|
||||
|
||||
todo (tests[i].todo.retval ? "wine" : "none")
|
||||
ok (n == expect, "\"%s\": expected %d, returned %d\n",
|
||||
fmt, expect, n);
|
||||
todo (tests[i].todo.render ? "wine" : "none")
|
||||
ok (!memcmp (fmt, buffer, valid),
|
||||
"\"%s\": rendered \"%.*s\"\n", fmt, valid, buffer);
|
||||
};
|
||||
}
|
||||
|
||||
START_TEST(printf)
|
||||
{
|
||||
test_sprintf();
|
||||
test_swprintf();
|
||||
test_fwprintf();
|
||||
test_snprintf();
|
||||
}
|
|
@ -1,103 +0,0 @@
|
|||
/*
|
||||
* Unit test suite for *scanf functions.
|
||||
*
|
||||
* Copyright 2002 Uwe Bonnes
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
static void test_sscanf( void )
|
||||
{
|
||||
char buffer[100], buffer1[100];
|
||||
char format[20];
|
||||
int result, ret;
|
||||
float res1= -82.6267f, res2= 27.76f, res11, res12;
|
||||
static const char pname[]=" St. Petersburg, Florida\n";
|
||||
int hour=21,min=59,sec=20;
|
||||
int number,number_so_far;
|
||||
|
||||
|
||||
/* check EOF */
|
||||
strcpy(buffer,"");
|
||||
ret = sscanf(buffer, "%d", &result);
|
||||
ok( ret == EOF,"sscanf returns %x instead of %x\n", ret, EOF );
|
||||
|
||||
/* check %x */
|
||||
strcpy(buffer,"0x519");
|
||||
ok( sscanf(buffer, "%x", &result) == 1, "sscanf failed\n" );
|
||||
ok( result == 0x519,"sscanf reads %x instead of %x\n", result, 0x519 );
|
||||
|
||||
strcpy(buffer,"0x51a");
|
||||
ok( sscanf(buffer, "%x", &result) == 1, "sscanf failed\n" );
|
||||
ok( result == 0x51a ,"sscanf reads %x instead of %x\n", result, 0x51a );
|
||||
|
||||
strcpy(buffer,"0x51g");
|
||||
ok( sscanf(buffer, "%x", &result) == 1, "sscanf failed\n" );
|
||||
ok( result == 0x51, "sscanf reads %x instead of %x\n", result, 0x51 );
|
||||
|
||||
/* check % followed by any char */
|
||||
strcpy(buffer,"\"%12@");
|
||||
strcpy(format,"%\"%%%d%@"); /* work around gcc format check */
|
||||
ok( sscanf(buffer, format, &result) == 1, "sscanf failed\n" );
|
||||
ok( result == 12, "sscanf reads %x instead of %x\n", result, 12 );
|
||||
|
||||
/* Check float */
|
||||
ret = sprintf(buffer,"%f %f",res1, res2);
|
||||
ret = sscanf(buffer,"%f%f",&res11, &res12);
|
||||
ok( (res11 == res1) && (res12 == res2), "Error reading floats\n");
|
||||
|
||||
/* check strings */
|
||||
ret = sprintf(buffer," %s", pname);
|
||||
ret = sscanf(buffer,"%*c%[^\n]",buffer1);
|
||||
ok( ret == 1, "Error with format \"%s\"\n","%*c%[^\n]");
|
||||
ok( strncmp(pname,buffer1,strlen(buffer1)) == 0, "Error with \"%s\" \"%s\"\n",pname, buffer1);
|
||||
|
||||
ret = sscanf("abcefgdh","%*[a-cg-e]%c",&buffer[0]);
|
||||
ok( ret == 1, "Error with format \"%s\"\n","%*[a-cg-e]%c");
|
||||
ok( buffer[0] == 'd', "Error with \"abcefgdh\" \"%c\"\n", buffer[0]);
|
||||
|
||||
ret = sscanf("abcefgdh","%*[a-cd-dg-e]%c",&buffer[0]);
|
||||
ok( ret == 1, "Error with format \"%s\"\n","%*[a-cd-dg-e]%c");
|
||||
ok( buffer[0] == 'h', "Error with \"abcefgdh\" \"%c\"\n", buffer[0]);
|
||||
|
||||
/* check digits */
|
||||
ret = sprintf(buffer,"%d:%d:%d",hour,min,sec);
|
||||
ret = sscanf(buffer,"%d%n",&number,&number_so_far);
|
||||
ok(ret == 1 , "problem with format arg \"%%d%%n\"\n");
|
||||
ok(number == hour,"Read wrong arg %d instead of %d\n",number, hour);
|
||||
ok(number_so_far == 2,"Read wrong arg for \"%%n\" %d instead of 2\n",number_so_far);
|
||||
|
||||
ret = sscanf(buffer+2,"%*c%n",&number_so_far);
|
||||
ok(ret == 0 , "problem with format arg \"%%*c%%n\"\n");
|
||||
ok(number_so_far == 1,"Read wrong arg for \"%%n\" %d instead of 2\n",number_so_far);
|
||||
|
||||
/* Check %i according to bug 1878 */
|
||||
strcpy(buffer,"123");
|
||||
ret = sscanf(buffer, "%i", &result);
|
||||
ok( ret == 1 , "Wrong number of arguments read\n");
|
||||
ok(result == 123, "Wrong number read\n");
|
||||
ret = sscanf(buffer, "%d", &result);
|
||||
ok( ret == 1 , "Wrong number of arguments read\n");
|
||||
ok(result == 123, "Wrong number read\n");
|
||||
}
|
||||
|
||||
START_TEST(scanf)
|
||||
{
|
||||
test_sscanf();
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* Unit test suite for string functions.
|
||||
*
|
||||
* Copyright 2004 Uwe Bonnes
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "wine/test.h"
|
||||
#include "winbase.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static void* (*pmemcpy)(void *, const void *, size_t n);
|
||||
static int* (*pmemcmp)(void *, const void *, size_t n);
|
||||
|
||||
#define SETNOFAIL(x,y) x = (void*)GetProcAddress(hMsvcrt,y)
|
||||
#define SET(x,y) SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y)
|
||||
|
||||
|
||||
START_TEST(string)
|
||||
{
|
||||
void *mem;
|
||||
static const char xilstring[]="c:/xilinx";
|
||||
int nLen=strlen(xilstring);
|
||||
HMODULE hMsvcrt = LoadLibraryA("msvcrt.dll");
|
||||
ok(hMsvcrt != 0, "LoadLibraryA failed\n");
|
||||
SET(pmemcpy,"memcpy");
|
||||
SET(pmemcmp,"memcmp");
|
||||
|
||||
/* MSVCRT memcpy behaves like memmove for overlapping moves,
|
||||
MFC42 CString::Insert seems to rely on that behaviour */
|
||||
mem = malloc(100);
|
||||
ok(mem != NULL, "memory not allocated for size 0\n");
|
||||
strcpy((char*)mem,xilstring);
|
||||
pmemcpy((char*)mem+5, mem,nLen+1);
|
||||
ok(pmemcmp((char*)mem+5,xilstring, nLen) == 0,
|
||||
"Got result %s\n",(char*)mem+5);
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
/* Automatically generated file; DO NOT EDIT!! */
|
||||
|
||||
/* stdarg.h is needed for Winelib */
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
|
||||
extern void func_cpp(void);
|
||||
extern void func_environ(void);
|
||||
extern void func_file(void);
|
||||
extern void func_heap(void);
|
||||
extern void func_printf(void);
|
||||
extern void func_scanf(void);
|
||||
extern void func_string(void);
|
||||
extern void func_time(void);
|
||||
|
||||
struct test
|
||||
{
|
||||
const char *name;
|
||||
void (*func)(void);
|
||||
};
|
||||
|
||||
static const struct test winetest_testlist[] =
|
||||
{
|
||||
{ "cpp", func_cpp },
|
||||
{ "environ", func_environ },
|
||||
{ "file", func_file },
|
||||
{ "heap", func_heap },
|
||||
{ "printf", func_printf },
|
||||
{ "scanf", func_scanf },
|
||||
{ "string", func_string },
|
||||
{ "time", func_time },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
#define WINETEST_WANT_MAIN
|
||||
#include "wine/test.h"
|
|
@ -1,189 +0,0 @@
|
|||
/*
|
||||
* Unit test suite for time functions.
|
||||
*
|
||||
* Copyright 2004 Uwe Bonnes
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "wine/test.h"
|
||||
#include "winbase.h"
|
||||
#include "time.h"
|
||||
|
||||
#include <stdlib.h> /*setenv*/
|
||||
#include <stdio.h> /*printf*/
|
||||
|
||||
#define SECSPERDAY 86400
|
||||
#define SECSPERHOUR 3600
|
||||
#define SECSPERMIN 60
|
||||
#define MINSPERHOUR 60
|
||||
#define HOURSPERDAY 24
|
||||
|
||||
static void test_gmtime()
|
||||
{
|
||||
time_t gmt = (time_t)NULL;
|
||||
struct tm* gmt_tm = gmtime(&gmt);
|
||||
if(gmt_tm == 0)
|
||||
{
|
||||
ok(0,"gmtime() error\n");
|
||||
return;
|
||||
}
|
||||
ok(((gmt_tm->tm_year == 70) && (gmt_tm->tm_mon == 0) && (gmt_tm->tm_yday == 0) &&
|
||||
(gmt_tm->tm_mday == 1) && (gmt_tm->tm_wday == 4) && (gmt_tm->tm_hour == 0) &&
|
||||
(gmt_tm->tm_min == 0) && (gmt_tm->tm_sec == 0) && (gmt_tm->tm_isdst == 0)),
|
||||
"Wrong date:Year %4d mon %2d yday %3d mday %2d wday %1d hour%2d min %2d sec %2d dst %2d\n",
|
||||
gmt_tm->tm_year, gmt_tm->tm_mon, gmt_tm->tm_yday, gmt_tm->tm_mday, gmt_tm->tm_wday,
|
||||
gmt_tm->tm_hour, gmt_tm->tm_min, gmt_tm->tm_sec, gmt_tm->tm_isdst);
|
||||
|
||||
}
|
||||
static void test_mktime()
|
||||
{
|
||||
TIME_ZONE_INFORMATION tzinfo;
|
||||
DWORD res = GetTimeZoneInformation(&tzinfo);
|
||||
struct tm my_tm, sav_tm;
|
||||
time_t nulltime, local_time;
|
||||
char TZ_env[256];
|
||||
int secs;
|
||||
|
||||
ok (res != TIME_ZONE_ID_INVALID, "GetTimeZoneInformation failed\n");
|
||||
/* Bias may be positive or negative, to use offset of one day */
|
||||
secs= SECSPERDAY - (tzinfo.Bias +
|
||||
( res == TIME_ZONE_ID_STANDARD ? tzinfo.StandardBias :
|
||||
( res == TIME_ZONE_ID_DAYLIGHT ? tzinfo.DaylightBias : 0 ))) * SECSPERMIN;
|
||||
my_tm.tm_mday = 1 + secs/SECSPERDAY;
|
||||
secs = secs % SECSPERDAY;
|
||||
my_tm.tm_hour = secs / SECSPERHOUR;
|
||||
secs = secs % SECSPERHOUR;
|
||||
my_tm.tm_min = secs / SECSPERMIN;
|
||||
secs = secs % SECSPERMIN;
|
||||
my_tm.tm_sec = secs;
|
||||
|
||||
my_tm.tm_year = 70;
|
||||
my_tm.tm_mon = 0;
|
||||
my_tm.tm_isdst= 0;
|
||||
|
||||
sav_tm = my_tm;
|
||||
|
||||
local_time = mktime(&my_tm);
|
||||
ok(((DWORD)local_time == SECSPERDAY), "mktime returned 0x%08lx\n",(DWORD)local_time);
|
||||
/* now test some unnormalized struct tm's */
|
||||
my_tm = sav_tm;
|
||||
my_tm.tm_sec += 60;
|
||||
my_tm.tm_min -= 1;
|
||||
local_time = mktime(&my_tm);
|
||||
ok(((DWORD)local_time == SECSPERDAY), "Unnormalized mktime returned 0x%08lx\n",(DWORD)local_time);
|
||||
ok( my_tm.tm_year == sav_tm.tm_year && my_tm.tm_mon == sav_tm.tm_mon &&
|
||||
my_tm.tm_mday == sav_tm.tm_mday && my_tm.tm_hour == sav_tm.tm_hour &&
|
||||
my_tm.tm_sec == sav_tm.tm_sec
|
||||
, "mktime returned %3d-%02d-%02d %02d:%02d expected %3d-%02d-%02d %02d:%02d.\n",
|
||||
my_tm.tm_year,my_tm.tm_mon,my_tm.tm_mday,
|
||||
my_tm.tm_hour,my_tm.tm_sec,
|
||||
sav_tm.tm_year,sav_tm.tm_mon,sav_tm.tm_mday,
|
||||
sav_tm.tm_hour,sav_tm.tm_sec);
|
||||
my_tm = sav_tm;
|
||||
my_tm.tm_min -= 60;
|
||||
my_tm.tm_hour += 1;
|
||||
local_time = mktime(&my_tm);
|
||||
ok(((DWORD)local_time == SECSPERDAY), "Unnormalized mktime returned 0x%08lx\n",(DWORD)local_time);
|
||||
ok( my_tm.tm_year == sav_tm.tm_year && my_tm.tm_mon == sav_tm.tm_mon &&
|
||||
my_tm.tm_mday == sav_tm.tm_mday && my_tm.tm_hour == sav_tm.tm_hour &&
|
||||
my_tm.tm_sec == sav_tm.tm_sec
|
||||
, "mktime returned %3d-%02d-%02d %02d:%02d expected %3d-%02d-%02d %02d:%02d.\n",
|
||||
my_tm.tm_year,my_tm.tm_mon,my_tm.tm_mday,
|
||||
my_tm.tm_hour,my_tm.tm_sec,
|
||||
sav_tm.tm_year,sav_tm.tm_mon,sav_tm.tm_mday,
|
||||
sav_tm.tm_hour,sav_tm.tm_sec);
|
||||
my_tm = sav_tm;
|
||||
my_tm.tm_mon -= 12;
|
||||
my_tm.tm_year += 1;
|
||||
local_time = mktime(&my_tm);
|
||||
ok(((DWORD)local_time == SECSPERDAY), "Unnormalized mktime returned 0x%08lx\n",(DWORD)local_time);
|
||||
ok( my_tm.tm_year == sav_tm.tm_year && my_tm.tm_mon == sav_tm.tm_mon &&
|
||||
my_tm.tm_mday == sav_tm.tm_mday && my_tm.tm_hour == sav_tm.tm_hour &&
|
||||
my_tm.tm_sec == sav_tm.tm_sec
|
||||
, "mktime returned %3d-%02d-%02d %02d:%02d expected %3d-%02d-%02d %02d:%02d.\n",
|
||||
my_tm.tm_year,my_tm.tm_mon,my_tm.tm_mday,
|
||||
my_tm.tm_hour,my_tm.tm_sec,
|
||||
sav_tm.tm_year,sav_tm.tm_mon,sav_tm.tm_mday,
|
||||
sav_tm.tm_hour,sav_tm.tm_sec);
|
||||
my_tm = sav_tm;
|
||||
my_tm.tm_mon += 12;
|
||||
my_tm.tm_year -= 1;
|
||||
local_time = mktime(&my_tm);
|
||||
ok(((DWORD)local_time == SECSPERDAY), "Unnormalized mktime returned 0x%08lx\n",(DWORD)local_time);
|
||||
ok( my_tm.tm_year == sav_tm.tm_year && my_tm.tm_mon == sav_tm.tm_mon &&
|
||||
my_tm.tm_mday == sav_tm.tm_mday && my_tm.tm_hour == sav_tm.tm_hour &&
|
||||
my_tm.tm_sec == sav_tm.tm_sec
|
||||
, "mktime returned %3d-%02d-%02d %02d:%02d expected %3d-%02d-%02d %02d:%02d.\n",
|
||||
my_tm.tm_year,my_tm.tm_mon,my_tm.tm_mday,
|
||||
my_tm.tm_hour,my_tm.tm_sec,
|
||||
sav_tm.tm_year,sav_tm.tm_mon,sav_tm.tm_mday,
|
||||
sav_tm.tm_hour,sav_tm.tm_sec);
|
||||
/* now a bad time example */
|
||||
my_tm = sav_tm;
|
||||
my_tm.tm_year -= 1;
|
||||
local_time = mktime(&my_tm);
|
||||
ok((local_time == -1), "(bad time) mktime returned 0x%08lx\n",(DWORD)local_time);
|
||||
|
||||
my_tm = sav_tm;
|
||||
/* TEST that we are independent from the TZ variable */
|
||||
/*Argh, msvcrt doesn't have setenv() */
|
||||
_snprintf(TZ_env,255,"TZ=%s",(getenv("TZ")?getenv("TZ"):""));
|
||||
putenv("TZ=GMT");
|
||||
nulltime = mktime(&my_tm);
|
||||
ok(((DWORD)nulltime == SECSPERDAY),"mktime returned 0x%08lx\n",(DWORD)nulltime);
|
||||
putenv(TZ_env);
|
||||
}
|
||||
static void test_localtime()
|
||||
{
|
||||
TIME_ZONE_INFORMATION tzinfo;
|
||||
DWORD res = GetTimeZoneInformation(&tzinfo);
|
||||
time_t gmt = (time_t)(SECSPERDAY + (tzinfo.Bias +
|
||||
( res == TIME_ZONE_ID_STANDARD ? tzinfo.StandardBias :
|
||||
( res == TIME_ZONE_ID_DAYLIGHT ? tzinfo.DaylightBias : 0 ))) * SECSPERMIN);
|
||||
|
||||
char TZ_env[256];
|
||||
struct tm* lt;
|
||||
|
||||
ok (res != TIME_ZONE_ID_INVALID, "GetTimeZoneInformation failed\n");
|
||||
lt = localtime(&gmt);
|
||||
ok(((lt->tm_year == 70) && (lt->tm_mon == 0) && (lt->tm_yday == 1) &&
|
||||
(lt->tm_mday == 2) && (lt->tm_wday == 5) && (lt->tm_hour == 0) &&
|
||||
(lt->tm_min == 0) && (lt->tm_sec == 0) && (lt->tm_isdst ==
|
||||
(res == TIME_ZONE_ID_DAYLIGHT))),
|
||||
"Wrong date:Year %4d mon %2d yday %3d mday %2d wday %1d hour%2d min %2d sec %2d dst %2d\n",
|
||||
lt->tm_year, lt->tm_mon, lt->tm_yday, lt->tm_mday, lt->tm_wday, lt->tm_hour,
|
||||
lt->tm_min, lt->tm_sec, lt->tm_isdst);
|
||||
|
||||
_snprintf(TZ_env,255,"TZ=%s",(getenv("TZ")?getenv("TZ"):""));
|
||||
putenv("TZ=GMT");
|
||||
lt = localtime(&gmt);
|
||||
ok(((lt->tm_year == 70) && (lt->tm_mon == 0) && (lt->tm_yday == 1) &&
|
||||
(lt->tm_mday == 2) && (lt->tm_wday == 5) && (lt->tm_hour == 0) &&
|
||||
(lt->tm_min == 0) && (lt->tm_sec == 0) && (lt->tm_isdst ==
|
||||
(res == TIME_ZONE_ID_DAYLIGHT))),
|
||||
"Wrong date:Year %4d mon %2d yday %3d mday %2d wday %1d hour%2d min %2d sec %2d dst %2d\n",
|
||||
lt->tm_year, lt->tm_mon, lt->tm_yday, lt->tm_mday, lt->tm_wday, lt->tm_hour,
|
||||
lt->tm_min, lt->tm_sec, lt->tm_isdst);
|
||||
putenv(TZ_env);
|
||||
}
|
||||
|
||||
|
||||
START_TEST(time)
|
||||
{
|
||||
test_gmtime();
|
||||
test_mktime();
|
||||
test_localtime();
|
||||
}
|
Loading…
Reference in a new issue