Browse Source

* extended bsf/bsr tests with values in which more than one bit is set

git-svn-id: trunk@30151 -
Jonas Maebe 10 years ago
parent
commit
00642288b8
1 changed files with 10 additions and 10 deletions
  1. 10 10
      tests/test/tbsx1.pp

+ 10 - 10
tests/test/tbsx1.pp

@@ -10,16 +10,16 @@ begin
   for i:=0 to 7 do
   begin
     x8:=1 shl i;
-    f:=BsfByte(x8);
+    f:=BsfByte(x8 or ((7-i) shl i));
     if (f<>i) then
     begin
-      writeln('BsfByte(',x8,') returned ',f,', should be ',i);
+      writeln('BsfByte($',hexstr(x8 or ((7-i) shl i),2),') returned ',f,', should be ',i);
       exit(false);
     end;
-    r:=BsrByte(x8);
+    r:=BsrByte(x8 or i);
     if r<>i then
     begin
-      writeln('BsrByte(',x8,') returned ',r,', should be ',i);
+      writeln('BsrByte($',hexstr(x8 or i,2),') returned ',r,', should be ',i);
       exit(false);
     end;
   end;
@@ -47,13 +47,13 @@ begin
   for i:=0 to 15 do
   begin
     x16:=1 shl i;
-    f:=BsfWord(x16);
+    f:=BsfWord(x16 or ((15-i) shl i));
     if (f<>i) then
     begin
       writeln('BsfWord(',x16,') returned ',f,', should be ',i);
       exit(false);
     end;
-    r:=BsrWord(x16);
+    r:=BsrWord(x16 or i);
     if r<>i then
     begin
       writeln('BsrWord(',x16,') returned ',r,', should be ',i);
@@ -84,13 +84,13 @@ begin
   for i:=0 to 31 do
   begin
     x32:=cardinal(1) shl i;
-    f:=BsfDWord(x32);
+    f:=BsfDWord(x32 or ((31-i) shl i));
     if (f<>i) then
     begin
       writeln('BsfDWord(',x32,') returned ',f,', should be ',i);
       exit(false);
     end;
-    r:=BsrDWord(x32);
+    r:=BsrDWord(x32 or i);
     if r<>i then
     begin
       writeln('BsrDWord(',x32,') returned ',r,', should be ',i);
@@ -121,12 +121,12 @@ begin
   for i:=0 to 63 do
   begin
     x64:=uint64(1) shl i;
-    f:=BsfQWord(x64);
+    f:=BsfQWord(x64 or (uint64(63-i) shl i));
     if f<>i then begin
       writeln('BsfQWord(',x64,') returned ',f,', should be ',i);
       exit(false);
     end;
-    r:=BsrQWord(x64);
+    r:=BsrQWord(x64 or i);
     if r<>i then begin
       writeln('BsrQWord(',x64,') returned ',r,', should be ',i);
       exit(false);