File: trtti13.pp

package info (click to toggle)
fpc 3.2.2%2Bdfsg-49
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 341,452 kB
  • sloc: pascal: 3,820,194; xml: 194,356; ansic: 9,637; asm: 8,482; java: 5,346; sh: 4,813; yacc: 3,956; makefile: 2,705; lex: 2,661; javascript: 2,454; sql: 929; php: 474; cpp: 145; perl: 136; sed: 132; csh: 34; tcl: 7
file content (69 lines) | stat: -rw-r--r-- 1,978 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
program trtti13;

uses
  TypInfo;

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;
begin
  Inc(error);
  if aTI^.Kind <> aTypeKind then
    Halt(error);

  td := GetTypeData(aTI);

  Inc(error);
  if td^.OrdType <> aOrdType then
    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);
  TestOrdTypeInfo(PTypeInfo(TypeInfo(Int32)), tkInteger, otSLong);
  TestOrdTypeInfo(PTypeInfo(TypeInfo(Int64)), tkInt64, otSQWord);

  TestOrdTypeInfo(PTypeInfo(TypeInfo(UInt8)), tkInteger, otUByte);
  TestOrdTypeInfo(PTypeInfo(TypeInfo(UInt16)), tkInteger, otUWord);
  TestOrdTypeInfo(PTypeInfo(TypeInfo(UInt32)), tkInteger, otULong);
  TestOrdTypeInfo(PTypeInfo(TypeInfo(UInt64)), tkQWord, otUQWord);

  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.