2 * Copyright 2007 Hans Leidekker
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.
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.
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
21 #include <wine/test.h>
26 static INT (WINAPI
*pSnmpUtilAsnAnyCpy
)(AsnAny
*, AsnAny
*);
27 static VOID (WINAPI
*pSnmpUtilAsnAnyFree
)(AsnAny
*);
28 static INT (WINAPI
*pSnmpUtilOctetsCmp
)(AsnOctetString
*, AsnOctetString
*);
29 static INT (WINAPI
*pSnmpUtilOctetsCpy
)(AsnOctetString
*, AsnOctetString
*);
30 static VOID (WINAPI
*pSnmpUtilOctetsFree
)(AsnOctetString
*);
31 static INT (WINAPI
*pSnmpUtilOctetsNCmp
)(AsnOctetString
*, AsnOctetString
*, UINT
);
33 static void InitFunctionPtrs(void)
35 HMODULE hSnmpapi
= GetModuleHandle("snmpapi.dll");
37 #define SNMPAPI_GET_PROC(func) \
38 p ## func = (void*)GetProcAddress(hSnmpapi, #func); \
40 trace("GetProcAddress(%s) failed\n", #func);
42 SNMPAPI_GET_PROC(SnmpUtilAsnAnyCpy
)
43 SNMPAPI_GET_PROC(SnmpUtilAsnAnyFree
)
44 SNMPAPI_GET_PROC(SnmpUtilOctetsCmp
)
45 SNMPAPI_GET_PROC(SnmpUtilOctetsCpy
)
46 SNMPAPI_GET_PROC(SnmpUtilOctetsFree
)
47 SNMPAPI_GET_PROC(SnmpUtilOctetsNCmp
)
49 #undef SNMPAPI_GET_PROC
52 static void test_SnmpUtilOidToA(void)
55 static UINT ids1
[] = { 1,3,6,1,4,1,311 };
56 static UINT ids2
[] = {
57 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
58 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
59 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
60 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
61 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
62 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
63 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
64 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
65 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 };
66 static UINT ids3
[] = { 0xffffffff };
67 static AsnObjectIdentifier oid0
= { 0, ids1
};
68 static AsnObjectIdentifier oid1
= { 7, ids1
};
69 static AsnObjectIdentifier oid2
= { 256, ids2
};
70 static AsnObjectIdentifier oid3
= { 257, ids2
};
71 static AsnObjectIdentifier oid4
= { 258, ids2
};
72 static AsnObjectIdentifier oid5
= { 1, ids3
};
73 static const char expect0
[] = "<null oid>";
74 static const char expect1
[] = "1.3.6.1.4.1.311";
75 static const char expect2
[] =
76 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
77 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
78 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
79 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
80 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
81 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
82 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
83 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1";
84 static const char expect3
[] =
85 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
86 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
87 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
88 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
89 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
90 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
91 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."
92 "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1";
93 static const char expect4
[] = "-1";
95 /* This crashes under win98 */
98 ret
= SnmpUtilOidToA(NULL
);
99 ok(ret
!= NULL
, "SnmpUtilOidToA failed\n");
100 ok(!strcmp(ret
, expect0
), "SnmpUtilOidToA failed got \n%s\n expected \n%s\n",
104 ret
= SnmpUtilOidToA(&oid0
);
105 ok(ret
!= NULL
, "SnmpUtilOidToA failed\n");
106 ok(!strcmp(ret
, expect0
), "SnmpUtilOidToA failed got \n%s\n expected \n%s\n",
109 ret
= SnmpUtilOidToA(&oid1
);
110 ok(ret
!= NULL
, "SnmpUtilOidToA failed\n");
111 ok(!strcmp(ret
, expect1
), "SnmpUtilOidToA failed got \n%s\n expected \n%s\n",
114 ret
= SnmpUtilOidToA(&oid2
);
115 ok(ret
!= NULL
, "SnmpUtilOidToA failed\n");
116 ok(!strcmp(ret
, expect2
), "SnmpUtilOidToA failed got \n%s\n expected \n%s\n",
119 ret
= SnmpUtilOidToA(&oid3
);
120 ok(ret
!= NULL
, "SnmpUtilOidToA failed\n");
121 ok(!strcmp(ret
, expect3
), "SnmpUtilOidToA failed got \n%s\n expected \n%s\n",
124 ret
= SnmpUtilOidToA(&oid4
);
125 ok(ret
!= NULL
, "SnmpUtilOidToA failed\n");
126 ok(!strcmp(ret
, expect3
), "SnmpUtilOidToA failed got \n%s\n expected \n%s\n",
129 ret
= SnmpUtilOidToA(&oid5
);
130 ok(ret
!= NULL
, "SnmpUtilOidToA failed\n");
131 ok(!strcmp(ret
, expect4
), "SnmpUtilOidToA failed got \n%s\n expected \n%s\n",
135 static void test_SnmpUtilAsnAnyCpyFree(void)
138 static AsnAny dst
, src
= { ASN_INTEGER
, { 1 } };
140 if (0) { /* these crash on XP */
141 ret
= pSnmpUtilAsnAnyCpy(NULL
, NULL
);
142 ok(!ret
, "SnmpUtilAsnAnyCpy succeeded\n");
144 ret
= pSnmpUtilAsnAnyCpy(&dst
, NULL
);
145 ok(!ret
, "SnmpUtilAsnAnyCpy succeeded\n");
147 ret
= pSnmpUtilAsnAnyCpy(NULL
, &src
);
148 ok(!ret
, "SnmpUtilAsnAnyCpy succeeded\n");
151 ret
= pSnmpUtilAsnAnyCpy(&dst
, &src
);
152 ok(ret
, "SnmpUtilAsnAnyCpy failed\n");
153 ok(!memcmp(&src
, &dst
, sizeof(AsnAny
)), "SnmpUtilAsnAnyCpy failed\n");
155 if (0) { /* crashes on XP */
156 pSnmpUtilAsnAnyFree(NULL
);
158 pSnmpUtilAsnAnyFree(&dst
);
159 ok(dst
.asnType
== ASN_NULL
, "SnmpUtilAsnAnyFree failed\n");
160 ok(dst
.asnValue
.number
== 1, "SnmpUtilAsnAnyFree failed\n");
163 static void test_SnmpUtilOctetsCpyFree(void)
166 static BYTE stream
[] = { '1', '2', '3', '4' };
167 static AsnOctetString dst
, src
= { stream
, 4, TRUE
};
169 ret
= pSnmpUtilOctetsCpy(NULL
, NULL
);
170 ok(!ret
, "SnmpUtilOctetsCpy succeeded\n");
172 memset(&dst
, 1, sizeof(AsnOctetString
));
173 ret
= pSnmpUtilOctetsCpy(&dst
, NULL
);
174 ok(ret
, "SnmpUtilOctetsCpy failed\n");
175 ok(dst
.length
== 0, "SnmpUtilOctetsCpy failed\n");
176 ok(dst
.stream
== NULL
, "SnmpUtilOctetsCpy failed\n");
177 ok(dst
.dynamic
== FALSE
, "SnmpUtilOctetsCpy failed\n");
179 ret
= pSnmpUtilOctetsCpy(NULL
, &src
);
180 ok(!ret
, "SnmpUtilOctetsCpy succeeded\n");
182 memset(&dst
, 0, sizeof(AsnOctetString
));
183 ret
= pSnmpUtilOctetsCpy(&dst
, &src
);
184 ok(ret
, "SnmpUtilOctetsCpy failed\n");
185 ok(src
.length
== dst
.length
, "SnmpUtilOctetsCpy failed\n");
186 ok(!memcmp(src
.stream
, dst
.stream
, dst
.length
), "SnmpUtilOctetsCpy failed\n");
187 ok(dst
.dynamic
== TRUE
, "SnmpUtilOctetsCpy failed\n");
189 pSnmpUtilOctetsFree(NULL
);
190 pSnmpUtilOctetsFree(&dst
);
191 ok(dst
.stream
== NULL
, "SnmpUtilOctetsFree failed\n");
192 ok(dst
.length
== 0, "SnmpUtilOctetsFree failed\n");
193 ok(dst
.dynamic
== FALSE
, "SnmpUtilOctetsFree failed\n");
196 static void test_SnmpUtilOidCpyFree(void)
199 static UINT ids
[] = { 1, 3, 6, 1, 4, 1, 311 };
200 static AsnObjectIdentifier dst
, src
= { sizeof(ids
) / sizeof(ids
[0]), ids
};
202 /* These crashes under win98 */
205 ret
= SnmpUtilOidCpy(NULL
, NULL
);
206 ok(!ret
, "SnmpUtilOidCpy succeeded\n");
208 memset(&dst
, 1, sizeof(AsnObjectIdentifier
));
209 ret
= SnmpUtilOidCpy(&dst
, NULL
);
210 ok(ret
, "SnmpUtilOidCpy failed\n");
211 ok(dst
.idLength
== 0, "SnmpUtilOidCpy failed\n");
212 ok(dst
.ids
== NULL
, "SnmpUtilOidCpy failed\n");
214 ret
= SnmpUtilOidCpy(NULL
, &src
);
215 ok(!ret
, "SnmpUtilOidCpy succeeded\n");
218 memset(&dst
, 0, sizeof(AsnObjectIdentifier
));
219 ret
= SnmpUtilOidCpy(&dst
, &src
);
220 ok(ret
, "SnmpUtilOidCpy failed\n");
221 ok(src
.idLength
== dst
.idLength
, "SnmpUtilOidCpy failed\n");
222 ok(!memcmp(src
.ids
, dst
.ids
, dst
.idLength
* sizeof(UINT
)), "SnmpUtilOidCpy failed\n");
223 SnmpUtilOidFree(&dst
);
225 /* These crashes under win98 */
228 ret
= SnmpUtilOidCpy(NULL
, NULL
);
229 ok(!ret
, "SnmpUtilOidCpy succeeded\n");
231 memset(&dst
, 1, sizeof(AsnObjectIdentifier
));
232 ret
= SnmpUtilOidCpy(&dst
, NULL
);
233 ok(ret
, "SnmpUtilOidCpy failed\n");
234 ok(dst
.idLength
== 0, "SnmpUtilOidCpy failed\n");
235 ok(dst
.ids
== NULL
, "SnmpUtilOidCpy failed\n");
237 ret
= SnmpUtilOidCpy(NULL
, &src
);
238 ok(!ret
, "SnmpUtilOidCpy succeeded\n");
241 memset(&dst
, 0, sizeof(AsnObjectIdentifier
));
242 ret
= SnmpUtilOidCpy(&dst
, &src
);
243 ok(ret
, "SnmpUtilOidCpy failed\n");
244 ok(src
.idLength
== dst
.idLength
, "SnmpUtilOidCpy failed\n");
245 ok(!memcmp(src
.ids
, dst
.ids
, dst
.idLength
* sizeof(UINT
)), "SnmpUtilOidCpy failed\n");
247 /* This crashes under win98 */
250 SnmpUtilOidFree(NULL
);
252 SnmpUtilOidFree(&dst
);
253 ok(dst
.idLength
== 0, "SnmpUtilOidFree failed\n");
254 ok(dst
.ids
== NULL
, "SnmpUtilOidFree failed\n");
257 static void test_SnmpUtilOctetsNCmp(void)
260 static BYTE stream1
[] = { '1', '2', '3', '4' };
261 static BYTE stream2
[] = { '5', '6', '7', '8' };
262 static AsnOctetString octets1
= { stream1
, 4, FALSE
};
263 static AsnOctetString octets2
= { stream2
, 4, FALSE
};
265 ret
= pSnmpUtilOctetsNCmp(NULL
, NULL
, 0);
266 ok(!ret
, "SnmpUtilOctetsNCmp succeeded\n");
268 ret
= pSnmpUtilOctetsNCmp(NULL
, NULL
, 1);
269 ok(!ret
, "SnmpUtilOctetsNCmp succeeded\n");
271 ret
= pSnmpUtilOctetsNCmp(&octets1
, NULL
, 0);
272 ok(!ret
, "SnmpUtilOctetsNCmp succeeded\n");
274 ret
= pSnmpUtilOctetsNCmp(&octets1
, NULL
, 1);
275 ok(!ret
, "SnmpUtilOctetsNCmp succeeded\n");
277 ret
= pSnmpUtilOctetsNCmp(NULL
, &octets2
, 0);
278 ok(!ret
, "SnmpUtilOctetsNCmp succeeded\n");
280 ret
= pSnmpUtilOctetsNCmp(NULL
, &octets2
, 1);
281 ok(!ret
, "SnmpUtilOctetsNCmp succeeded\n");
283 ret
= pSnmpUtilOctetsNCmp(&octets1
, &octets1
, 0);
284 ok(!ret
, "SnmpUtilOctetsNCmp failed\n");
286 ret
= pSnmpUtilOctetsNCmp(&octets1
, &octets1
, 4);
287 ok(!ret
, "SnmpUtilOctetsNCmp failed\n");
289 ret
= pSnmpUtilOctetsNCmp(&octets1
, &octets2
, 4);
290 ok(ret
== -4, "SnmpUtilOctetsNCmp failed\n");
292 ret
= pSnmpUtilOctetsNCmp(&octets2
, &octets1
, 4);
293 ok(ret
== 4, "SnmpUtilOctetsNCmp failed\n");
296 static void test_SnmpUtilOctetsCmp(void)
299 static BYTE stream1
[] = { '1', '2', '3' };
300 static BYTE stream2
[] = { '1', '2', '3', '4' };
301 static AsnOctetString octets1
= { stream1
, 3, FALSE
};
302 static AsnOctetString octets2
= { stream2
, 4, FALSE
};
304 if (0) { /* these crash on XP */
305 ret
= pSnmpUtilOctetsCmp(NULL
, NULL
);
306 ok(!ret
, "SnmpUtilOctetsCmp succeeded\n");
308 ret
= pSnmpUtilOctetsCmp(&octets1
, NULL
);
309 ok(!ret
, "SnmpUtilOctetsCmp succeeded\n");
311 ret
= pSnmpUtilOctetsCmp(NULL
, &octets2
);
312 ok(!ret
, "SnmpUtilOctetsCmp succeeded\n");
315 ret
= pSnmpUtilOctetsCmp(&octets2
, &octets1
);
316 ok(ret
== 1, "SnmpUtilOctetsCmp failed\n");
318 ret
= pSnmpUtilOctetsCmp(&octets1
, &octets2
);
319 ok(ret
== -1, "SnmpUtilOctetsCmp failed\n");
322 static void test_SnmpUtilOidNCmp(void)
325 static UINT ids1
[] = { 1, 2, 3, 4 };
326 static UINT ids2
[] = { 5, 6, 7, 8 };
327 static AsnObjectIdentifier oid1
= { 4, ids1
};
328 static AsnObjectIdentifier oid2
= { 4, ids2
};
330 /* This crashes under win98 */
333 ret
= SnmpUtilOidNCmp(NULL
, NULL
, 0);
334 ok(!ret
, "SnmpUtilOidNCmp succeeded\n");
336 ret
= SnmpUtilOidNCmp(NULL
, NULL
, 1);
337 ok(!ret
, "SnmpUtilOidNCmp succeeded\n");
339 ret
= SnmpUtilOidNCmp(&oid1
, NULL
, 0);
340 ok(!ret
, "SnmpUtilOidNCmp succeeded\n");
342 ret
= SnmpUtilOidNCmp(&oid1
, NULL
, 1);
343 ok(!ret
, "SnmpUtilOidNCmp succeeded\n");
345 ret
= SnmpUtilOidNCmp(NULL
, &oid2
, 0);
346 ok(!ret
, "SnmpUtilOidNCmp succeeded\n");
348 ret
= SnmpUtilOidNCmp(NULL
, &oid2
, 1);
349 ok(!ret
, "SnmpUtilOidNCmp succeeded\n");
352 ret
= SnmpUtilOidNCmp(&oid1
, &oid1
, 0);
353 ok(!ret
, "SnmpUtilOidNCmp failed\n");
355 ret
= SnmpUtilOidNCmp(&oid1
, &oid1
, 4);
356 ok(!ret
, "SnmpUtilOidNCmp failed\n");
358 ret
= SnmpUtilOidNCmp(&oid1
, &oid2
, 4);
359 ok(ret
== -1, "SnmpUtilOidNCmp failed: %d\n", ret
);
361 ret
= SnmpUtilOidNCmp(&oid2
, &oid1
, 4);
362 ok(ret
== 1, "SnmpUtilOidNCmp failed: %d\n", ret
);
365 memcpy(oid1
.ids
, oid2
.ids
, sizeof(UINT
) * 4);
366 ret
= SnmpUtilOidNCmp(&oid1
, &oid1
, 4);
367 ok(!ret
, "SnmpUtilOidNCmp failed: %d\n", ret
);
368 ret
= SnmpUtilOidNCmp(&oid2
, &oid1
, 4);
369 ok(ret
== 1, "SnmpUtilOidNCmp failed: %d\n", ret
);
370 ret
= SnmpUtilOidNCmp(&oid1
, &oid2
, 4);
371 ok(ret
== -1, "SnmpUtilOidNCmp failed: %d\n", ret
);
373 ret
= SnmpUtilOidNCmp(&oid1
, &oid2
, 2);
374 ok(!ret
, "SnmpUtilOidNCmp failed: %d\n", ret
);
375 ret
= SnmpUtilOidNCmp(&oid2
, &oid1
, 2);
376 ok(!ret
, "SnmpUtilOidNCmp failed: %d\n", ret
);
379 static void test_SnmpUtilOidCmp(void)
382 static UINT ids1
[] = { 1, 2, 3 };
383 static UINT ids2
[] = { 1, 2, 3, 4 };
384 static AsnObjectIdentifier oid1
= { 3, ids1
};
385 static AsnObjectIdentifier oid2
= { 4, ids2
};
387 if (0) { /* these crash on XP */
388 ret
= SnmpUtilOidCmp(NULL
, NULL
);
389 ok(!ret
, "SnmpUtilOidCmp succeeded\n");
391 ret
= SnmpUtilOidCmp(&oid1
, NULL
);
392 ok(!ret
, "SnmpUtilOidCmp succeeded\n");
394 ret
= SnmpUtilOidCmp(NULL
, &oid2
);
395 ok(!ret
, "SnmpUtilOidCmp succeeded\n");
398 ret
= SnmpUtilOidCmp(&oid2
, &oid1
);
399 ok(ret
== 1, "SnmpUtilOidCmp failed\n");
401 ret
= SnmpUtilOidCmp(&oid1
, &oid2
);
402 ok(ret
== -1, "SnmpUtilOidCmp failed\n");
405 static void test_SnmpUtilOidAppend(void)
409 static UINT ids2
[] = { 4, 5, 6 };
410 static AsnObjectIdentifier oid1
;
411 static AsnObjectIdentifier oid2
= { 3, ids2
};
413 ids1
= HeapAlloc(GetProcessHeap(), 0, 3 * sizeof(UINT
));
421 /* This crashes under win98 */
424 ret
= SnmpUtilOidAppend(NULL
, NULL
);
425 ok(!ret
, "SnmpUtilOidAppend succeeded\n");
427 ret
= SnmpUtilOidAppend(&oid1
, NULL
);
428 ok(ret
, "SnmpUtilOidAppend failed\n");
430 ret
= SnmpUtilOidAppend(NULL
, &oid2
);
431 ok(!ret
, "SnmpUtilOidAppend succeeded\n");
434 ret
= SnmpUtilOidAppend(&oid1
, &oid2
);
435 ok(ret
, "SnmpUtilOidAppend failed\n");
436 ok(oid1
.idLength
== 6, "SnmpUtilOidAppend failed\n");
437 ok(!memcmp(&oid1
.ids
[3], ids2
, 3 * sizeof(UINT
)),
438 "SnmpUtilOidAppend failed\n");
440 HeapFree(GetProcessHeap(), 0, ids1
);
443 static void test_SnmpUtilVarBindCpyFree(void)
446 static UINT ids
[] = { 1, 3, 6, 1, 4, 1, 311 };
447 static SnmpVarBind dst
, src
= { { 7, ids
}, { ASN_INTEGER
, { 1 } } };
449 /* This crashes under win98 */
452 ret
= SnmpUtilVarBindCpy(NULL
, NULL
);
453 ok(!ret
, "SnmpUtilVarBindCpy succeeded\n");
455 memset(&dst
, 0, sizeof(SnmpVarBind
));
456 ret
= SnmpUtilVarBindCpy(&dst
, NULL
);
457 ok(ret
, "SnmpUtilVarBindCpy failed\n");
458 ok(dst
.name
.idLength
== 0, "SnmpUtilVarBindCpy failed\n");
459 ok(dst
.name
.ids
== NULL
, "SnmpUtilVarBindCpy failed\n");
460 ok(dst
.value
.asnType
== ASN_NULL
, "SnmpUtilVarBindCpy failed\n");
461 ok(dst
.value
.asnValue
.number
== 0, "SnmpUtilVarBindCpy failed\n");
463 ret
= SnmpUtilVarBindCpy(NULL
, &src
);
464 ok(!ret
, "SnmpUtilVarBindCpy succeeded\n");
467 memset(&dst
, 0, sizeof(SnmpVarBind
));
468 ret
= SnmpUtilVarBindCpy(&dst
, &src
);
469 ok(ret
, "SnmpUtilVarBindCpy failed\n");
470 ok(src
.name
.idLength
== dst
.name
.idLength
, "SnmpUtilVarBindCpy failed\n");
471 ok(!memcmp(src
.name
.ids
, dst
.name
.ids
, dst
.name
.idLength
* sizeof(UINT
)),
472 "SnmpUtilVarBindCpy failed\n");
473 ok(!memcmp(&src
.value
, &dst
.value
, sizeof(AsnObjectSyntax
)),
474 "SnmpUtilVarBindCpy failed\n");
476 /* This crashes under win98 */
479 SnmpUtilVarBindFree(NULL
);
481 SnmpUtilVarBindFree(&dst
);
482 ok(dst
.name
.idLength
== 0, "SnmpUtilVarBindFree failed\n");
483 ok(dst
.name
.ids
== NULL
, "SnmpUtilVarBindFree failed\n");
484 ok(dst
.value
.asnType
== ASN_NULL
, "SnmpUtilVarBindFree failed\n");
485 ok(dst
.value
.asnValue
.number
== 1, "SnmpUtilVarBindFree failed\n");
488 static void test_SnmpUtilVarBindListCpyFree(void)
491 static UINT ids
[] = { 1, 3, 6, 1, 4, 1, 311 };
492 static SnmpVarBind src
= { { 7, ids
}, { ASN_INTEGER
, { 1 } } };
493 static SnmpVarBindList dst_list
, src_list
= { &src
, 1 };
495 if (0) { /* these crash on XP */
496 ret
= SnmpUtilVarBindListCpy(NULL
, NULL
);
497 ok(!ret
, "SnmpUtilVarBindCpy succeeded\n");
499 ret
= SnmpUtilVarBindListCpy(NULL
, &src_list
);
500 ok(!ret
, "SnmpUtilVarBindListCpy succeeded\n");
503 /* This crashes under win98 */
506 memset(&dst_list
, 0xff, sizeof(SnmpVarBindList
));
507 ret
= SnmpUtilVarBindListCpy(&dst_list
, NULL
);
508 ok(ret
, "SnmpUtilVarBindListCpy failed\n");
509 ok(dst_list
.list
== NULL
, "SnmpUtilVarBindListCpy failed\n");
510 ok(dst_list
.len
== 0, "SnmpUtilVarBindListCpy failed\n");
513 ret
= SnmpUtilVarBindListCpy(&dst_list
, &src_list
);
514 ok(ret
, "SnmpUtilVarBindListCpy failed\n");
515 ok(src_list
.len
== dst_list
.len
, "SnmpUtilVarBindListCpy failed\n");
516 ok(src_list
.list
->name
.idLength
== dst_list
.list
->name
.idLength
,
517 "SnmpUtilVarBindListCpy failed\n");
518 ok(!memcmp(src_list
.list
->name
.ids
, dst_list
.list
->name
.ids
,
519 dst_list
.list
->name
.idLength
* sizeof(UINT
)),
520 "SnmpUtilVarBindListCpy failed\n");
521 ok(!memcmp(&src_list
.list
->value
, &dst_list
.list
->value
, sizeof(AsnAny
)),
522 "SnmpUtilVarBindListCpy failed\n");
524 if (0) { /* crashes on XP */
525 SnmpUtilVarBindListFree(NULL
);
527 SnmpUtilVarBindListFree(&dst_list
);
528 ok(dst_list
.list
== NULL
, "SnmpUtilVarBindListFree failed\n");
529 ok(dst_list
.len
== 0, "SnmpUtilVarBindListFree failed\n");
536 test_SnmpUtilOidToA();
538 if (!pSnmpUtilAsnAnyCpy
|| !pSnmpUtilAsnAnyFree
)
539 skip("SnmpUtilAsnAnyCpy and/or SnmpUtilAsnAnyFree not available\n");
541 test_SnmpUtilAsnAnyCpyFree();
543 if (!pSnmpUtilOctetsCpy
|| !pSnmpUtilOctetsFree
)
544 skip("SnmpUtilOctetsCpy and/or SnmpUtilOctetsFree not available\n");
546 test_SnmpUtilOctetsCpyFree();
548 test_SnmpUtilOidCpyFree();
550 if (!pSnmpUtilOctetsNCmp
)
551 skip("SnmpUtilOctetsNCmp not available\n");
553 test_SnmpUtilOctetsNCmp();
555 if (!pSnmpUtilOctetsCmp
)
556 skip("SnmpUtilOctetsCmp not available\n");
558 test_SnmpUtilOctetsCmp();
560 test_SnmpUtilOidCmp();
561 test_SnmpUtilOidNCmp();
562 test_SnmpUtilOidAppend();
563 test_SnmpUtilVarBindCpyFree();
564 test_SnmpUtilVarBindListCpyFree();