* extend test for 64-bit subranges

git-svn-id: trunk@35179 -
This commit is contained in:
svenbarth 2016-12-23 15:11:38 +00:00
parent 00751d257e
commit 8e765ef807

View File

@ -6,6 +6,17 @@ uses
var
error: LongInt = 0;
const
RangedInt64Min = $FFFFFFFF00000000;
RangedInt64Max = $100000000;
RangedQWordMin = QWord($100000000);
RangedQWordMax = QWord($8000000000000000);
type
TRangedInt64 = RangedInt64Min..RangedInt64Max;
TRangedQWord = RangedQWordMin..RangedQWordMax;
procedure TestOrdTypeInfo(aTI: PTypeInfo; aTypeKind: TTypeKind; aOrdType: TOrdType);
var
td: PTypeData;
@ -21,6 +32,25 @@ begin
Halt(error);
end;
procedure TestMinMax64(aTI: PTypeInfo; aMin, aMax: Int64);
var
td: PTypeData;
begin
td := GetTypeData(aTI);
Inc(error);
if (td^.OrdType=otSQWord) and (td^.MinInt64Value<>Int64(aMin)) then
Halt(error);
if (td^.OrdType=otUQWord) and (td^.MinQWordValue<>QWord(aMin)) then
Halt(error);
Inc(error);
if (td^.OrdType=otSQWord) and (td^.MaxInt64Value<>Int64(aMax)) then
Halt(error);
if (td^.OrdType=otUQWord) and (td^.MaxQWordValue<>QWord(aMax)) then
Halt(error);
end;
begin
TestOrdTypeInfo(PTypeInfo(TypeInfo(Int8)), tkInteger, otSByte);
TestOrdTypeInfo(PTypeInfo(TypeInfo(Int16)), tkInteger, otSWord);
@ -32,19 +62,8 @@ begin
TestOrdTypeInfo(PTypeInfo(TypeInfo(UInt32)), tkInteger, otULong);
TestOrdTypeInfo(PTypeInfo(TypeInfo(UInt64)), tkQWord, otUQWord);
Inc(error);
if GetTypeData(PTypeInfo(TypeInfo(Int64)))^.MinInt64Value <> Low(Int64) then
Halt(error);
Inc(error);
if GetTypeData(PTypeInfo(TypeInfo(Int64)))^.MaxInt64Value <> High(Int64) then
Halt(error);
Inc(error);
if GetTypeData(PTypeInfo(TypeInfo(UInt64)))^.MinQWordValue <> Low(QWord) then
Halt(error);
Inc(error);
if GetTypeData(PTypeInfo(TypeInfo(UInt64)))^.MaxQWordValue <> High(QWord) then
Halt(error);
TestMinMax64(PTypeInfo(TypeInfo(Int64)), Low(Int64), High(Int64));
TestMinMax64(PTypeInfo(TypeInfo(TRangedInt64)), RangedInt64Min, RangedInt64Max);
TestMinMax64(PTypeInfo(TypeInfo(QWord)), Int64(Low(QWord)), Int64(High(QWord)));
TestMinMax64(PTypeInfo(TypeInfo(TRangedQWord)), Int64(RangedQWordMin), Int64(RangedQWordMax));
end.