Procházet zdrojové kódy

* test file for popcnt

git-svn-id: trunk@22288 -
florian před 13 roky
rodič
revize
728f53daa6
2 změnil soubory, kde provedl 121 přidání a 0 odebrání
  1. 1 0
      .gitattributes
  2. 120 0
      tests/test/tpopcnt1.pp

+ 1 - 0
.gitattributes

@@ -11128,6 +11128,7 @@ tests/test/tpointermath1.pp svneol=native#text/pascal
 tests/test/tpointermath2.pp svneol=native#text/pascal
 tests/test/tpointermath3.pp svneol=native#text/pascal
 tests/test/tpoll.pp svneol=native#text/plain
+tests/test/tpopcnt1.pp svneol=native#text/pascal
 tests/test/tprec1.pp svneol=native#text/plain
 tests/test/tprec10.pp svneol=native#text/plain
 tests/test/tprec11.pp svneol=native#text/plain

+ 120 - 0
tests/test/tpopcnt1.pp

@@ -0,0 +1,120 @@
+var
+  b : byte;
+  si : shortint;
+  w : word;
+  i : integer;
+  d : dword;
+  li : longint;
+  q : qword
+  i64 : int64;
+
+begin
+  { 8 Bit }
+
+  b:=$a4;
+  if popcnt(b)<>3 then
+    halt(1);
+
+  b:=$0;
+  if popcnt(b)<>0 then
+    halt(1);
+
+  b:=$20;
+  if popcnt(b)<>1 then
+    halt(1);
+
+  si:=$54;
+  if popcnt(si)<>3 then
+    halt(1);
+
+  si:=$0;
+  if popcnt(si)<>0 then
+    halt(1);
+
+  si:=$20;
+  if popcnt(si)<>1 then
+    halt(1);
+
+  { 16 Bit }
+
+  w:=$a4a4;
+  if popcnt(w)<>6 then
+    halt(1);
+
+  w:=$0;
+  if popcnt(w)<>0 then
+    halt(1);
+
+  w:=$2020;
+  if popcnt(w)<>2 then
+    halt(1);
+
+  i:=$5454;
+  if popcnt(i)<>6 then
+    halt(1);
+
+  i:=$0;
+  if popcnt(i)<>0 then
+    halt(1);
+
+  i:=$2020;
+  if popcnt(i)<>2 then
+    halt(1);
+
+  { 32 Bit }
+
+  d:=$a4a4a4a4;
+  if popcnt(w)<>12 then
+    halt(1);
+
+  d:=$0;
+  if popcnt(d)<>0 then
+    halt(1);
+
+  d:=$20402040;
+  if popcnt(d)<>4 then
+    halt(1);
+
+  li:=$54545454;
+  if popcnt(li)<>12 then
+    halt(1);
+
+  li:=$0;
+  if popcnt(li)<>0 then
+    halt(1);
+
+  li:=$20402080;
+  if popcnt(li)<>4 then
+    halt(1);
+
+
+  { 64 Bit }
+
+  q:=$a4a4a4a4a4a4a4a4;
+  if popcnt(q)<>24 then
+    halt(1);
+
+  q:=$0;
+  if popcnt(q)<>0 then
+    halt(1);
+
+  q:=$2040204080804001;
+  if popcnt(q)<>8 then
+    halt(1);
+
+  i64:=$5454545454545454;
+  if popcnt(i64)<>24 then
+    halt(1);
+
+  i64:=$0;
+  if popcnt(i64)<>0 then
+    halt(1);
+
+  i64:=$2040208020402080;
+  if popcnt(li)<>8 then
+    halt(1);
+
+
+  writeln('ok');
+end.
+