xref: /reactos/modules/rostests/winetests/sxs/name.c (revision 845faec4)
1 /*
2  * Copyright 2012 Hans Leidekker for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18 
19 #include <stdio.h>
20 
21 #define COBJMACROS
22 
23 #include <windows.h>
24 #include <winsxs.h>
25 #include <corerror.h>
26 
27 #include "wine/test.h"
28 
29 static const WCHAR wine1W[] =
30     {'w','i','n','e',0};
31 static const WCHAR wine2W[] =
32     {'w','i','n','e',',','v','e','r','s','i','o','n','=','\"','1','.','2','.','3','.','4','\"',0};
33 static const WCHAR wine3W[] =
34     {'w','i','n','e',',','v','e','r','s','i','o','n','=','1','.','2','.','3','.','4',0};
35 static const WCHAR wine4W[] =
36     {'w','i','n','e',',',' ','v','e','r','s','i','o','n','=','\"','1','.','2','.','3','.','4','\"',0};
37 static const WCHAR wine5W[] =
38     {'w','i','n','e',',','v','e','r','s','i','o','n',' ','=','\"','1','.','2','.','3','.','4','\"',0};
39 static const WCHAR wine6W[] =
40     {'w','i','n','e',',','v','e','r','s','i','o','n','=',' ','\"','1','.','2','.','3','.','4','\"',0};
41 static const WCHAR wine7W[] =
42     {'w','i','n','e',' ',',','v','e','r','s','i','o','n','=','\"','1','.','2','.','3','.','4','\"',0};
43 static const WCHAR wine8W[] =
44     {'w','i','n','e',',','v','e','r','s','i','o','n',0};
45 static const WCHAR wine9W[] =
46     {'w','i','n','e',',','t','y','p','e','=','\"','\"',0};
47 static const WCHAR wine10W[] =
48     {'w','i','n','e',',','t','y','p','e','=','\"','w','i','n','3','2',0};
49 
50 static void test_CreateAssemblyNameObject( void )
51 {
52     static const WCHAR emptyW[] = {0};
53     IAssemblyName *name;
54     HRESULT hr;
55 
56     hr = CreateAssemblyNameObject( NULL, wine1W, CANOF_PARSE_DISPLAY_NAME, NULL );
57     ok(hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr);
58 
59     name = (IAssemblyName *)0xdeadbeef;
60     hr = CreateAssemblyNameObject( &name, NULL, CANOF_PARSE_DISPLAY_NAME, NULL );
61     ok( hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr );
62     ok( !name, "expected NULL got %p\n", name );
63 
64     name = (IAssemblyName *)0xdeadbeef;
65     hr = CreateAssemblyNameObject( &name, emptyW, CANOF_PARSE_DISPLAY_NAME, NULL );
66     ok( hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr );
67     ok( !name, "expected NULL got %p\n", name );
68 
69     name = (IAssemblyName *)0xdeadbeef;
70     hr = CreateAssemblyNameObject( &name, NULL, CANOF_SET_DEFAULT_VALUES, NULL );
71     ok( hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr );
72     ok( !name, "expected NULL got %p\n", name );
73 
74     name = (IAssemblyName *)0xdeadbeef;
75     hr = CreateAssemblyNameObject( &name, emptyW, CANOF_SET_DEFAULT_VALUES, NULL );
76     ok( hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr );
77     ok( !name, "expected NULL got %p\n", name );
78 
79     name = NULL;
80     hr = CreateAssemblyNameObject( &name, wine1W, CANOF_PARSE_DISPLAY_NAME, NULL );
81     ok( hr == S_OK, "expected S_OK got %08x\n", hr );
82     ok( name != NULL, "expected non-NULL name\n" );
83     IAssemblyName_Release( name );
84 
85     hr = CreateAssemblyNameObject( NULL, wine1W, CANOF_SET_DEFAULT_VALUES, NULL );
86     ok( hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr );
87 
88     name = (IAssemblyName *)0xdeadbeef;
89     hr = CreateAssemblyNameObject( &name, NULL, CANOF_SET_DEFAULT_VALUES, NULL );
90     ok( hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr );
91     ok( !name, "expected NULL got %p\n", name );
92 
93     name = (IAssemblyName *)0xdeadbeef;
94     hr = CreateAssemblyNameObject( &name, emptyW, CANOF_SET_DEFAULT_VALUES, NULL );
95     ok( hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr );
96     ok( !name, "expected NULL got %p\n", name );
97 
98     name = (IAssemblyName *)0xdeadbeef;
99     hr = CreateAssemblyNameObject( &name, NULL, CANOF_SET_DEFAULT_VALUES, NULL );
100     ok( hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr );
101     ok( !name, "expected NULL got %p\n", name );
102 
103     name = (IAssemblyName *)0xdeadbeef;
104     hr = CreateAssemblyNameObject( &name, emptyW, CANOF_SET_DEFAULT_VALUES, NULL );
105     ok( hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr );
106     ok( !name, "expected NULL got %p\n", name );
107 
108     name = (IAssemblyName *)0xdeadbeef;
109     hr = CreateAssemblyNameObject( &name, wine1W, CANOF_SET_DEFAULT_VALUES, NULL );
110     ok( hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr );
111     ok( !name, "expected NULL got %p\n", name );
112 
113     hr = CreateAssemblyNameObject( NULL, wine1W, 0, NULL );
114     ok( hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr );
115 
116     name = (IAssemblyName *)0xdeadbeef;
117     hr = CreateAssemblyNameObject( &name, NULL, 0, NULL );
118     ok( hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr );
119     ok( !name, "expected NULL got %p\n", name );
120 
121     name = (IAssemblyName *)0xdeadbeef;
122     hr = CreateAssemblyNameObject( &name, emptyW, 0, NULL );
123     ok( hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr );
124     ok( !name, "expected NULL got %p\n", name );
125 
126     name = (IAssemblyName *)0xdeadbeef;
127     hr = CreateAssemblyNameObject( &name, NULL, 0, NULL );
128     ok( hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr );
129     ok( !name, "expected NULL got %p\n", name );
130 
131     name = (IAssemblyName *)0xdeadbeef;
132     hr = CreateAssemblyNameObject( &name, emptyW, 0, NULL );
133     ok( hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr );
134     ok( !name, "expected NULL got %p\n", name );
135 
136     name = (IAssemblyName *)0xdeadbeef;
137     hr = CreateAssemblyNameObject( &name, wine1W, 0, NULL );
138     ok( hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr );
139 
140     hr = CreateAssemblyNameObject( NULL, wine1W, CANOF_SET_DEFAULT_VALUES|CANOF_PARSE_DISPLAY_NAME, NULL );
141     ok( hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr );
142 
143     name = (IAssemblyName *)0xdeadbeef;
144     hr = CreateAssemblyNameObject( &name, NULL, CANOF_SET_DEFAULT_VALUES|CANOF_PARSE_DISPLAY_NAME, NULL );
145     ok( hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr );
146     ok( !name, "expected NULL got %p\n", name );
147 
148     name = (IAssemblyName *)0xdeadbeef;
149     hr = CreateAssemblyNameObject( &name, emptyW, CANOF_SET_DEFAULT_VALUES|CANOF_PARSE_DISPLAY_NAME, NULL );
150     ok( hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr );
151     ok( !name, "expected NULL got %p\n", name );
152 
153     name = (IAssemblyName *)0xdeadbeef;
154     hr = CreateAssemblyNameObject( &name, NULL, CANOF_SET_DEFAULT_VALUES|CANOF_PARSE_DISPLAY_NAME, NULL );
155     ok( hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr );
156     ok( !name, "expected NULL got %p\n", name );
157 
158     name = (IAssemblyName *)0xdeadbeef;
159     hr = CreateAssemblyNameObject( &name, emptyW, CANOF_SET_DEFAULT_VALUES|CANOF_PARSE_DISPLAY_NAME, NULL );
160     ok( hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr );
161     ok( !name, "expected NULL got %p\n", name );
162 
163     name = (IAssemblyName *)0xdeadbeef;
164     hr = CreateAssemblyNameObject( &name, wine1W, CANOF_SET_DEFAULT_VALUES|CANOF_PARSE_DISPLAY_NAME, NULL );
165     ok( hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr );
166     ok( !name, "expected NULL got %p\n", name );
167 
168     name = NULL;
169     hr = CreateAssemblyNameObject( &name, wine2W, CANOF_PARSE_DISPLAY_NAME, NULL );
170     ok( hr == S_OK, "expected S_OK got %08x\n", hr );
171     ok( name != NULL, "expected non-NULL name\n" );
172     IAssemblyName_Release( name );
173 
174     name = (IAssemblyName *)0xdeadbeef;
175     hr = CreateAssemblyNameObject( &name, wine3W, CANOF_PARSE_DISPLAY_NAME, NULL );
176     ok( hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr );
177     ok( !name, "expected NULL got %p\n", name );
178 
179     name = (IAssemblyName *)0xdeadbeef;
180     hr = CreateAssemblyNameObject( &name, wine4W, CANOF_PARSE_DISPLAY_NAME, NULL );
181     ok( hr == HRESULT_FROM_WIN32( ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE_NAME ),
182         "expected ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE_NAME got %08x\n", hr );
183     ok( !name, "expected NULL got %p\n", name );
184 
185     name = (IAssemblyName *)0xdeadbeef;
186     hr = CreateAssemblyNameObject( &name, wine5W, CANOF_PARSE_DISPLAY_NAME, NULL );
187     ok( hr == HRESULT_FROM_WIN32( ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE_NAME ),
188         "expected ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE_NAME got %08x\n", hr );
189     ok( !name, "expected NULL got %p\n", name );
190 
191     name = (IAssemblyName *)0xdeadbeef;
192     hr = CreateAssemblyNameObject( &name, wine6W, CANOF_PARSE_DISPLAY_NAME, NULL );
193     ok( hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr );
194     ok( !name, "expected NULL got %p\n", name );
195 
196     name = NULL;
197     hr = CreateAssemblyNameObject( &name, wine7W, CANOF_PARSE_DISPLAY_NAME, NULL );
198     ok( hr == S_OK, "expected S_OK got %08x\n", hr );
199     ok( name != NULL, "expected non-NULL name\n" );
200     IAssemblyName_Release( name );
201 
202     name = (IAssemblyName *)0xdeadbeef;
203     hr = CreateAssemblyNameObject( &name, wine8W, CANOF_PARSE_DISPLAY_NAME, NULL );
204     ok( hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr );
205     ok( !name, "expected NULL got %p\n", name );
206 
207     name = NULL;
208     hr = CreateAssemblyNameObject( &name, wine9W, CANOF_PARSE_DISPLAY_NAME, NULL );
209     ok( hr == S_OK, "expected S_OK got %08x\n", hr );
210     ok( name != NULL, "expected non-NULL name\n" );
211     IAssemblyName_Release( name );
212 
213     name = (IAssemblyName *)0xdeadbeef;
214     hr = CreateAssemblyNameObject( &name, wine10W, CANOF_PARSE_DISPLAY_NAME, NULL );
215     ok( hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr );
216     ok( !name, "expected NULL got %p\n", name );
217 }
218 
219 START_TEST(name)
220 {
221     test_CreateAssemblyNameObject();
222 }
223