Implement A->W call for GetNamedSecurityInfo.
[wine] / dlls / mapi32 / tests / util.c
1 /*
2  * Unit test suite for MAPI utility functions
3  *
4  * Copyright 2004 Jon Griffiths
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #define NONAMELESSUNION
22 #define NONAMELESSSTRUCT
23 #include "wine/test.h"
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "winerror.h"
28 #include "winnt.h"
29 #include "mapiutil.h"
30 #include "mapitags.h"
31
32 static HMODULE hMapi32 = 0;
33
34 static SCODE (WINAPI *pScInitMapiUtil)(ULONG);
35 static void  (WINAPI *pSwapPword)(PUSHORT,ULONG);
36 static void  (WINAPI *pSwapPlong)(PULONG,ULONG);
37
38 static void test_SwapPword(void)
39 {
40     USHORT shorts[3];
41
42     pSwapPword = (void*)GetProcAddress(hMapi32, "SwapPword@8");
43     if (!pSwapPword)
44         return;
45
46     shorts[0] = 0xff01;
47     shorts[1] = 0x10ff;
48     shorts[2] = 0x2001;
49     pSwapPword(shorts, 2);
50     ok(shorts[0] == 0x01ff && shorts[1] == 0xff10 && shorts[2] == 0x2001,
51        "Expected {0x01ff,0xff10,0x2001}, got {0x%04x,0x%04x,0x%04x}\n",
52        shorts[0], shorts[1], shorts[2]);
53 }
54
55 static void test_SwapPlong(void)
56 {
57     ULONG longs[3];
58
59     pSwapPlong = (void*)GetProcAddress(hMapi32, "SwapPlong@8");
60     if (!pSwapPlong)
61         return;
62
63     longs[0] = 0xffff0001;
64     longs[1] = 0x1000ffff;
65     longs[2] = 0x20000001;
66     pSwapPlong(longs, 2);
67     ok(longs[0] == 0x0100ffff && longs[1] == 0xffff0010 && longs[2] == 0x20000001,
68        "Expected {0x0100ffff,0xffff0010,0x20000001}, got {0x%08lx,0x%08lx,0x%08lx}\n",
69        longs[0], longs[1], longs[2]);
70 }
71
72 START_TEST(util)
73 {
74     hMapi32 = LoadLibraryA("mapi32.dll");
75     
76     pScInitMapiUtil = (void*)GetProcAddress(hMapi32, "ScInitMapiUtil@4");
77     if (!pScInitMapiUtil)
78         return;
79     pScInitMapiUtil(0);
80
81     test_SwapPword();
82     test_SwapPlong();
83 }