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");
224 /* These crashes under win98 */
227 ret
= SnmpUtilOidCpy(NULL
, NULL
);
228 ok(!ret
, "SnmpUtilOidCpy succeeded\n");
230 memset(&dst
, 1, sizeof(AsnObjectIdentifier
));
231 ret
= SnmpUtilOidCpy(&dst
, NULL
);
232 ok(ret
, "SnmpUtilOidCpy failed\n");
233 ok(dst
.idLength
== 0, "SnmpUtilOidCpy failed\n");
234 ok(dst
.ids
== NULL
, "SnmpUtilOidCpy failed\n");
236 ret
= SnmpUtilOidCpy(NULL
, &src
);
237 ok(!ret
, "SnmpUtilOidCpy succeeded\n");
240 memset(&dst
, 0, sizeof(AsnObjectIdentifier
));
241 ret
= SnmpUtilOidCpy(&dst
, &src
);
242 ok(ret
, "SnmpUtilOidCpy failed\n");
243 ok(src
.idLength
== dst
.idLength
, "SnmpUtilOidCpy failed\n");
244 ok(!memcmp(src
.ids
, dst
.ids
, dst
.idLength
* sizeof(UINT
)), "SnmpUtilOidCpy failed\n");
246 /* This crashes under win98 */
249 SnmpUtilOidFree(NULL
);
251 SnmpUtilOidFree(&dst
);
252 ok(dst
.idLength
== 0, "SnmpUtilOidFree failed\n");
253 ok(dst
.ids
== NULL
, "SnmpUtilOidFree failed\n");
256 static void test_SnmpUtilOctetsNCmp(void)
259 static BYTE stream1
[] = { '1', '2', '3', '4' };
260 static BYTE stream2
[] = { '5', '6', '7', '8' };
261 static AsnOctetString octets1
= { stream1
, 4, FALSE
};
262 static AsnOctetString octets2
= { stream2
, 4, FALSE
};
264 ret
= pSnmpUtilOctetsNCmp(NULL
, NULL
, 0);
265 ok(!ret
, "SnmpUtilOctetsNCmp succeeded\n");
267 ret
= pSnmpUtilOctetsNCmp(NULL
, NULL
, 1);
268 ok(!ret
, "SnmpUtilOctetsNCmp succeeded\n");
270 ret
= pSnmpUtilOctetsNCmp(&octets1
, NULL
, 0);
271 ok(!ret
, "SnmpUtilOctetsNCmp succeeded\n");
273 ret
= pSnmpUtilOctetsNCmp(&octets1
, NULL
, 1);
274 ok(!ret
, "SnmpUtilOctetsNCmp succeeded\n");
276 ret
= pSnmpUtilOctetsNCmp(NULL
, &octets2
, 0);
277 ok(!ret
, "SnmpUtilOctetsNCmp succeeded\n");
279 ret
= pSnmpUtilOctetsNCmp(NULL
, &octets2
, 1);
280 ok(!ret
, "SnmpUtilOctetsNCmp succeeded\n");
282 ret
= pSnmpUtilOctetsNCmp(&octets1
, &octets1
, 0);
283 ok(!ret
, "SnmpUtilOctetsNCmp failed\n");
285 ret
= pSnmpUtilOctetsNCmp(&octets1
, &octets1
, 4);
286 ok(!ret
, "SnmpUtilOctetsNCmp failed\n");
288 ret
= pSnmpUtilOctetsNCmp(&octets1
, &octets2
, 4);
289 ok(ret
== -4, "SnmpUtilOctetsNCmp failed\n");
291 ret
= pSnmpUtilOctetsNCmp(&octets2
, &octets1
, 4);
292 ok(ret
== 4, "SnmpUtilOctetsNCmp failed\n");
295 static void test_SnmpUtilOctetsCmp(void)
298 static BYTE stream1
[] = { '1', '2', '3' };
299 static BYTE stream2
[] = { '1', '2', '3', '4' };
300 static AsnOctetString octets1
= { stream1
, 3, FALSE
};
301 static AsnOctetString octets2
= { stream2
, 4, FALSE
};
303 if (0) { /* these crash on XP */
304 ret
= pSnmpUtilOctetsCmp(NULL
, NULL
);
305 ok(!ret
, "SnmpUtilOctetsCmp succeeded\n");
307 ret
= pSnmpUtilOctetsCmp(&octets1
, NULL
);
308 ok(!ret
, "SnmpUtilOctetsCmp succeeded\n");
310 ret
= pSnmpUtilOctetsCmp(NULL
, &octets2
);
311 ok(!ret
, "SnmpUtilOctetsCmp succeeded\n");
314 ret
= pSnmpUtilOctetsCmp(&octets2
, &octets1
);
315 ok(ret
== 1, "SnmpUtilOctetsCmp failed\n");
317 ret
= pSnmpUtilOctetsCmp(&octets1
, &octets2
);
318 ok(ret
== -1, "SnmpUtilOctetsCmp failed\n");
321 static void test_SnmpUtilOidNCmp(void)
324 static UINT ids1
[] = { 1, 2, 3, 4 };
325 static UINT ids2
[] = { 5, 6, 7, 8 };
326 static AsnObjectIdentifier oid1
= { 4, ids1
};
327 static AsnObjectIdentifier oid2
= { 4, ids2
};
329 /* This crashes under win98 */
332 ret
= SnmpUtilOidNCmp(NULL
, NULL
, 0);
333 ok(!ret
, "SnmpUtilOidNCmp succeeded\n");
335 ret
= SnmpUtilOidNCmp(NULL
, NULL
, 1);
336 ok(!ret
, "SnmpUtilOidNCmp succeeded\n");
338 ret
= SnmpUtilOidNCmp(&oid1
, NULL
, 0);
339 ok(!ret
, "SnmpUtilOidNCmp succeeded\n");
341 ret
= SnmpUtilOidNCmp(&oid1
, NULL
, 1);
342 ok(!ret
, "SnmpUtilOidNCmp succeeded\n");
344 ret
= SnmpUtilOidNCmp(NULL
, &oid2
, 0);
345 ok(!ret
, "SnmpUtilOidNCmp succeeded\n");
347 ret
= SnmpUtilOidNCmp(NULL
, &oid2
, 1);
348 ok(!ret
, "SnmpUtilOidNCmp succeeded\n");
351 ret
= SnmpUtilOidNCmp(&oid1
, &oid1
, 0);
352 ok(!ret
, "SnmpUtilOidNCmp failed\n");
354 ret
= SnmpUtilOidNCmp(&oid1
, &oid1
, 4);
355 ok(!ret
, "SnmpUtilOidNCmp failed\n");
357 ret
= SnmpUtilOidNCmp(&oid1
, &oid2
, 4);
358 ok(ret
== -1, "SnmpUtilOidNCmp failed: %d\n", ret
);
360 ret
= SnmpUtilOidNCmp(&oid2
, &oid1
, 4);
361 ok(ret
== 1, "SnmpUtilOidNCmp failed: %d\n", ret
);
364 memcpy(oid1
.ids
, oid2
.ids
, sizeof(UINT
) * 4);
365 ret
= SnmpUtilOidNCmp(&oid1
, &oid1
, 4);
366 ok(!ret
, "SnmpUtilOidNCmp failed: %d\n", ret
);
367 ret
= SnmpUtilOidNCmp(&oid2
, &oid1
, 4);
368 ok(ret
== 1, "SnmpUtilOidNCmp failed: %d\n", ret
);
369 ret
= SnmpUtilOidNCmp(&oid1
, &oid2
, 4);
370 ok(ret
== -1, "SnmpUtilOidNCmp failed: %d\n", ret
);
372 ret
= SnmpUtilOidNCmp(&oid1
, &oid2
, 2);
373 ok(!ret
, "SnmpUtilOidNCmp failed: %d\n", ret
);
374 ret
= SnmpUtilOidNCmp(&oid2
, &oid1
, 2);
375 ok(!ret
, "SnmpUtilOidNCmp failed: %d\n", ret
);
378 static void test_SnmpUtilOidCmp(void)
381 static UINT ids1
[] = { 1, 2, 3 };
382 static UINT ids2
[] = { 1, 2, 3, 4 };
383 static AsnObjectIdentifier oid1
= { 3, ids1
};
384 static AsnObjectIdentifier oid2
= { 4, ids2
};
386 if (0) { /* these crash on XP */
387 ret
= SnmpUtilOidCmp(NULL
, NULL
);
388 ok(!ret
, "SnmpUtilOidCmp succeeded\n");
390 ret
= SnmpUtilOidCmp(&oid1
, NULL
);
391 ok(!ret
, "SnmpUtilOidCmp succeeded\n");
393 ret
= SnmpUtilOidCmp(NULL
, &oid2
);
394 ok(!ret
, "SnmpUtilOidCmp succeeded\n");
397 ret
= SnmpUtilOidCmp(&oid2
, &oid1
);
398 ok(ret
== 1, "SnmpUtilOidCmp failed\n");
400 ret
= SnmpUtilOidCmp(&oid1
, &oid2
);
401 ok(ret
== -1, "SnmpUtilOidCmp failed\n");
404 static void test_SnmpUtilOidAppend(void)
408 static UINT ids2
[] = { 4, 5, 6 };
409 static AsnObjectIdentifier oid1
;
410 static AsnObjectIdentifier oid2
= { 3, ids2
};
412 ids1
= HeapAlloc(GetProcessHeap(), 0, 3 * sizeof(UINT
));
420 /* This crashes under win98 */
423 ret
= SnmpUtilOidAppend(NULL
, NULL
);
424 ok(!ret
, "SnmpUtilOidAppend succeeded\n");
426 ret
= SnmpUtilOidAppend(&oid1
, NULL
);
427 ok(ret
, "SnmpUtilOidAppend failed\n");
429 ret
= SnmpUtilOidAppend(NULL
, &oid2
);
430 ok(!ret
, "SnmpUtilOidAppend succeeded\n");
433 ret
= SnmpUtilOidAppend(&oid1
, &oid2
);
434 ok(ret
, "SnmpUtilOidAppend failed\n");
435 ok(oid1
.idLength
== 6, "SnmpUtilOidAppend failed\n");
436 ok(!memcmp(&oid1
.ids
[3], ids2
, 3 * sizeof(UINT
)),
437 "SnmpUtilOidAppend failed\n");
439 HeapFree(GetProcessHeap(), 0, ids1
);
442 static void test_SnmpUtilVarBindCpyFree(void)
445 static UINT ids
[] = { 1, 3, 6, 1, 4, 1, 311 };
446 static SnmpVarBind dst
, src
= { { 7, ids
}, { ASN_INTEGER
, { 1 } } };
448 /* This crashes under win98 */
451 ret
= SnmpUtilVarBindCpy(NULL
, NULL
);
452 ok(!ret
, "SnmpUtilVarBindCpy succeeded\n");
454 memset(&dst
, 0, sizeof(SnmpVarBind
));
455 ret
= SnmpUtilVarBindCpy(&dst
, NULL
);
456 ok(ret
, "SnmpUtilVarBindCpy failed\n");
457 ok(dst
.name
.idLength
== 0, "SnmpUtilVarBindCpy failed\n");
458 ok(dst
.name
.ids
== NULL
, "SnmpUtilVarBindCpy failed\n");
459 ok(dst
.value
.asnType
== ASN_NULL
, "SnmpUtilVarBindCpy failed\n");
460 ok(dst
.value
.asnValue
.number
== 0, "SnmpUtilVarBindCpy failed\n");
462 ret
= SnmpUtilVarBindCpy(NULL
, &src
);
463 ok(!ret
, "SnmpUtilVarBindCpy succeeded\n");
466 memset(&dst
, 0, sizeof(SnmpVarBind
));
467 ret
= SnmpUtilVarBindCpy(&dst
, &src
);
468 ok(ret
, "SnmpUtilVarBindCpy failed\n");
469 ok(src
.name
.idLength
== dst
.name
.idLength
, "SnmpUtilVarBindCpy failed\n");
470 ok(!memcmp(src
.name
.ids
, dst
.name
.ids
, dst
.name
.idLength
* sizeof(UINT
)),
471 "SnmpUtilVarBindCpy failed\n");
472 ok(!memcmp(&src
.value
, &dst
.value
, sizeof(AsnObjectSyntax
)),
473 "SnmpUtilVarBindCpy failed\n");
475 /* This crashes under win98 */
478 SnmpUtilVarBindFree(NULL
);
480 SnmpUtilVarBindFree(&dst
);
481 ok(dst
.name
.idLength
== 0, "SnmpUtilVarBindFree failed\n");
482 ok(dst
.name
.ids
== NULL
, "SnmpUtilVarBindFree failed\n");
483 ok(dst
.value
.asnType
== ASN_NULL
, "SnmpUtilVarBindFree failed\n");
484 ok(dst
.value
.asnValue
.number
== 1, "SnmpUtilVarBindFree failed\n");
487 static void test_SnmpUtilVarBindListCpyFree(void)
490 static UINT ids
[] = { 1, 3, 6, 1, 4, 1, 311 };
491 static SnmpVarBind src
= { { 7, ids
}, { ASN_INTEGER
, { 1 } } };
492 static SnmpVarBindList dst_list
, src_list
= { &src
, 1 };
494 if (0) { /* these crash on XP */
495 ret
= SnmpUtilVarBindListCpy(NULL
, NULL
);
496 ok(!ret
, "SnmpUtilVarBindCpy succeeded\n");
498 ret
= SnmpUtilVarBindListCpy(NULL
, &src_list
);
499 ok(!ret
, "SnmpUtilVarBindListCpy succeeded\n");
502 /* This crashes under win98 */
505 memset(&dst_list
, 0xff, sizeof(SnmpVarBindList
));
506 ret
= SnmpUtilVarBindListCpy(&dst_list
, NULL
);
507 ok(ret
, "SnmpUtilVarBindListCpy failed\n");
508 ok(dst_list
.list
== NULL
, "SnmpUtilVarBindListCpy failed\n");
509 ok(dst_list
.len
== 0, "SnmpUtilVarBindListCpy failed\n");
512 ret
= SnmpUtilVarBindListCpy(&dst_list
, &src_list
);
513 ok(ret
, "SnmpUtilVarBindListCpy failed\n");
514 ok(src_list
.len
== dst_list
.len
, "SnmpUtilVarBindListCpy failed\n");
515 ok(src_list
.list
->name
.idLength
== dst_list
.list
->name
.idLength
,
516 "SnmpUtilVarBindListCpy failed\n");
517 ok(!memcmp(src_list
.list
->name
.ids
, dst_list
.list
->name
.ids
,
518 dst_list
.list
->name
.idLength
* sizeof(UINT
)),
519 "SnmpUtilVarBindListCpy failed\n");
520 ok(!memcmp(&src_list
.list
->value
, &dst_list
.list
->value
, sizeof(AsnAny
)),
521 "SnmpUtilVarBindListCpy failed\n");
523 if (0) { /* crashes on XP */
524 SnmpUtilVarBindListFree(NULL
);
526 SnmpUtilVarBindListFree(&dst_list
);
527 ok(dst_list
.list
== NULL
, "SnmpUtilVarBindListFree failed\n");
528 ok(dst_list
.len
== 0, "SnmpUtilVarBindListFree failed\n");
535 test_SnmpUtilOidToA();
537 if (!pSnmpUtilAsnAnyCpy
|| !pSnmpUtilAsnAnyFree
)
538 skip("SnmpUtilAsnAnyCpy and/or SnmpUtilAsnAnyFree not available\n");
540 test_SnmpUtilAsnAnyCpyFree();
542 if (!pSnmpUtilOctetsCpy
|| !pSnmpUtilOctetsFree
)
543 skip("SnmpUtilOctetsCpy and/or SnmpUtilOctetsFree not available\n");
545 test_SnmpUtilOctetsCpyFree();
547 test_SnmpUtilOidCpyFree();
549 if (!pSnmpUtilOctetsNCmp
)
550 skip("SnmpUtilOctetsNCmp not available\n");
552 test_SnmpUtilOctetsNCmp();
554 if (!pSnmpUtilOctetsCmp
)
555 skip("SnmpUtilOctetsCmp not available\n");
557 test_SnmpUtilOctetsCmp();
559 test_SnmpUtilOidCmp();
560 test_SnmpUtilOidNCmp();
561 test_SnmpUtilOidAppend();
562 test_SnmpUtilVarBindCpyFree();
563 test_SnmpUtilVarBindListCpyFree();