mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-14 11:39:27 +02:00
# revisions: 45370
git-svn-id: branches/fixes_3_2@45689 -
This commit is contained in:
parent
b9e071c1c2
commit
baf8b99261
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -15440,6 +15440,7 @@ tests/test/units/sysutils/tfile2.pp svneol=native#text/plain
|
||||
tests/test/units/sysutils/tfilename.pp svneol=native#text/plain
|
||||
tests/test/units/sysutils/tfloattostr.pp svneol=native#text/plain
|
||||
tests/test/units/sysutils/tformat.pp svneol=native#text/plain
|
||||
tests/test/units/sysutils/tinttohex.pp svneol=native#text/pascal
|
||||
tests/test/units/sysutils/tlocale.pp svneol=native#text/plain
|
||||
tests/test/units/sysutils/trwsync.pp svneol=native#text/plain
|
||||
tests/test/units/sysutils/tsscanf.pp svneol=native#text/plain
|
||||
|
@ -61,7 +61,7 @@ end;
|
||||
Function TORDINALHELPER.ToHexString: string; overload; inline;
|
||||
|
||||
begin
|
||||
Result:=IntToHex(Self,SizeOf(TORDINALTYPE)*2);
|
||||
Result:=IntToHex(Self);
|
||||
end;
|
||||
|
||||
Function TORDINALHELPER.ToSingle: Single; inline;
|
||||
|
@ -919,6 +919,46 @@ begin
|
||||
result:=IntToHex(Int64(Value),Digits);
|
||||
end;
|
||||
|
||||
function IntToHex(Value: Int8): string;
|
||||
begin
|
||||
Result:=IntToHex(Value, 2*SizeOf(Int8));
|
||||
end;
|
||||
|
||||
function IntToHex(Value: UInt8): string;
|
||||
begin
|
||||
Result:=IntToHex(Value, 2*SizeOf(UInt8));
|
||||
end;
|
||||
|
||||
function IntToHex(Value: Int16): string;
|
||||
begin
|
||||
Result:=IntToHex(Value, 2*SizeOf(Int16));
|
||||
end;
|
||||
|
||||
function IntToHex(Value: UInt16): string;
|
||||
begin
|
||||
Result:=IntToHex(Value, 2*SizeOf(UInt16));
|
||||
end;
|
||||
|
||||
function IntToHex(Value: Int32): string;
|
||||
begin
|
||||
Result:=IntToHex(Value, 2*SizeOf(Int32));
|
||||
end;
|
||||
|
||||
function IntToHex(Value: UInt32): string;
|
||||
begin
|
||||
Result:=IntToHex(Value, 2*SizeOf(UInt32));
|
||||
end;
|
||||
|
||||
function IntToHex(Value: Int64): string;
|
||||
begin
|
||||
Result:=IntToHex(Value, 2*SizeOf(Int64));
|
||||
end;
|
||||
|
||||
function IntToHex(Value: UInt64): string;
|
||||
begin
|
||||
Result:=IntToHex(Value, 2*SizeOf(UInt64));
|
||||
end;
|
||||
|
||||
function TryStrToInt(const s: string; out i : Longint) : boolean;
|
||||
var Error : word;
|
||||
begin
|
||||
|
@ -120,6 +120,14 @@ function UIntToStr(Value: Cardinal): string; {$ifdef SYSUTILSINLINE}inline;{$END
|
||||
function IntToHex(Value: Longint; Digits: integer): string;
|
||||
function IntToHex(Value: Int64; Digits: integer): string;
|
||||
function IntToHex(Value: QWord; Digits: integer): string; {$ifdef SYSUTILSINLINE}inline;{$ENDIF}
|
||||
function IntToHex(Value: Int8): string; {$ifdef SYSUTILSINLINE}inline;{$ENDIF}
|
||||
function IntToHex(Value: UInt8): string; {$ifdef SYSUTILSINLINE}inline;{$ENDIF}
|
||||
function IntToHex(Value: Int16): string; {$ifdef SYSUTILSINLINE}inline;{$ENDIF}
|
||||
function IntToHex(Value: UInt16): string; {$ifdef SYSUTILSINLINE}inline;{$ENDIF}
|
||||
function IntToHex(Value: Int32): string; {$ifdef SYSUTILSINLINE}inline;{$ENDIF}
|
||||
function IntToHex(Value: UInt32): string; {$ifdef SYSUTILSINLINE}inline;{$ENDIF}
|
||||
function IntToHex(Value: Int64): string; {$ifdef SYSUTILSINLINE}inline;{$ENDIF}
|
||||
function IntToHex(Value: UInt64): string; {$ifdef SYSUTILSINLINE}inline;{$ENDIF}
|
||||
function StrToInt(const s: string): Longint;
|
||||
function StrToDWord(const s: string): DWord;
|
||||
function StrToUInt(const s: string): Cardinal;
|
||||
|
74
tests/test/units/sysutils/tinttohex.pp
Normal file
74
tests/test/units/sysutils/tinttohex.pp
Normal file
@ -0,0 +1,74 @@
|
||||
program tinttohex;
|
||||
|
||||
{$mode Delphi}
|
||||
|
||||
uses
|
||||
SysUtils;
|
||||
|
||||
var
|
||||
i8: Int8;
|
||||
u8: UInt8;
|
||||
i16: Int16;
|
||||
u32: UInt32;
|
||||
u64: Uint64;
|
||||
i: Integer;
|
||||
s: AnsiString;
|
||||
|
||||
begin
|
||||
i8 := 15;
|
||||
s := IntToHex(i8);
|
||||
writeln(s);
|
||||
if s <> '0F' then halt(1);
|
||||
|
||||
u8 := 224;
|
||||
s := IntToHex(u8);
|
||||
writeln(s);
|
||||
if s <> 'E0' then halt(2);
|
||||
|
||||
i16 := 224;
|
||||
s := IntToHex(i16);
|
||||
writeln(s);
|
||||
if s <> '00E0' then halt(3);
|
||||
|
||||
u32 := 224;
|
||||
s := IntToHex(u32);
|
||||
writeln(s);
|
||||
if s <> '000000E0' then halt(4);
|
||||
|
||||
u64 := 224;
|
||||
s := IntToHex(u64);
|
||||
writeln(s);
|
||||
if s <> '00000000000000E0' then halt(5);
|
||||
|
||||
i := 224;
|
||||
s := IntToHex(i);
|
||||
writeln(s);
|
||||
if s <> '000000E0' then halt(6);
|
||||
|
||||
s := i8.ToHexString;
|
||||
writeln(s);
|
||||
if s <> '0F' then halt(7);
|
||||
|
||||
s := u8.ToHexString;
|
||||
writeln(s);
|
||||
if s <> 'E0' then halt(8);
|
||||
|
||||
s := i16.ToHexString;
|
||||
writeln(s);
|
||||
if s <> '00E0' then halt(9);
|
||||
|
||||
s := u32.ToHexString;
|
||||
writeln(s);
|
||||
if s <> '000000E0' then halt(10);
|
||||
|
||||
s := u64.ToHexString;
|
||||
writeln(s);
|
||||
if s <> '00000000000000E0' then halt(11);
|
||||
|
||||
s := i.ToHexString;
|
||||
writeln(s);
|
||||
if s <> '000000E0' then halt(12);
|
||||
|
||||
writeln('ok');
|
||||
//readln;
|
||||
end.
|
Loading…
Reference in New Issue
Block a user