mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-22 17:09:27 +02:00
* fix for Mantis #35150: correctly convert Int64/QWord values to OleVariant (Delphi compatible)
+ added test git-svn-id: trunk@41571 -
This commit is contained in:
parent
07b1a3d211
commit
9a9c6a3ff4
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -11797,6 +11797,7 @@ tests/tbs/tb0651.pp svneol=native#text/pascal
|
|||||||
tests/tbs/tb0652.pp svneol=native#text/pascal
|
tests/tbs/tb0652.pp svneol=native#text/pascal
|
||||||
tests/tbs/tb0653.pp svneol=native#text/plain
|
tests/tbs/tb0653.pp svneol=native#text/plain
|
||||||
tests/tbs/tb0654.pp svneol=native#text/plain
|
tests/tbs/tb0654.pp svneol=native#text/plain
|
||||||
|
tests/tbs/tb0655.pp svneol=native#text/pascal
|
||||||
tests/tbs/tb205.pp svneol=native#text/plain
|
tests/tbs/tb205.pp svneol=native#text/plain
|
||||||
tests/tbs/tb610.pp svneol=native#text/pascal
|
tests/tbs/tb610.pp svneol=native#text/pascal
|
||||||
tests/tbs/tb613.pp svneol=native#text/plain
|
tests/tbs/tb613.pp svneol=native#text/plain
|
||||||
|
@ -2491,9 +2491,22 @@ end;
|
|||||||
procedure sysolevarfromint(var Dest : olevariant; const Source : Int64; const range : ShortInt);
|
procedure sysolevarfromint(var Dest : olevariant; const Source : Int64; const range : ShortInt);
|
||||||
begin
|
begin
|
||||||
DoVarClearIfComplex(TVarData(Dest));
|
DoVarClearIfComplex(TVarData(Dest));
|
||||||
|
{ 64-bit values have their own types, all smaller ones are stored as signed 32-bit value }
|
||||||
with TVarData(Dest) do begin
|
with TVarData(Dest) do begin
|
||||||
vInteger := Source;
|
case range of
|
||||||
vType := varInteger;
|
-8: begin
|
||||||
|
vInt64 := Int64(Source);
|
||||||
|
vType := varInt64;
|
||||||
|
end;
|
||||||
|
8: begin
|
||||||
|
vQWord := QWord(Source);
|
||||||
|
vType := varQWord;
|
||||||
|
end;
|
||||||
|
else begin
|
||||||
|
vInteger := LongInt(Source);
|
||||||
|
vType := varInteger;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
115
tests/tbs/tb0655.pp
Normal file
115
tests/tbs/tb0655.pp
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
program tb0655;
|
||||||
|
|
||||||
|
uses
|
||||||
|
Variants;
|
||||||
|
|
||||||
|
var
|
||||||
|
s8: Int8 = $12;
|
||||||
|
u8: UInt8 = $98;
|
||||||
|
s16: Int16 = $1234;
|
||||||
|
u16: UInt16 = $9876;
|
||||||
|
s32: Int32 = $12345768;
|
||||||
|
u32: UInt32 = $98765432;
|
||||||
|
s64: Int64 = $1234567812345678;
|
||||||
|
u64: UInt64 = UInt64($9876543298765432);
|
||||||
|
v: Variant;
|
||||||
|
ov: OleVariant;
|
||||||
|
begin
|
||||||
|
v := s8;
|
||||||
|
if VarType(v) <> varShortInt then
|
||||||
|
Halt(1);
|
||||||
|
if Int8(v) <> s8 then
|
||||||
|
Halt(2);
|
||||||
|
|
||||||
|
v := u8;
|
||||||
|
if VarType(v) <> varByte then
|
||||||
|
Halt(3);
|
||||||
|
if UInt8(v) <> u8 then
|
||||||
|
Halt(4);
|
||||||
|
|
||||||
|
v := s16;
|
||||||
|
if VarType(v) <> varSmallInt then
|
||||||
|
Halt(5);
|
||||||
|
if Int16(v) <> s16 then
|
||||||
|
Halt(6);
|
||||||
|
|
||||||
|
v := u16;
|
||||||
|
if VarType(v) <> varWord then
|
||||||
|
Halt(7);
|
||||||
|
if UInt16(v) <> u16 then
|
||||||
|
Halt(8);
|
||||||
|
|
||||||
|
v := s32;
|
||||||
|
if VarType(v) <> varInteger then
|
||||||
|
Halt(9);
|
||||||
|
if Int32(v) <> s32 then
|
||||||
|
Halt(10);
|
||||||
|
|
||||||
|
v := u32;
|
||||||
|
if VarType(v) <> varLongWord then
|
||||||
|
Halt(11);
|
||||||
|
if UInt32(v) <> u32 then
|
||||||
|
Halt(12);
|
||||||
|
|
||||||
|
v := s64;
|
||||||
|
if VarType(v) <> varInt64 then
|
||||||
|
Halt(13);
|
||||||
|
if Int64(v) <> s64 then
|
||||||
|
Halt(14);
|
||||||
|
|
||||||
|
v := u64;
|
||||||
|
if VarType(v) <> varUInt64 then
|
||||||
|
Halt(15);
|
||||||
|
if UInt64(v) <> u64 then
|
||||||
|
Halt(16);
|
||||||
|
|
||||||
|
{ OleVariant has slightly different behaviour to Variant }
|
||||||
|
ov := s8;
|
||||||
|
if VarType(ov) <> varInteger then
|
||||||
|
Halt(17);
|
||||||
|
if Int8(ov) <> s8 then
|
||||||
|
Halt(18);
|
||||||
|
|
||||||
|
ov := u8;
|
||||||
|
if VarType(ov) <> varInteger then
|
||||||
|
Halt(19);
|
||||||
|
if UInt8(ov) <> u8 then
|
||||||
|
Halt(20);
|
||||||
|
|
||||||
|
ov := s16;
|
||||||
|
if VarType(ov) <> varInteger then
|
||||||
|
Halt(21);
|
||||||
|
if Int16(ov) <> s16 then
|
||||||
|
Halt(22);
|
||||||
|
|
||||||
|
ov := u16;
|
||||||
|
if VarType(ov) <> varInteger then
|
||||||
|
Halt(23);
|
||||||
|
if UInt16(ov) <> u16 then
|
||||||
|
Halt(24);
|
||||||
|
|
||||||
|
ov := s32;
|
||||||
|
if VarType(ov) <> varInteger then
|
||||||
|
Halt(25);
|
||||||
|
if Int32(ov) <> s32 then
|
||||||
|
Halt(26);
|
||||||
|
|
||||||
|
ov := u32;
|
||||||
|
if VarType(ov) <> varInteger then
|
||||||
|
Halt(27);
|
||||||
|
{ ! }
|
||||||
|
if UInt32(Int32(ov)) <> u32 then
|
||||||
|
Halt(28);
|
||||||
|
|
||||||
|
ov := s64;
|
||||||
|
if VarType(ov) <> varInt64 then
|
||||||
|
Halt(29);
|
||||||
|
if Int64(ov) <> s64 then
|
||||||
|
Halt(30);
|
||||||
|
|
||||||
|
ov := u64;
|
||||||
|
if VarType(ov) <> varUInt64 then
|
||||||
|
Halt(31);
|
||||||
|
if UInt64(ov) <> u64 then
|
||||||
|
Halt(32);
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user