mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-12 10:49:31 +02:00
+ add test for Boolean RTTI
git-svn-id: trunk@35187 -
This commit is contained in:
parent
7023a6f95b
commit
150441627a
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -13011,6 +13011,7 @@ tests/test/trtti10.pp svneol=native#text/pascal
|
||||
tests/test/trtti11.pp svneol=native#text/pascal
|
||||
tests/test/trtti12.pp svneol=native#text/pascal
|
||||
tests/test/trtti13.pp svneol=native#text/pascal
|
||||
tests/test/trtti14.pp svneol=native#text/pascal
|
||||
tests/test/trtti2.pp svneol=native#text/plain
|
||||
tests/test/trtti3.pp svneol=native#text/plain
|
||||
tests/test/trtti4.pp svneol=native#text/plain
|
||||
|
86
tests/test/trtti14.pp
Normal file
86
tests/test/trtti14.pp
Normal file
@ -0,0 +1,86 @@
|
||||
program trtti14;
|
||||
|
||||
uses
|
||||
TypInfo;
|
||||
|
||||
var
|
||||
error: LongInt = 0;
|
||||
|
||||
procedure TestBooleanInfo(aTI: PTypeInfo; aOrdType: TOrdType; aWinBool: Boolean);
|
||||
var
|
||||
td: PTypeData;
|
||||
begin
|
||||
Inc(error);
|
||||
if aTI^.Kind <> tkBool then
|
||||
Halt(error);
|
||||
|
||||
td := GetTypeData(aTI);
|
||||
|
||||
Inc(error);
|
||||
if td^.OrdType <> aOrdType then
|
||||
Halt(error);
|
||||
|
||||
if aWinBool then begin
|
||||
case td^.OrdType of
|
||||
otSQWord: begin
|
||||
Inc(error);
|
||||
if td^.MaxInt64Value <> High(Int64) then
|
||||
Halt(error);
|
||||
Inc(error);
|
||||
if td^.MinInt64Value <> Low(Int64) then
|
||||
Halt(error);
|
||||
end;
|
||||
otUByte,
|
||||
otUWord,
|
||||
otULong,
|
||||
otUQWord: begin
|
||||
Inc(error);
|
||||
Halt(error);
|
||||
end;
|
||||
else
|
||||
Inc(error);
|
||||
if td^.MaxValue <> High(LongInt) then
|
||||
Halt(error);
|
||||
Inc(error);
|
||||
if td^.MinValue <> Low(LongInt) then
|
||||
Halt(error);
|
||||
end;
|
||||
end else begin
|
||||
case td^.OrdType of
|
||||
otUQWord: begin
|
||||
Inc(error);
|
||||
if td^.MaxQWordValue <> 1 then
|
||||
Halt(error);
|
||||
Inc(error);
|
||||
if td^.MinQWordValue <> 0 then
|
||||
Halt(error);
|
||||
end;
|
||||
otSByte,
|
||||
otSWord,
|
||||
otSLong,
|
||||
otSQWord: begin
|
||||
Inc(error);
|
||||
Halt(error);
|
||||
end;
|
||||
else
|
||||
Inc(error);
|
||||
if td^.MaxValue <> 1 then
|
||||
Halt(error);
|
||||
Inc(error);
|
||||
if td^.MinValue <> 0 then
|
||||
Halt(error);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
TestBooleanInfo(PTypeInfo(TypeInfo(Boolean)), otUByte, False);
|
||||
TestBooleanInfo(PTypeInfo(TypeInfo(Boolean16)), otUWord, False);
|
||||
TestBooleanInfo(PTypeInfo(TypeInfo(Boolean32)), otULong, False);
|
||||
TestBooleanInfo(PTypeInfo(TypeInfo(Boolean64)), otUQWord, False);
|
||||
|
||||
TestBooleanInfo(PTypeInfo(TypeInfo(ByteBool)), otSByte, True);
|
||||
TestBooleanInfo(PTypeInfo(TypeInfo(WordBool)), otSWord, True);
|
||||
TestBooleanInfo(PTypeInfo(TypeInfo(LongBool)), otSLong, True);
|
||||
TestBooleanInfo(PTypeInfo(TypeInfo(QWordBool)), otSQWord, True);
|
||||
end.
|
Loading…
Reference in New Issue
Block a user