fpc/tests/tbs/tb0548.pp
Jonas Maebe 95637dea75 * fixed swapendian(smallint) (bug found by Joost van der Sluis)
* based swap(smallint) and swap(word) on swapendian(smallint/word),
    since the same bug was already fixed in swap(smallint) in r6752
    (so these routines now share the same code)
  * fixed potential range error in swapendian(word)
  + added basic test for the above four routines

git-svn-id: trunk@10840 -
2008-04-29 22:14:43 +00:00

31 lines
476 B
ObjectPascal

{$r+}
{$q+}
var
wo: word;
si: smallint;
begin
wo:=$9876;
if swap(wo)<>$7698 then
halt(1);
if swapendian(wo)<>$7698 then
halt(2);
wo:=$1290;
if swap(wo)<>$9012 then
halt(3);
if swapendian(wo)<>$9012 then
halt(4);
si:=smallint($9876);
if swap(si)<>$7698 then
halt(5);
if swapendian(si)<>$7698 then
halt(6);
si:=$1290;
if swap(si)<>smallint($9012) then
halt(7);
if swapendian(si)<>smallint($9012) then
halt(8);
end.