Esempio n. 1
0
/* Note: this tests RtlFindClearBits also */
static void test_RtlFindClearBitsAndSet(void)
{
  BOOLEAN bRet;
  ULONG ulPos;

  if (!pRtlFindClearBitsAndSet)
    return;

  pRtlInitializeBitMap(&bm, buff, sizeof(buff)*8);

  memset(buff, 0xff, sizeof(buff));
  pRtlSetBits(&bm, 0, 32);
  ulPos = pRtlFindSetBitsAndClear(&bm, 32, 0);
  ok (ulPos == 0, "didn't find bits\n");
  if(ulPos == 0)
  {
      bRet = pRtlAreBitsClear(&bm, 0, 32);
      ok (bRet, "found but didn't clear\n");
  }

  memset(buff, 0xff , sizeof(buff));
  pRtlClearBits(&bm, 40, 77);
  ulPos = pRtlFindClearBitsAndSet(&bm, 77, 50);
  ok (ulPos == 40, "didn't find bits\n");
  if(ulPos == 40)
  {
    bRet = pRtlAreBitsSet(&bm, 40, 77);
    ok (bRet, "found but didn't set\n");
  }
}
Esempio n. 2
0
static void test_RtlAreBitsSet(void)
{
  BOOLEAN bRet;

  if (!pRtlAreBitsSet)
    return;

  memset(buff, 0 , sizeof(buff));
  pRtlInitializeBitMap(&bm, buff, sizeof(buff)*8);

  bRet = pRtlAreBitsSet(&bm, 0, 1);
  ok (!bRet, "found set bits after init\n");

  pRtlSetBits(&bm, 0, 1);
  bRet = pRtlAreBitsSet(&bm, 0, 1);
  ok (bRet, "didn't find set bits\n");

  buff[0] = 0;
  pRtlSetBits(&bm, 7, 2);
  bRet = pRtlAreBitsSet(&bm, 7, 2);
  ok(bRet, "didn't find w/len < 8\n");
  bRet = pRtlAreBitsSet(&bm, 6, 3);
  ok(!bRet, "found non set bit\n");
  bRet = pRtlAreBitsSet(&bm, 7, 3);
  ok(!bRet, "found non set bit\n");

  buff[0] = buff[1] = 0;
  pRtlSetBits(&bm, 7, 10);
  bRet = pRtlAreBitsSet(&bm, 7, 10);
  ok(bRet, "didn't find w/len < 8\n");
  bRet = pRtlAreBitsSet(&bm, 6, 11);
  ok(!bRet, "found non set bit\n");
  bRet = pRtlAreBitsSet(&bm, 7, 11);
  ok(!bRet, "found non set bit\n");

  buff[0] = buff[1] = buff[2] = 0;
  pRtlSetBits(&bm, 0, 8); /* 1st byte */
  bRet = pRtlAreBitsSet(&bm, 0, 8);
  ok(bRet, "didn't find whole byte\n");

  pRtlSetBits(&bm, sizeof(buff)*8-1, 1);
  bRet = pRtlAreBitsSet(&bm, sizeof(buff)*8-1, 1);
  ok(bRet, "didn't find last bit\n");
}