瀏覽代碼

+ add test for Boolean RTTI

git-svn-id: trunk@35187 -
svenbarth 8 年之前
父節點
當前提交
150441627a
共有 2 個文件被更改,包括 87 次插入0 次删除
  1. 1 0
      .gitattributes
  2. 86 0
      tests/test/trtti14.pp

+ 1 - 0
.gitattributes

@@ -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 - 0
tests/test/trtti14.pp

@@ -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.