user32/tests: Restructure the DDE end-to-end tests to make it easier to add new cases.
[wine] / dlls / atl / tests / module.c
1 /*
2  * ATL test program
3  *
4  * Copyright 2010 Marcus Meissner
5  *
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21
22 #include <stdarg.h>
23 #include <stdio.h>
24
25 #define COBJMACROS
26
27 #include <wine/test.h>
28 #include <windef.h>
29 #include <winbase.h>
30 #include <winuser.h>
31 #include <wingdi.h>
32 #include <winnls.h>
33 #include <winerror.h>
34 #include <winnt.h>
35 #include <initguid.h>
36 #include <wtypes.h>
37 #include <olectl.h>
38 #include <ocidl.h>
39
40 struct _ATL_OBJMAP_ENTRYW;
41 struct _AtlCreateWndData;
42 struct _ATL_TERMFUNC_ELEM;
43
44 struct _ATL_MODULEW
45 {
46     UINT cbSize;
47     HINSTANCE m_hInst;
48     HINSTANCE m_hInstResource;
49     HINSTANCE m_hInstTypeLib;
50     struct _ATL_OBJMAP_ENTRYW* m_pObjMap;
51     LONG m_nLockCnt;
52     HANDLE m_hHeap;
53     union
54     {
55         CRITICAL_SECTION m_csTypeInfoHolder;
56         CRITICAL_SECTION m_csStaticDataInit;
57     } u;
58     CRITICAL_SECTION m_csWindowCreate;
59     CRITICAL_SECTION m_csObjMap;
60
61     DWORD dwAtlBuildVer;
62     struct _AtlCreateWndData* m_pCreateWndList;
63     BOOL m_bDestroyHeap;
64     GUID* pguidVer;
65     DWORD m_dwHeaps;
66     HANDLE* m_phHeaps;
67     int m_nHeap;
68     struct _ATL_TERMFUNC_ELEM* m_pTermFuncs;
69 };
70
71 HRESULT WINAPI AtlModuleInit(struct _ATL_MODULEW* pM, struct _ATL_OBJMAP_ENTRYW* p, HINSTANCE h);
72
73 #define MAXSIZE 512
74 static void test_StructSize(void)
75 {
76         struct _ATL_MODULEW  *tst;
77         HRESULT              hres;
78         int i;
79
80         tst = HeapAlloc (GetProcessHeap(),HEAP_ZERO_MEMORY,MAXSIZE);
81
82         for (i=0;i<MAXSIZE;i++) {
83                 tst->cbSize = i;
84                 hres = AtlModuleInit(tst, NULL, NULL);
85
86                 switch (i)  {
87                 case FIELD_OFFSET( struct _ATL_MODULEW, dwAtlBuildVer ):
88                 case sizeof(struct _ATL_MODULEW):
89 #ifdef _WIN64
90                 case sizeof(struct _ATL_MODULEW) + sizeof(void *):
91 #endif
92                         ok (hres == S_OK, "AtlModuleInit with %d failed (0x%x).\n", i, (int)hres);
93                         break;
94                 default:
95                         ok (FAILED(hres), "AtlModuleInit with %d succeeded? (0x%x).\n", i, (int)hres);
96                         break;
97                 }
98         }
99 }
100
101 START_TEST(module)
102 {
103         test_StructSize();
104 }