1 /* Unit test suite for Rtl bitmap functions
3 * Copyright 2002 Jon Griffiths
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * We use function pointers here as some of the bitmap functions exist only
21 * in later versions of ntdll.
23 #include "wine/test.h"
28 /* Function ptrs for ordinal calls */
29 static HMODULE hntdll
= 0;
30 static VOID (WINAPI
*pRtlInitializeBitMap
)(PRTL_BITMAP
,LPBYTE
,ULONG
);
31 static VOID (WINAPI
*pRtlSetAllBits
)(PRTL_BITMAP
);
32 static VOID (WINAPI
*pRtlClearAllBits
)(PRTL_BITMAP
);
33 static VOID (WINAPI
*pRtlSetBits
)(PRTL_BITMAP
,ULONG
,ULONG
);
34 static VOID (WINAPI
*pRtlClearBits
)(PRTL_BITMAP
,ULONG
,ULONG
);
35 static BOOLEAN (WINAPI
*pRtlAreBitsSet
)(PRTL_BITMAP
,ULONG
,ULONG
);
36 static BOOLEAN (WINAPI
*pRtlAreBitsClear
)(PRTL_BITMAP
,ULONG
,ULONG
);
37 static ULONG (WINAPI
*pRtlFindSetBitsAndClear
)(PRTL_BITMAP
,ULONG
,ULONG
);
38 static ULONG (WINAPI
*pRtlFindClearBitsAndSet
)(PRTL_BITMAP
,ULONG
,ULONG
);
39 static CCHAR (WINAPI
*pRtlFindMostSignificantBit
)(ULONGLONG
);
40 static CCHAR (WINAPI
*pRtlFindLeastSignificantBit
)(ULONGLONG
);
41 static ULONG (WINAPI
*pRtlFindSetRuns
)(PRTL_BITMAP
,PRTL_BITMAP_RUN
,ULONG
,BOOLEAN
);
42 static ULONG (WINAPI
*pRtlFindClearRuns
)(PRTL_BITMAP
,PRTL_BITMAP_RUN
,ULONG
,BOOLEAN
);
43 static ULONG (WINAPI
*pRtlNumberOfSetBits
)(PRTL_BITMAP
);
44 static ULONG (WINAPI
*pRtlNumberOfClearBits
)(PRTL_BITMAP
);
45 static ULONG (WINAPI
*pRtlFindLongestRunSet
)(PRTL_BITMAP
,PULONG
);
46 static ULONG (WINAPI
*pRtlFindLongestRunClear
)(PRTL_BITMAP
,PULONG
);
48 static BYTE buff
[256];
51 static void InitFunctionPtrs()
53 hntdll
= LoadLibraryA("ntdll.dll");
54 ok(hntdll
!= 0, "LoadLibrary failed");
57 pRtlInitializeBitMap
= (void *)GetProcAddress(hntdll
, "RtlInitializeBitMap");
58 pRtlSetAllBits
= (void *)GetProcAddress(hntdll
, "RtlSetAllBits");
59 pRtlClearAllBits
= (void *)GetProcAddress(hntdll
, "RtlClearAllBits");
60 pRtlSetBits
= (void *)GetProcAddress(hntdll
, "RtlSetBits");
61 pRtlClearBits
= (void *)GetProcAddress(hntdll
, "RtlClearBits");
62 pRtlAreBitsSet
= (void *)GetProcAddress(hntdll
, "RtlAreBitsSet");
63 pRtlAreBitsClear
= (void *)GetProcAddress(hntdll
, "RtlAreBitsClear");
64 pRtlNumberOfSetBits
= (void *)GetProcAddress(hntdll
, "RtlNumberOfSetBits");
65 pRtlNumberOfClearBits
= (void *)GetProcAddress(hntdll
, "RtlNumberOfClearBits");
66 pRtlFindSetBitsAndClear
= (void *)GetProcAddress(hntdll
, "RtlFindSetBitsAndClear");
67 pRtlFindClearBitsAndSet
= (void *)GetProcAddress(hntdll
, "RtlFindClearBitsAndSet");
68 pRtlFindMostSignificantBit
= (void *)GetProcAddress(hntdll
, "RtlFindMostSignificantBit");
69 pRtlFindLeastSignificantBit
= (void *)GetProcAddress(hntdll
, "RtlFindLeastSignificantBit");
70 pRtlFindSetRuns
= (void *)GetProcAddress(hntdll
, "RtlFindSetRuns");
71 pRtlFindClearRuns
= (void *)GetProcAddress(hntdll
, "RtlFindClearRuns");
72 pRtlFindLongestRunSet
= (void *)GetProcAddress(hntdll
, "RtlFindLongestRunSet");
73 pRtlFindLongestRunClear
= (void *)GetProcAddress(hntdll
, "RtlFindLongestRunClear");
77 static void test_RtlInitializeBitMap(void)
82 memset(buff
, 0, sizeof(buff
));
83 buff
[0] = 77; /* Check buffer is not written to during init */
86 pRtlInitializeBitMap(&bm
, buff
, 800);
87 ok(bm
.SizeOfBitMap
== 800, "size uninitialised");
88 ok(bm
.BitMapBuffer
== buff
,"buffer uninitialised");
89 ok(buff
[0] == 77 && buff
[79] == 77, "wrote to buffer");
91 /* Test inlined version */
92 RtlInitializeBitMap(&bm
, buff
, 800);
93 ok(bm
.SizeOfBitMap
== 800, "size uninitialised");
94 ok(bm
.BitMapBuffer
== buff
,"buffer uninitialised");
95 ok(buff
[0] == 77 && buff
[79] == 77, "wrote to buffer");
98 static void test_RtlSetAllBits(void)
103 memset(buff
, 0 , sizeof(buff
));
104 pRtlInitializeBitMap(&bm
, buff
, 1);
107 ok(buff
[0] == 0xff && buff
[1] == 0xff && buff
[2] == 0xff &&
108 buff
[3] == 0xff, "didnt round up size");
109 ok(buff
[4] == 0, "set more than rounded size");
111 /* Test inlined version */
112 memset(buff
, 0 , sizeof(buff
));
114 ok(buff
[0] == 0xff && buff
[1] == 0xff && buff
[2] == 0xff &&
115 buff
[3] == 0xff, "didnt round up size");
116 ok(buff
[4] == 0, "set more than rounded size");
119 static void test_RtlClearAllBits()
121 if (!pRtlClearAllBits
)
124 memset(buff
, 0xff , sizeof(buff
));
125 pRtlInitializeBitMap(&bm
, buff
, 1);
127 pRtlClearAllBits(&bm
);
128 ok(!buff
[0] && !buff
[1] && !buff
[2] && !buff
[3], "didnt round up size");
129 ok(buff
[4] == 0xff, "cleared more than rounded size");
131 /* Test inlined version */
132 memset(buff
, 0xff , sizeof(buff
));
133 RtlClearAllBits(&bm
);
134 ok(!buff
[0] && !buff
[1] && !buff
[2] && !buff
[3] , "didnt round up size");
135 ok(buff
[4] == 0xff, "cleared more than rounded size");
138 static void test_RtlSetBits()
143 memset(buff
, 0 , sizeof(buff
));
144 pRtlInitializeBitMap(&bm
, buff
, sizeof(buff
)*8);
146 pRtlSetBits(&bm
, 0, 1);
147 ok(buff
[0] == 1, "didnt set 1st bit");
150 pRtlSetBits(&bm
, 7, 2);
151 ok(buff
[0] == 0x80 && buff
[1] == 1, "didnt span w/len < 8");
153 buff
[0] = buff
[1] = 0;
154 pRtlSetBits(&bm
, 7, 10);
155 ok(buff
[0] == 0x80 && buff
[1] == 0xff && buff
[2] == 1, "didnt span w/len > 8");
157 buff
[0] = buff
[1] = buff
[2] = 0;
158 pRtlSetBits(&bm
, 0, 8); /* 1st byte */
159 ok(buff
[0] == 0xff, "didnt set all bits");
160 ok(!buff
[1], "set too many bits");
162 pRtlSetBits(&bm
, sizeof(buff
)*8-1, 1); /* last bit */
163 ok(buff
[sizeof(buff
)-1] == 0x80, "didnt set last bit");
166 static void test_RtlClearBits()
171 memset(buff
, 0xff , sizeof(buff
));
172 pRtlInitializeBitMap(&bm
, buff
, sizeof(buff
)*8);
174 pRtlClearBits(&bm
, 0, 1);
175 ok(buff
[0] == 0xfe, "didnt clear 1st bit");
178 pRtlClearBits(&bm
, 7, 2);
179 ok(buff
[0] == 0x7f && buff
[1] == 0xfe, "didnt span w/len < 8");
181 buff
[0] = buff
[1] = 0xff;
182 pRtlClearBits(&bm
, 7, 10);
183 ok(buff
[0] == 0x7f && buff
[1] == 0 && buff
[2] == 0xfe, "didnt span w/len > 8");
185 buff
[0] = buff
[1] = buff
[2] = 0xff;
186 pRtlClearBits(&bm
, 0, 8); /* 1st byte */
187 ok(!buff
[0], "didnt clear all bits");
188 ok(buff
[1] == 0xff, "cleared too many bits");
190 pRtlClearBits(&bm
, sizeof(buff
)*8-1, 1);
191 ok(buff
[sizeof(buff
)-1] == 0x7f, "didnt set last bit");
194 static void test_RtlCheckBit()
198 memset(buff
, 0 , sizeof(buff
));
199 pRtlInitializeBitMap(&bm
, buff
, sizeof(buff
)*8);
200 pRtlSetBits(&bm
, 0, 1);
201 pRtlSetBits(&bm
, 7, 2);
202 pRtlSetBits(&bm
, sizeof(buff
)*8-1, 1);
204 bRet
= RtlCheckBit(&bm
, 0);
205 ok (bRet
, "didnt find set bit");
206 bRet
= RtlCheckBit(&bm
, 7);
207 ok (bRet
, "didnt find set bit");
208 bRet
= RtlCheckBit(&bm
, 8);
209 ok (bRet
, "didnt find set bit");
210 bRet
= RtlCheckBit(&bm
, sizeof(buff
)*8-1);
211 ok (bRet
, "didnt find set bit");
212 bRet
= RtlCheckBit(&bm
, 1);
213 ok (!bRet
, "found non set bit");
214 bRet
= RtlCheckBit(&bm
, sizeof(buff
)*8-2);
215 ok (!bRet
, "found non set bit");
218 static void test_RtlAreBitsSet()
225 memset(buff
, 0 , sizeof(buff
));
226 pRtlInitializeBitMap(&bm
, buff
, sizeof(buff
)*8);
228 bRet
= pRtlAreBitsSet(&bm
, 0, 1);
229 ok (!bRet
, "found set bits after init");
231 pRtlSetBits(&bm
, 0, 1);
232 bRet
= pRtlAreBitsSet(&bm
, 0, 1);
233 ok (bRet
, "didnt find set bits");
236 pRtlSetBits(&bm
, 7, 2);
237 bRet
= pRtlAreBitsSet(&bm
, 7, 2);
238 ok(bRet
, "didnt find w/len < 8");
239 bRet
= pRtlAreBitsSet(&bm
, 6, 3);
240 ok(!bRet
, "found non set bit");
241 bRet
= pRtlAreBitsSet(&bm
, 7, 3);
242 ok(!bRet
, "found non set bit");
244 buff
[0] = buff
[1] = 0;
245 pRtlSetBits(&bm
, 7, 10);
246 bRet
= pRtlAreBitsSet(&bm
, 7, 10);
247 ok(bRet
, "didnt find w/len < 8");
248 bRet
= pRtlAreBitsSet(&bm
, 6, 11);
249 ok(!bRet
, "found non set bit");
250 bRet
= pRtlAreBitsSet(&bm
, 7, 11);
251 ok(!bRet
, "found non set bit");
253 buff
[0] = buff
[1] = buff
[2] = 0;
254 pRtlSetBits(&bm
, 0, 8); /* 1st byte */
255 bRet
= pRtlAreBitsSet(&bm
, 0, 8);
256 ok(bRet
, "didn't find whole byte");
258 pRtlSetBits(&bm
, sizeof(buff
)*8-1, 1);
259 bRet
= pRtlAreBitsSet(&bm
, sizeof(buff
)*8-1, 1);
260 ok(bRet
, "didn't find last bit");
263 static void test_RtlAreBitsClear()
267 if (!pRtlAreBitsClear
)
270 memset(buff
, 0xff , sizeof(buff
));
271 pRtlInitializeBitMap(&bm
, buff
, sizeof(buff
)*8);
273 bRet
= pRtlAreBitsClear(&bm
, 0, 1);
274 ok (!bRet
, "found clear bits after init");
276 pRtlClearBits(&bm
, 0, 1);
277 bRet
= pRtlAreBitsClear(&bm
, 0, 1);
278 ok (bRet
, "didnt find set bits");
281 pRtlClearBits(&bm
, 7, 2);
282 bRet
= pRtlAreBitsClear(&bm
, 7, 2);
283 ok(bRet
, "didnt find w/len < 8");
284 bRet
= pRtlAreBitsClear(&bm
, 6, 3);
285 ok(!bRet
, "found non clear bit");
286 bRet
= pRtlAreBitsClear(&bm
, 7, 3);
287 ok(!bRet
, "found non clear bit");
289 buff
[0] = buff
[1] = 0xff;
290 pRtlClearBits(&bm
, 7, 10);
291 bRet
= pRtlAreBitsClear(&bm
, 7, 10);
292 ok(bRet
, "didnt find w/len < 8");
293 bRet
= pRtlAreBitsClear(&bm
, 6, 11);
294 ok(!bRet
, "found non clear bit");
295 bRet
= pRtlAreBitsClear(&bm
, 7, 11);
296 ok(!bRet
, "found non clear bit");
298 buff
[0] = buff
[1] = buff
[2] = 0xff;
299 pRtlClearBits(&bm
, 0, 8); /* 1st byte */
300 bRet
= pRtlAreBitsClear(&bm
, 0, 8);
301 ok(bRet
, "didn't find whole byte");
303 pRtlClearBits(&bm
, sizeof(buff
)*8-1, 1);
304 bRet
= pRtlAreBitsClear(&bm
, sizeof(buff
)*8-1, 1);
305 ok(bRet
, "didn't find last bit");
308 static void test_RtlNumberOfSetBits()
312 if (!pRtlNumberOfSetBits
)
315 memset(buff
, 0 , sizeof(buff
));
316 pRtlInitializeBitMap(&bm
, buff
, sizeof(buff
)*8);
318 ulCount
= pRtlNumberOfSetBits(&bm
);
319 ok(ulCount
== 0, "set bits after init");
321 pRtlSetBits(&bm
, 0, 1); /* Set 1st bit */
322 ulCount
= pRtlNumberOfSetBits(&bm
);
323 ok(ulCount
== 1, "count wrong");
325 pRtlSetBits(&bm
, 7, 8); /* 8 more, spanning bytes 1-2 */
326 ulCount
= pRtlNumberOfSetBits(&bm
);
327 ok(ulCount
== 8+1, "count wrong");
329 pRtlSetBits(&bm
, 17, 33); /* 33 more crossing ULONG boundary */
330 ulCount
= pRtlNumberOfSetBits(&bm
);
331 ok(ulCount
== 8+1+33, "count wrong");
333 pRtlSetBits(&bm
, sizeof(buff
)*8-1, 1); /* Set last bit */
334 ulCount
= pRtlNumberOfSetBits(&bm
);
335 ok(ulCount
== 8+1+33+1, "count wrong");
338 static void test_RtlNumberOfClearBits()
342 if (!pRtlNumberOfClearBits
)
345 memset(buff
, 0xff , sizeof(buff
));
346 pRtlInitializeBitMap(&bm
, buff
, sizeof(buff
)*8);
348 ulCount
= pRtlNumberOfClearBits(&bm
);
349 ok(ulCount
== 0, "cleared bits after init");
351 pRtlClearBits(&bm
, 0, 1); /* Set 1st bit */
352 ulCount
= pRtlNumberOfClearBits(&bm
);
353 ok(ulCount
== 1, "count wrong");
355 pRtlClearBits(&bm
, 7, 8); /* 8 more, spanning bytes 1-2 */
356 ulCount
= pRtlNumberOfClearBits(&bm
);
357 ok(ulCount
== 8+1, "count wrong");
359 pRtlClearBits(&bm
, 17, 33); /* 33 more crossing ULONG boundary */
360 ulCount
= pRtlNumberOfClearBits(&bm
);
361 ok(ulCount
== 8+1+33, "count wrong");
363 pRtlClearBits(&bm
, sizeof(buff
)*8-1, 1); /* Set last bit */
364 ulCount
= pRtlNumberOfClearBits(&bm
);
365 ok(ulCount
== 8+1+33+1, "count wrong");
368 /* Note: this tests RtlFindSetBits also */
369 static void test_RtlFindSetBitsAndClear()
374 if (!pRtlFindSetBitsAndClear
)
377 memset(buff
, 0, sizeof(buff
));
378 pRtlInitializeBitMap(&bm
, buff
, sizeof(buff
)*8);
380 pRtlSetBits(&bm
, 0, 32);
381 ulPos
= pRtlFindSetBitsAndClear(&bm
, 32, 0);
382 ok (ulPos
== 0, "didnt find bits");
385 bRet
= pRtlAreBitsClear(&bm
, 0, 32);
386 ok (bRet
, "found but didnt clear");
389 memset(buff
, 0 , sizeof(buff
));
390 pRtlSetBits(&bm
, 40, 77);
391 ulPos
= pRtlFindSetBitsAndClear(&bm
, 77, 0);
392 ok (ulPos
== 40, "didnt find bits");
395 bRet
= pRtlAreBitsClear(&bm
, 40, 77);
396 ok (bRet
, "found but didnt clear");
400 /* Note: this tests RtlFindClearBits also */
401 static void test_RtlFindClearBitsAndSet()
406 if (!pRtlFindClearBitsAndSet
)
409 pRtlInitializeBitMap(&bm
, buff
, sizeof(buff
)*8);
411 memset(buff
, 0xff, sizeof(buff
));
412 pRtlSetBits(&bm
, 0, 32);
413 ulPos
= pRtlFindSetBitsAndClear(&bm
, 32, 0);
414 ok (ulPos
== 0, "didnt find bits");
417 bRet
= pRtlAreBitsClear(&bm
, 0, 32);
418 ok (bRet
, "found but didnt clear");
421 memset(buff
, 0xff , sizeof(buff
));
422 pRtlClearBits(&bm
, 40, 77);
423 ulPos
= pRtlFindClearBitsAndSet(&bm
, 77, 50);
424 ok (ulPos
== 40, "didnt find bits");
427 bRet
= pRtlAreBitsSet(&bm
, 40, 77);
428 ok (bRet
, "found but didnt set");
432 static void test_RtlFindMostSignificantBit()
438 if (!pRtlFindMostSignificantBit
)
441 for (i
= 0; i
< 64; i
++)
446 cPos
= pRtlFindMostSignificantBit(ulLong
);
447 ok (cPos
== i
, "didnt find MSB %lld %d %d", ulLong
, i
, cPos
);
449 cPos
= pRtlFindMostSignificantBit(0);
450 ok (cPos
== -1, "found bit when not set");
453 static void test_RtlFindLeastSignificantBit()
459 if (!pRtlFindLeastSignificantBit
)
462 for (i
= 0; i
< 64; i
++)
467 cPos
= pRtlFindLeastSignificantBit(ulLong
);
468 ok (cPos
== i
, "didnt find LSB at %d", cPos
);
470 cPos
= pRtlFindLeastSignificantBit(0);
471 ok (cPos
== -1, "found bit when not set");
474 /* Note: Also tests RtlFindLongestRunSet() */
475 static void test_RtlFindSetRuns()
477 RTL_BITMAP_RUN runs
[16];
480 if (!pRtlFindSetRuns
)
483 pRtlInitializeBitMap(&bm
, buff
, sizeof(buff
)*8);
485 memset(buff
, 0, sizeof(buff
));
486 ulCount
= pRtlFindSetRuns(&bm
, runs
, 16, TRUE
);
487 ok (ulCount
== 0, "found set bits in empty bitmap");
489 memset(runs
, 0, sizeof(runs
));
490 memset(buff
, 0xff, sizeof(buff
));
491 ulCount
= pRtlFindSetRuns(&bm
, runs
, 16, TRUE
);
492 ok (ulCount
== 1, "didnt find set bits");
493 ok (runs
[0].StartOfRun
== 0,"bad start");
494 ok (runs
[0].SizeOfRun
== sizeof(buff
)*8,"bad size");
497 memset(runs
, 0, sizeof(runs
));
498 memset(buff
, 0, sizeof(buff
));
499 pRtlSetBits(&bm
, 7, 19);
500 pRtlSetBits(&bm
, 101, 3);
501 pRtlSetBits(&bm
, 1877, 33);
504 ulCount
= pRtlFindSetRuns(&bm
, runs
, 2, FALSE
);
505 ok (runs
[0].StartOfRun
== 7 || runs
[0].StartOfRun
== 101,"bad find");
506 ok (runs
[1].StartOfRun
== 7 || runs
[1].StartOfRun
== 101,"bad find");
507 ok (runs
[0].SizeOfRun
+ runs
[1].SizeOfRun
== 19 + 3,"bad size");
508 ok (runs
[0].StartOfRun
!= runs
[1].StartOfRun
,"found run twice");
509 ok (runs
[2].StartOfRun
== 0,"found extra run");
512 memset(runs
, 0, sizeof(runs
));
513 ulCount
= pRtlFindSetRuns(&bm
, runs
, 2, TRUE
);
514 ok (runs
[0].StartOfRun
== 7 || runs
[0].StartOfRun
== 1877,"bad find");
515 ok (runs
[1].StartOfRun
== 7 || runs
[1].StartOfRun
== 1877,"bad find");
516 ok (runs
[0].SizeOfRun
+ runs
[1].SizeOfRun
== 33 + 19,"bad size");
517 ok (runs
[0].StartOfRun
!= runs
[1].StartOfRun
,"found run twice");
518 ok (runs
[2].StartOfRun
== 0,"found extra run");
521 memset(runs
, 0, sizeof(runs
));
522 ulCount
= pRtlFindSetRuns(&bm
, runs
, 3, TRUE
);
523 ok (runs
[0].StartOfRun
== 7 || runs
[0].StartOfRun
== 101 ||
524 runs
[0].StartOfRun
== 1877,"bad find");
525 ok (runs
[1].StartOfRun
== 7 || runs
[1].StartOfRun
== 101 ||
526 runs
[1].StartOfRun
== 1877,"bad find");
527 ok (runs
[2].StartOfRun
== 7 || runs
[2].StartOfRun
== 101 ||
528 runs
[2].StartOfRun
== 1877,"bad find");
529 ok (runs
[0].SizeOfRun
+ runs
[1].SizeOfRun
530 + runs
[2].SizeOfRun
== 19 + 3 + 33,"bad size");
531 ok (runs
[0].StartOfRun
!= runs
[1].StartOfRun
,"found run twice");
532 ok (runs
[1].StartOfRun
!= runs
[2].StartOfRun
,"found run twice");
533 ok (runs
[3].StartOfRun
== 0,"found extra run");
535 if (pRtlFindLongestRunSet
)
539 ulCount
= pRtlFindLongestRunSet(&bm
, &ulStart
);
540 ok(ulCount
== 33 && ulStart
== 1877,"didn't find longest %ld %ld",ulCount
,ulStart
);
542 memset(buff
, 0, sizeof(buff
));
543 ulCount
= pRtlFindLongestRunSet(&bm
, &ulStart
);
544 ok(ulCount
== 0,"found longest when none set");
548 /* Note: Also tests RtlFindLongestRunClear() */
549 static void test_RtlFindClearRuns()
551 RTL_BITMAP_RUN runs
[16];
554 if (!pRtlFindClearRuns
)
557 pRtlInitializeBitMap(&bm
, buff
, sizeof(buff
)*8);
559 memset(buff
, 0xff, sizeof(buff
));
560 ulCount
= pRtlFindClearRuns(&bm
, runs
, 16, TRUE
);
561 ok (ulCount
== 0, "found clear bits in full bitmap");
563 memset(runs
, 0, sizeof(runs
));
564 memset(buff
, 0, sizeof(buff
));
565 ulCount
= pRtlFindClearRuns(&bm
, runs
, 16, TRUE
);
566 ok (ulCount
== 1, "didnt find clear bits");
567 ok (runs
[0].StartOfRun
== 0,"bad start");
568 ok (runs
[0].SizeOfRun
== sizeof(buff
)*8,"bad size");
571 memset(runs
, 0, sizeof(runs
));
572 memset(buff
, 0xff, sizeof(buff
));
573 pRtlClearBits(&bm
, 7, 19);
574 pRtlClearBits(&bm
, 101, 3);
575 pRtlClearBits(&bm
, 1877, 33);
578 ulCount
= pRtlFindClearRuns(&bm
, runs
, 2, FALSE
);
579 ok (runs
[0].StartOfRun
== 7 || runs
[0].StartOfRun
== 101,"bad find");
580 ok (runs
[1].StartOfRun
== 7 || runs
[1].StartOfRun
== 101,"bad find");
581 ok (runs
[0].SizeOfRun
+ runs
[1].SizeOfRun
== 19 + 3,"bad size");
582 ok (runs
[0].StartOfRun
!= runs
[1].StartOfRun
,"found run twice");
583 ok (runs
[2].StartOfRun
== 0,"found extra run");
586 memset(runs
, 0, sizeof(runs
));
587 ulCount
= pRtlFindClearRuns(&bm
, runs
, 2, TRUE
);
588 ok (runs
[0].StartOfRun
== 7 || runs
[0].StartOfRun
== 1877,"bad find");
589 ok (runs
[1].StartOfRun
== 7 || runs
[1].StartOfRun
== 1877,"bad find");
590 ok (runs
[0].SizeOfRun
+ runs
[1].SizeOfRun
== 33 + 19,"bad size");
591 ok (runs
[0].StartOfRun
!= runs
[1].StartOfRun
,"found run twice");
592 ok (runs
[2].StartOfRun
== 0,"found extra run");
595 memset(runs
, 0, sizeof(runs
));
596 ulCount
= pRtlFindClearRuns(&bm
, runs
, 3, TRUE
);
597 ok (runs
[0].StartOfRun
== 7 || runs
[0].StartOfRun
== 101 ||
598 runs
[0].StartOfRun
== 1877,"bad find");
599 ok (runs
[1].StartOfRun
== 7 || runs
[1].StartOfRun
== 101 ||
600 runs
[1].StartOfRun
== 1877,"bad find");
601 ok (runs
[2].StartOfRun
== 7 || runs
[2].StartOfRun
== 101 ||
602 runs
[2].StartOfRun
== 1877,"bad find");
603 ok (runs
[0].SizeOfRun
+ runs
[1].SizeOfRun
604 + runs
[2].SizeOfRun
== 19 + 3 + 33,"bad size");
605 ok (runs
[0].StartOfRun
!= runs
[1].StartOfRun
,"found run twice");
606 ok (runs
[1].StartOfRun
!= runs
[2].StartOfRun
,"found run twice");
607 ok (runs
[3].StartOfRun
== 0,"found extra run");
609 if (pRtlFindLongestRunClear
)
613 ulCount
= pRtlFindLongestRunClear(&bm
, &ulStart
);
614 ok(ulCount
== 33 && ulStart
== 1877,"didn't find longest");
616 memset(buff
, 0xff, sizeof(buff
));
617 ulCount
= pRtlFindLongestRunClear(&bm
, &ulStart
);
618 ok(ulCount
== 0,"found longest when none clear");
623 START_TEST(rtlbitmap
)
627 if (pRtlInitializeBitMap
)
629 test_RtlInitializeBitMap();
630 test_RtlSetAllBits();
631 test_RtlClearAllBits();
635 test_RtlAreBitsSet();
636 test_RtlAreBitsClear();
637 test_RtlNumberOfSetBits();
638 test_RtlNumberOfClearBits();
639 test_RtlFindSetBitsAndClear();
640 test_RtlFindClearBitsAndSet();
641 test_RtlFindMostSignificantBit();
642 test_RtlFindLeastSignificantBit();
643 test_RtlFindSetRuns();
644 test_RtlFindClearRuns();