Define EXTRA_TRACES instead of #if 0.
[wine] / dlls / shlwapi / tests / ordinal.c
1 /* Unit test suite for SHLWAPI ordinal functions
2  *
3  * Copyright 2004 Jon Griffiths
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19
20 #include <stdlib.h>
21 #include <stdio.h>
22
23 #include "wine/test.h"
24 #include "winbase.h"
25 #include "winerror.h"
26 #include "winuser.h"
27 #define NO_SHLWAPI_REG
28 #define NO_SHLWAPI_PATH
29 #define NO_SHLWAPI_GDI
30 #define NO_SHLWAPI_STREAM
31 #include "shlwapi.h"
32
33 /* Function ptrs for ordinal calls */
34 static HMODULE hShlwapi;
35 static int (WINAPI *pSHSearchMapInt)(const int*,const int*,int,int);
36
37
38 static void test_SHSearchMapInt(void)
39 {
40   int keys[8], values[8];
41   int i = 0;
42
43   if (!pSHSearchMapInt)
44     return;
45
46   memset(keys, 0, sizeof(keys));
47   memset(values, 0, sizeof(values));
48   keys[0] = 99; values[0] = 101;
49
50   /* NULL key/value lists crash native, so skip testing them */
51
52   /* 1 element */
53   i = pSHSearchMapInt(keys, values, 1, keys[0]);
54   ok(i == values[0], "Len 1, expected %d, got %d\n", values[0], i);
55
56   /* Key doesn't exist */
57   i = pSHSearchMapInt(keys, values, 1, 100);
58   ok(i == -1, "Len 1 - bad key, expected -1, got %d\n", i);
59
60   /* Len = 0 => not found */
61   i = pSHSearchMapInt(keys, values, 0, keys[0]);
62   ok(i == -1, "Len 1 - passed len 0, expected -1, got %d\n", i);
63
64   /* 2 elements, len = 1 */
65   keys[1] = 98; values[1] = 102;
66   i = pSHSearchMapInt(keys, values, 1, keys[1]);
67   ok(i == -1, "Len 1 - array len 2, expected -1, got %d\n", i);
68
69   /* 2 elements, len = 2 */
70   i = pSHSearchMapInt(keys, values, 2, keys[1]);
71   ok(i == values[1], "Len 2, expected %d, got %d\n", values[1], i);
72
73   /* Searches forward */
74   keys[2] = 99; values[2] = 103;
75   i = pSHSearchMapInt(keys, values, 3, keys[0]);
76   ok(i == values[0], "Len 3, expected %d, got %d\n", values[0], i);
77 }
78
79
80 START_TEST(ordinal)
81 {
82   hShlwapi = LoadLibraryA("shlwapi.dll");
83   ok(hShlwapi != 0, "LoadLibraryA failed\n");
84   if (!hShlwapi)
85     return;
86
87   pSHSearchMapInt = (void*)GetProcAddress(hShlwapi, (LPSTR)198);
88
89   test_SHSearchMapInt();
90   FreeLibrary(hShlwapi);
91 }