mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-11 22:08:18 +02:00

* 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 -
31 lines
476 B
ObjectPascal
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.
|