debug.c 1.99 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * Unit test suite for debug functions.
 *
 * Copyright 2004 Patrik Stridvall
 *
 * 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
18
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 20 21 22 23 24 25 26
 */

#include <stdarg.h>

#include "windef.h"
#include "winbase.h"
#include "winnt.h"

27 28
#include "crtdbg.h"

29 30 31 32 33 34 35 36 37 38
#include "wine/test.h"

/**********************************************************************/

static void * (*pMSVCRTD_operator_new_dbg)(unsigned long, int, const char *, int) = NULL;

/* Some exports are only available in later versions */
#define SETNOFAIL(x,y) x = (void*)GetProcAddress(hModule,y)
#define SET(x,y) SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y)

39
static int init_functions(void)
40 41 42
{
  HMODULE hModule = LoadLibraryA("msvcrtd.dll");

43
  if (!hModule) {
44
    trace("LoadLibraryA failed to load msvcrtd.dll with GLE=%d\n", GetLastError());
45
    return FALSE;
46
  }
47 48 49 50 51 52 53 54 55 56

  SET(pMSVCRTD_operator_new_dbg, "??2@YAPAXIHPBDH@Z");
  if (pMSVCRTD_operator_new_dbg == NULL)
    return FALSE;

  return TRUE;
}

/**********************************************************************/

57
static void test_new(void)
58 59 60
{
  void *mem;

61
  mem = pMSVCRTD_operator_new_dbg(42, _NORMAL_BLOCK, __FILE__, __LINE__);
62 63 64 65 66 67 68 69 70 71 72 73
  ok(mem != NULL, "memory not allocated\n");
}

/**********************************************************************/

START_TEST(debug)
{
  if (!init_functions()) 
    return;

  test_new();
}