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.
25 #include "wine/test.h"
33 /* Function ptrs for ordinal calls */
34 static HMODULE hntdll = 0;
35 static VOID (WINAPI *pRtlInitializeBitMap)(PRTL_BITMAP,LPBYTE,ULONG);
36 static VOID (WINAPI *pRtlSetAllBits)(PRTL_BITMAP);
37 static VOID (WINAPI *pRtlClearAllBits)(PRTL_BITMAP);
38 static VOID (WINAPI *pRtlSetBits)(PRTL_BITMAP,ULONG,ULONG);
39 static VOID (WINAPI *pRtlClearBits)(PRTL_BITMAP,ULONG,ULONG);
40 static BOOLEAN (WINAPI *pRtlAreBitsSet)(PRTL_BITMAP,ULONG,ULONG);
41 static BOOLEAN (WINAPI *pRtlAreBitsClear)(PRTL_BITMAP,ULONG,ULONG);
42 static ULONG (WINAPI *pRtlFindSetBitsAndClear)(PRTL_BITMAP,ULONG,ULONG);
43 static ULONG (WINAPI *pRtlFindClearBitsAndSet)(PRTL_BITMAP,ULONG,ULONG);
44 static CCHAR (WINAPI *pRtlFindMostSignificantBit)(ULONGLONG);
45 static CCHAR (WINAPI *pRtlFindLeastSignificantBit)(ULONGLONG);
46 static ULONG (WINAPI *pRtlFindSetRuns)(PRTL_BITMAP,PRTL_BITMAP_RUN,ULONG,BOOLEAN);
47 static ULONG (WINAPI *pRtlFindClearRuns)(PRTL_BITMAP,PRTL_BITMAP_RUN,ULONG,BOOLEAN);
48 static ULONG (WINAPI *pRtlNumberOfSetBits)(PRTL_BITMAP);
49 static ULONG (WINAPI *pRtlNumberOfClearBits)(PRTL_BITMAP);
50 static ULONG (WINAPI *pRtlFindLongestRunSet)(PRTL_BITMAP,PULONG);
51 static ULONG (WINAPI *pRtlFindLongestRunClear)(PRTL_BITMAP,PULONG);
53 static BYTE buff[256];
56 static void InitFunctionPtrs()
58 hntdll = LoadLibraryA("ntdll.dll");
59 ok(hntdll != 0, "LoadLibrary failed");
62 pRtlInitializeBitMap = (void *)GetProcAddress(hntdll, "RtlInitializeBitMap");
63 pRtlSetAllBits = (void *)GetProcAddress(hntdll, "RtlSetAllBits");
64 pRtlClearAllBits = (void *)GetProcAddress(hntdll, "RtlClearAllBits");
65 pRtlSetBits = (void *)GetProcAddress(hntdll, "RtlSetBits");
66 pRtlClearBits = (void *)GetProcAddress(hntdll, "RtlClearBits");
67 pRtlAreBitsSet = (void *)GetProcAddress(hntdll, "RtlAreBitsSet");
68 pRtlAreBitsClear = (void *)GetProcAddress(hntdll, "RtlAreBitsClear");
69 pRtlNumberOfSetBits = (void *)GetProcAddress(hntdll, "RtlNumberOfSetBits");
70 pRtlNumberOfClearBits = (void *)GetProcAddress(hntdll, "RtlNumberOfClearBits");
71 pRtlFindSetBitsAndClear = (void *)GetProcAddress(hntdll, "RtlFindSetBitsAndClear");
72 pRtlFindClearBitsAndSet = (void *)GetProcAddress(hntdll, "RtlFindClearBitsAndSet");
73 pRtlFindMostSignificantBit = (void *)GetProcAddress(hntdll, "RtlFindMostSignificantBit");
74 pRtlFindLeastSignificantBit = (void *)GetProcAddress(hntdll, "RtlFindLeastSignificantBit");
75 pRtlFindSetRuns = (void *)GetProcAddress(hntdll, "RtlFindSetRuns");
76 pRtlFindClearRuns = (void *)GetProcAddress(hntdll, "RtlFindClearRuns");
77 pRtlFindLongestRunSet = (void *)GetProcAddress(hntdll, "RtlFindLongestRunSet");
78 pRtlFindLongestRunClear = (void *)GetProcAddress(hntdll, "RtlFindLongestRunClear");
82 static void test_RtlInitializeBitMap(void)
87 memset(buff, 0, sizeof(buff));
88 buff[0] = 77; /* Check buffer is not written to during init */
91 pRtlInitializeBitMap(&bm, buff, 800);
92 ok(bm.SizeOfBitMap == 800, "size uninitialised");
93 ok(bm.BitMapBuffer == buff,"buffer uninitialised");
94 ok(buff[0] == 77 && buff[79] == 77, "wrote to buffer");
96 /* Test inlined version */
97 RtlInitializeBitMap(&bm, buff, 800);
98 ok(bm.SizeOfBitMap == 800, "size uninitialised");
99 ok(bm.BitMapBuffer == buff,"buffer uninitialised");
100 ok(buff[0] == 77 && buff[79] == 77, "wrote to buffer");
103 static void test_RtlSetAllBits(void)
108 memset(buff, 0 , sizeof(buff));
109 pRtlInitializeBitMap(&bm, buff, 1);
112 ok(buff[0] == 0xff && buff[1] == 0xff && buff[2] == 0xff &&
113 buff[3] == 0xff, "didnt round up size");
114 ok(buff[4] == 0, "set more than rounded size");
116 /* Test inlined version */
117 memset(buff, 0 , sizeof(buff));
119 ok(buff[0] == 0xff && buff[1] == 0xff && buff[2] == 0xff &&
120 buff[3] == 0xff, "didnt round up size");
121 ok(buff[4] == 0, "set more than rounded size");
124 static void test_RtlClearAllBits()
126 if (!pRtlClearAllBits)
129 memset(buff, 0xff , sizeof(buff));
130 pRtlInitializeBitMap(&bm, buff, 1);
132 pRtlClearAllBits(&bm);
133 ok(!buff[0] && !buff[1] && !buff[2] && !buff[3], "didnt round up size");
134 ok(buff[4] == 0xff, "cleared more than rounded size");
136 /* Test inlined version */
137 memset(buff, 0xff , sizeof(buff));
138 RtlClearAllBits(&bm);
139 ok(!buff[0] && !buff[1] && !buff[2] && !buff[3] , "didnt round up size");
140 ok(buff[4] == 0xff, "cleared more than rounded size");
143 static void test_RtlSetBits()
148 memset(buff, 0 , sizeof(buff));
149 pRtlInitializeBitMap(&bm, buff, sizeof(buff)*8);
151 pRtlSetBits(&bm, 0, 1);
152 ok(buff[0] == 1, "didnt set 1st bit");
155 pRtlSetBits(&bm, 7, 2);
156 ok(buff[0] == 0x80 && buff[1] == 1, "didnt span w/len < 8");
158 buff[0] = buff[1] = 0;
159 pRtlSetBits(&bm, 7, 10);
160 ok(buff[0] == 0x80 && buff[1] == 0xff && buff[2] == 1, "didnt span w/len > 8");
162 buff[0] = buff[1] = buff[2] = 0;
163 pRtlSetBits(&bm, 0, 8); /* 1st byte */
164 ok(buff[0] == 0xff, "didnt set all bits");
165 ok(!buff[1], "set too many bits");
167 pRtlSetBits(&bm, sizeof(buff)*8-1, 1); /* last bit */
168 ok(buff[sizeof(buff)-1] == 0x80, "didnt set last bit");
171 static void test_RtlClearBits()
176 memset(buff, 0xff , sizeof(buff));
177 pRtlInitializeBitMap(&bm, buff, sizeof(buff)*8);
179 pRtlClearBits(&bm, 0, 1);
180 ok(buff[0] == 0xfe, "didnt clear 1st bit");
183 pRtlClearBits(&bm, 7, 2);
184 ok(buff[0] == 0x7f && buff[1] == 0xfe, "didnt span w/len < 8");
186 buff[0] = buff[1] = 0xff;
187 pRtlClearBits(&bm, 7, 10);
188 ok(buff[0] == 0x7f && buff[1] == 0 && buff[2] == 0xfe, "didnt span w/len > 8");
190 buff[0] = buff[1] = buff[2] = 0xff;
191 pRtlClearBits(&bm, 0, 8); /* 1st byte */
192 ok(!buff[0], "didnt clear all bits");
193 ok(buff[1] == 0xff, "cleared too many bits");
195 pRtlClearBits(&bm, sizeof(buff)*8-1, 1);
196 ok(buff[sizeof(buff)-1] == 0x7f, "didnt set last bit");
199 static void test_RtlCheckBit()
203 memset(buff, 0 , sizeof(buff));
204 pRtlInitializeBitMap(&bm, buff, sizeof(buff)*8);
205 pRtlSetBits(&bm, 0, 1);
206 pRtlSetBits(&bm, 7, 2);
207 pRtlSetBits(&bm, sizeof(buff)*8-1, 1);
209 bRet = RtlCheckBit(&bm, 0);
210 ok (bRet, "didnt find set bit");
211 bRet = RtlCheckBit(&bm, 7);
212 ok (bRet, "didnt find set bit");
213 bRet = RtlCheckBit(&bm, 8);
214 ok (bRet, "didnt find set bit");
215 bRet = RtlCheckBit(&bm, sizeof(buff)*8-1);
216 ok (bRet, "didnt find set bit");
217 bRet = RtlCheckBit(&bm, 1);
218 ok (!bRet, "found non set bit");
219 bRet = RtlCheckBit(&bm, sizeof(buff)*8-2);
220 ok (!bRet, "found non set bit");
223 static void test_RtlAreBitsSet()
230 memset(buff, 0 , sizeof(buff));
231 pRtlInitializeBitMap(&bm, buff, sizeof(buff)*8);
233 bRet = pRtlAreBitsSet(&bm, 0, 1);
234 ok (!bRet, "found set bits after init");
236 pRtlSetBits(&bm, 0, 1);
237 bRet = pRtlAreBitsSet(&bm, 0, 1);
238 ok (bRet, "didnt find set bits");
241 pRtlSetBits(&bm, 7, 2);
242 bRet = pRtlAreBitsSet(&bm, 7, 2);
243 ok(bRet, "didnt find w/len < 8");
244 bRet = pRtlAreBitsSet(&bm, 6, 3);
245 ok(!bRet, "found non set bit");
246 bRet = pRtlAreBitsSet(&bm, 7, 3);
247 ok(!bRet, "found non set bit");
249 buff[0] = buff[1] = 0;
250 pRtlSetBits(&bm, 7, 10);
251 bRet = pRtlAreBitsSet(&bm, 7, 10);
252 ok(bRet, "didnt find w/len < 8");
253 bRet = pRtlAreBitsSet(&bm, 6, 11);
254 ok(!bRet, "found non set bit");
255 bRet = pRtlAreBitsSet(&bm, 7, 11);
256 ok(!bRet, "found non set bit");
258 buff[0] = buff[1] = buff[2] = 0;
259 pRtlSetBits(&bm, 0, 8); /* 1st byte */
260 bRet = pRtlAreBitsSet(&bm, 0, 8);
261 ok(bRet, "didn't find whole byte");
263 pRtlSetBits(&bm, sizeof(buff)*8-1, 1);
264 bRet = pRtlAreBitsSet(&bm, sizeof(buff)*8-1, 1);
265 ok(bRet, "didn't find last bit");
268 static void test_RtlAreBitsClear()
272 if (!pRtlAreBitsClear)
275 memset(buff, 0xff , sizeof(buff));
276 pRtlInitializeBitMap(&bm, buff, sizeof(buff)*8);
278 bRet = pRtlAreBitsClear(&bm, 0, 1);
279 ok (!bRet, "found clear bits after init");
281 pRtlClearBits(&bm, 0, 1);
282 bRet = pRtlAreBitsClear(&bm, 0, 1);
283 ok (bRet, "didnt find set bits");
286 pRtlClearBits(&bm, 7, 2);
287 bRet = pRtlAreBitsClear(&bm, 7, 2);
288 ok(bRet, "didnt find w/len < 8");
289 bRet = pRtlAreBitsClear(&bm, 6, 3);
290 ok(!bRet, "found non clear bit");
291 bRet = pRtlAreBitsClear(&bm, 7, 3);
292 ok(!bRet, "found non clear bit");
294 buff[0] = buff[1] = 0xff;
295 pRtlClearBits(&bm, 7, 10);
296 bRet = pRtlAreBitsClear(&bm, 7, 10);
297 ok(bRet, "didnt find w/len < 8");
298 bRet = pRtlAreBitsClear(&bm, 6, 11);
299 ok(!bRet, "found non clear bit");
300 bRet = pRtlAreBitsClear(&bm, 7, 11);
301 ok(!bRet, "found non clear bit");
303 buff[0] = buff[1] = buff[2] = 0xff;
304 pRtlClearBits(&bm, 0, 8); /* 1st byte */
305 bRet = pRtlAreBitsClear(&bm, 0, 8);
306 ok(bRet, "didn't find whole byte");
308 pRtlClearBits(&bm, sizeof(buff)*8-1, 1);
309 bRet = pRtlAreBitsClear(&bm, sizeof(buff)*8-1, 1);
310 ok(bRet, "didn't find last bit");
313 static void test_RtlNumberOfSetBits()
317 if (!pRtlNumberOfSetBits)
320 memset(buff, 0 , sizeof(buff));
321 pRtlInitializeBitMap(&bm, buff, sizeof(buff)*8);
323 ulCount = pRtlNumberOfSetBits(&bm);
324 ok(ulCount == 0, "set bits after init");
326 pRtlSetBits(&bm, 0, 1); /* Set 1st bit */
327 ulCount = pRtlNumberOfSetBits(&bm);
328 ok(ulCount == 1, "count wrong");
330 pRtlSetBits(&bm, 7, 8); /* 8 more, spanning bytes 1-2 */
331 ulCount = pRtlNumberOfSetBits(&bm);
332 ok(ulCount == 8+1, "count wrong");
334 pRtlSetBits(&bm, 17, 33); /* 33 more crossing ULONG boundary */
335 ulCount = pRtlNumberOfSetBits(&bm);
336 ok(ulCount == 8+1+33, "count wrong");
338 pRtlSetBits(&bm, sizeof(buff)*8-1, 1); /* Set last bit */
339 ulCount = pRtlNumberOfSetBits(&bm);
340 ok(ulCount == 8+1+33+1, "count wrong");
343 static void test_RtlNumberOfClearBits()
347 if (!pRtlNumberOfClearBits)
350 memset(buff, 0xff , sizeof(buff));
351 pRtlInitializeBitMap(&bm, buff, sizeof(buff)*8);
353 ulCount = pRtlNumberOfClearBits(&bm);
354 ok(ulCount == 0, "cleared bits after init");
356 pRtlClearBits(&bm, 0, 1); /* Set 1st bit */
357 ulCount = pRtlNumberOfClearBits(&bm);
358 ok(ulCount == 1, "count wrong");
360 pRtlClearBits(&bm, 7, 8); /* 8 more, spanning bytes 1-2 */
361 ulCount = pRtlNumberOfClearBits(&bm);
362 ok(ulCount == 8+1, "count wrong");
364 pRtlClearBits(&bm, 17, 33); /* 33 more crossing ULONG boundary */
365 ulCount = pRtlNumberOfClearBits(&bm);
366 ok(ulCount == 8+1+33, "count wrong");
368 pRtlClearBits(&bm, sizeof(buff)*8-1, 1); /* Set last bit */
369 ulCount = pRtlNumberOfClearBits(&bm);
370 ok(ulCount == 8+1+33+1, "count wrong");
373 /* Note: this tests RtlFindSetBits also */
374 static void test_RtlFindSetBitsAndClear()
379 if (!pRtlFindSetBitsAndClear)
382 memset(buff, 0, sizeof(buff));
383 pRtlInitializeBitMap(&bm, buff, sizeof(buff)*8);
385 pRtlSetBits(&bm, 0, 32);
386 ulPos = pRtlFindSetBitsAndClear(&bm, 32, 0);
387 ok (ulPos == 0, "didnt find bits");
390 bRet = pRtlAreBitsClear(&bm, 0, 32);
391 ok (bRet, "found but didnt clear");
394 memset(buff, 0 , sizeof(buff));
395 pRtlSetBits(&bm, 40, 77);
396 ulPos = pRtlFindSetBitsAndClear(&bm, 77, 0);
397 ok (ulPos == 40, "didnt find bits");
400 bRet = pRtlAreBitsClear(&bm, 40, 77);
401 ok (bRet, "found but didnt clear");
405 /* Note: this tests RtlFindClearBits also */
406 static void test_RtlFindClearBitsAndSet()
411 if (!pRtlFindClearBitsAndSet)
414 pRtlInitializeBitMap(&bm, buff, sizeof(buff)*8);
416 memset(buff, 0xff, sizeof(buff));
417 pRtlSetBits(&bm, 0, 32);
418 ulPos = pRtlFindSetBitsAndClear(&bm, 32, 0);
419 ok (ulPos == 0, "didnt find bits");
422 bRet = pRtlAreBitsClear(&bm, 0, 32);
423 ok (bRet, "found but didnt clear");
426 memset(buff, 0xff , sizeof(buff));
427 pRtlClearBits(&bm, 40, 77);
428 ulPos = pRtlFindClearBitsAndSet(&bm, 77, 50);
429 ok (ulPos == 40, "didnt find bits");
432 bRet = pRtlAreBitsSet(&bm, 40, 77);
433 ok (bRet, "found but didnt set");
437 static void test_RtlFindMostSignificantBit()
443 if (!pRtlFindMostSignificantBit)
446 for (i = 0; i < 64; i++)
451 cPos = pRtlFindMostSignificantBit(ulLong);
452 ok (cPos == i, "didnt find MSB %llx %d %d", ulLong, i, cPos);
454 /* Set all bits lower than bit i */
455 ulLong = ((ulLong - 1) << 1) | 1;
457 cPos = pRtlFindMostSignificantBit(ulLong);
458 ok (cPos == i, "didnt find MSB %llx %d %d", ulLong, i, cPos);
460 cPos = pRtlFindMostSignificantBit(0);
461 ok (cPos == -1, "found bit when not set");
464 static void test_RtlFindLeastSignificantBit()
470 if (!pRtlFindLeastSignificantBit)
473 for (i = 0; i < 64; i++)
475 ulLong = (ULONGLONG)1 << i;
477 cPos = pRtlFindLeastSignificantBit(ulLong);
478 ok (cPos == i, "didnt find LSB %llx %d %d", ulLong, i, cPos);
480 ulLong = ~((ULONGLONG)0) << i;
482 cPos = pRtlFindLeastSignificantBit(ulLong);
483 ok (cPos == i, "didnt find LSB %llx %d %d", ulLong, i, cPos);
485 cPos = pRtlFindLeastSignificantBit(0);
486 ok (cPos == -1, "found bit when not set");
489 /* Note: Also tests RtlFindLongestRunSet() */
490 static void test_RtlFindSetRuns()
492 RTL_BITMAP_RUN runs[16];
495 if (!pRtlFindSetRuns)
498 pRtlInitializeBitMap(&bm, buff, sizeof(buff)*8);
500 memset(buff, 0, sizeof(buff));
501 ulCount = pRtlFindSetRuns(&bm, runs, 16, TRUE);
502 ok (ulCount == 0, "found set bits in empty bitmap");
504 memset(runs, 0, sizeof(runs));
505 memset(buff, 0xff, sizeof(buff));
506 ulCount = pRtlFindSetRuns(&bm, runs, 16, TRUE);
507 ok (ulCount == 1, "didnt find set bits");
508 ok (runs[0].StartOfRun == 0,"bad start");
509 ok (runs[0].SizeOfRun == sizeof(buff)*8,"bad size");
512 memset(runs, 0, sizeof(runs));
513 memset(buff, 0, sizeof(buff));
514 pRtlSetBits(&bm, 7, 19);
515 pRtlSetBits(&bm, 101, 3);
516 pRtlSetBits(&bm, 1877, 33);
519 ulCount = pRtlFindSetRuns(&bm, runs, 2, FALSE);
520 ok (runs[0].StartOfRun == 7 || runs[0].StartOfRun == 101,"bad find");
521 ok (runs[1].StartOfRun == 7 || runs[1].StartOfRun == 101,"bad find");
522 ok (runs[0].SizeOfRun + runs[1].SizeOfRun == 19 + 3,"bad size");
523 ok (runs[0].StartOfRun != runs[1].StartOfRun,"found run twice");
524 ok (runs[2].StartOfRun == 0,"found extra run");
527 memset(runs, 0, sizeof(runs));
528 ulCount = pRtlFindSetRuns(&bm, runs, 2, TRUE);
529 ok (runs[0].StartOfRun == 7 || runs[0].StartOfRun == 1877,"bad find");
530 ok (runs[1].StartOfRun == 7 || runs[1].StartOfRun == 1877,"bad find");
531 ok (runs[0].SizeOfRun + runs[1].SizeOfRun == 33 + 19,"bad size");
532 ok (runs[0].StartOfRun != runs[1].StartOfRun,"found run twice");
533 ok (runs[2].StartOfRun == 0,"found extra run");
536 memset(runs, 0, sizeof(runs));
537 ulCount = pRtlFindSetRuns(&bm, runs, 3, TRUE);
538 ok (runs[0].StartOfRun == 7 || runs[0].StartOfRun == 101 ||
539 runs[0].StartOfRun == 1877,"bad find");
540 ok (runs[1].StartOfRun == 7 || runs[1].StartOfRun == 101 ||
541 runs[1].StartOfRun == 1877,"bad find");
542 ok (runs[2].StartOfRun == 7 || runs[2].StartOfRun == 101 ||
543 runs[2].StartOfRun == 1877,"bad find");
544 ok (runs[0].SizeOfRun + runs[1].SizeOfRun
545 + runs[2].SizeOfRun == 19 + 3 + 33,"bad size");
546 ok (runs[0].StartOfRun != runs[1].StartOfRun,"found run twice");
547 ok (runs[1].StartOfRun != runs[2].StartOfRun,"found run twice");
548 ok (runs[3].StartOfRun == 0,"found extra run");
550 if (pRtlFindLongestRunSet)
554 ulCount = pRtlFindLongestRunSet(&bm, &ulStart);
555 ok(ulCount == 33 && ulStart == 1877,"didn't find longest %ld %ld",ulCount,ulStart);
557 memset(buff, 0, sizeof(buff));
558 ulCount = pRtlFindLongestRunSet(&bm, &ulStart);
559 ok(ulCount == 0,"found longest when none set");
563 /* Note: Also tests RtlFindLongestRunClear() */
564 static void test_RtlFindClearRuns()
566 RTL_BITMAP_RUN runs[16];
569 if (!pRtlFindClearRuns)
572 pRtlInitializeBitMap(&bm, buff, sizeof(buff)*8);
574 memset(buff, 0xff, sizeof(buff));
575 ulCount = pRtlFindClearRuns(&bm, runs, 16, TRUE);
576 ok (ulCount == 0, "found clear bits in full bitmap");
578 memset(runs, 0, sizeof(runs));
579 memset(buff, 0, sizeof(buff));
580 ulCount = pRtlFindClearRuns(&bm, runs, 16, TRUE);
581 ok (ulCount == 1, "didnt find clear bits");
582 ok (runs[0].StartOfRun == 0,"bad start");
583 ok (runs[0].SizeOfRun == sizeof(buff)*8,"bad size");
586 memset(runs, 0, sizeof(runs));
587 memset(buff, 0xff, sizeof(buff));
588 pRtlClearBits(&bm, 7, 19);
589 pRtlClearBits(&bm, 101, 3);
590 pRtlClearBits(&bm, 1877, 33);
593 ulCount = pRtlFindClearRuns(&bm, runs, 2, FALSE);
594 ok (runs[0].StartOfRun == 7 || runs[0].StartOfRun == 101,"bad find");
595 ok (runs[1].StartOfRun == 7 || runs[1].StartOfRun == 101,"bad find");
596 ok (runs[0].SizeOfRun + runs[1].SizeOfRun == 19 + 3,"bad size");
597 ok (runs[0].StartOfRun != runs[1].StartOfRun,"found run twice");
598 ok (runs[2].StartOfRun == 0,"found extra run");
601 memset(runs, 0, sizeof(runs));
602 ulCount = pRtlFindClearRuns(&bm, runs, 2, TRUE);
603 ok (runs[0].StartOfRun == 7 || runs[0].StartOfRun == 1877,"bad find");
604 ok (runs[1].StartOfRun == 7 || runs[1].StartOfRun == 1877,"bad find");
605 ok (runs[0].SizeOfRun + runs[1].SizeOfRun == 33 + 19,"bad size");
606 ok (runs[0].StartOfRun != runs[1].StartOfRun,"found run twice");
607 ok (runs[2].StartOfRun == 0,"found extra run");
610 memset(runs, 0, sizeof(runs));
611 ulCount = pRtlFindClearRuns(&bm, runs, 3, TRUE);
612 ok (runs[0].StartOfRun == 7 || runs[0].StartOfRun == 101 ||
613 runs[0].StartOfRun == 1877,"bad find");
614 ok (runs[1].StartOfRun == 7 || runs[1].StartOfRun == 101 ||
615 runs[1].StartOfRun == 1877,"bad find");
616 ok (runs[2].StartOfRun == 7 || runs[2].StartOfRun == 101 ||
617 runs[2].StartOfRun == 1877,"bad find");
618 ok (runs[0].SizeOfRun + runs[1].SizeOfRun
619 + runs[2].SizeOfRun == 19 + 3 + 33,"bad size");
620 ok (runs[0].StartOfRun != runs[1].StartOfRun,"found run twice");
621 ok (runs[1].StartOfRun != runs[2].StartOfRun,"found run twice");
622 ok (runs[3].StartOfRun == 0,"found extra run");
624 if (pRtlFindLongestRunClear)
628 ulCount = pRtlFindLongestRunClear(&bm, &ulStart);
629 ok(ulCount == 33 && ulStart == 1877,"didn't find longest");
631 memset(buff, 0xff, sizeof(buff));
632 ulCount = pRtlFindLongestRunClear(&bm, &ulStart);
633 ok(ulCount == 0,"found longest when none clear");
638 START_TEST(rtlbitmap)
642 if (pRtlInitializeBitMap)
644 test_RtlInitializeBitMap();
645 test_RtlSetAllBits();
646 test_RtlClearAllBits();
650 test_RtlAreBitsSet();
651 test_RtlAreBitsClear();
652 test_RtlNumberOfSetBits();
653 test_RtlNumberOfClearBits();
654 test_RtlFindSetBitsAndClear();
655 test_RtlFindClearBitsAndSet();
656 test_RtlFindMostSignificantBit();
657 test_RtlFindLeastSignificantBit();
658 test_RtlFindSetRuns();
659 test_RtlFindClearRuns();