Bläddra i källkod

* add check if tests are successfull or not

peter 23 år sedan
förälder
incheckning
87e2ea1732
1 ändrade filer med 45 tillägg och 24 borttagningar
  1. 45 24
      tests/test/cg/tcnvint2.pp

+ 45 - 24
tests/test/cg/tcnvint2.pp

@@ -15,6 +15,8 @@
 {****************************************************************}
 program tcnvint2;
 
+var
+  failed   : boolean;
 
    function getbyte: byte;
      begin
@@ -38,6 +40,13 @@ program tcnvint2;
      end;
 {$endif}
 
+   procedure Test(const s:string;b:boolean);
+     begin
+       Writeln(s,b);
+       if not b then
+        failed:=true;
+     end;
+
 var
  frombyte : byte;
  fromword : word;
@@ -45,6 +54,7 @@ var
 {$ifdef fpc}
  fromint64 : int64;
 {$endif}
+ b   : boolean;
  bb1 : bytebool;
  wb1 : wordbool;
  lb1 : longbool;
@@ -52,117 +62,128 @@ var
  wb2 : wordbool;
  lb2 : longbool;
 begin
+ failed:=false;
 
  { left : LOC_REGISTER  }
  { from : LOC_REFERENCE }
- WriteLn('Testing LOC_REFERENCE...');
+ Writeln('Testing LOC_REFERENCE...');
  frombyte := $10;
  bb1 := bytebool(frombyte);
- WriteLn('byte-> bytebool : Value should be TRUE...',bb1);
+ Test('byte-> bytebool : Value should be TRUE...',bb1);
  frombyte := $10;
  wb1 := wordbool(frombyte);
- WriteLn('byte -> wordbool : Value should be TRUE...',wb1);
+ Test('byte -> wordbool : Value should be TRUE...',wb1);
  { ------------------------------------------------------------   }
  { WARNING : This test fails under Borland Pascal v7, but         }
  { works under Delphi 3.0 (normally it should give TRUE).         }
  { ------------------------------------------------------------   }
  fromword := $1000;
  wb1 := wordbool(fromword);
- WriteLn('word -> wordbool : Value should be TRUE...',wb1);
+ Test('word -> wordbool : Value should be TRUE...',wb1);
  frombyte := $10;
  lb1 := longbool(frombyte);
- WriteLn('byte -> longbool : Value should be TRUE...',lb1);
+ Test('byte -> longbool : Value should be TRUE...',lb1);
  { ------------------------------------------------------------   }
  { WARNING : This test fails under Borland Pascal v7, but         }
  { works under Delphi 3.0 (normally it should give TRUE).         }
  { ------------------------------------------------------------   }
  fromword := $1000;
  lb1 := longbool(fromword);
- WriteLn('word -> longbool : Value should be TRUE...',lb1);
+ Test('word -> longbool : Value should be TRUE...',lb1);
+ if not lb1 then
+  failed:=true;
  { ------------------------------------------------------------   }
  { WARNING : This test fails under Borland Pascal v7, but         }
  { works under Delphi 3.0 (normally it should give TRUE).         }
  { ------------------------------------------------------------   }
  fromlong := $00000100;
  lb1 := longbool(fromlong);
- WriteLn('longint -> longbool : Value should be TRUE...',lb1);
+ Test('longint -> longbool : Value should be TRUE...',lb1);
 {$ifdef fpc}
  fromint64 := $10000000;
  lb1 := longbool(fromint64);
- WriteLn('int64 -> longbool : Value should be TRUE...',lb1);
+ Test('int64 -> longbool : Value should be TRUE...',lb1);
 {$endif}
  { left : LOC_REGISTER  }
- WriteLn('Testing LOC_REGISTER...');
+ Writeln('Testing LOC_REGISTER...');
  frombyte := $10;
  bb1 := bytebool(getbyte);
- WriteLn('byte-> bytebool : Value should be TRUE...',bb1);
+ Test('byte-> bytebool : Value should be TRUE...',bb1);
  frombyte := $10;
  wb1 := wordbool(getbyte);
- WriteLn('byte -> wordbool : Value should be TRUE...',wb1);
+ Test('byte -> wordbool : Value should be TRUE...',wb1);
  { ------------------------------------------------------------   }
  { WARNING : This test fails under Borland Pascal v7, but         }
  { works under Delphi 3.0 (normally it should give TRUE).         }
  { ------------------------------------------------------------   }
  fromword := $1000;
  wb1 := wordbool(getword);
- WriteLn('word -> wordbool : Value should be TRUE...',wb1);
+ Test('word -> wordbool : Value should be TRUE...',wb1);
  frombyte := $10;
  lb1 := longbool(getbyte);
- WriteLn('byte -> longbool : Value should be TRUE...',lb1);
+ Test('byte -> longbool : Value should be TRUE...',lb1);
  { ------------------------------------------------------------   }
  { WARNING : This test fails under Borland Pascal v7, but         }
  { works under Delphi 3.0 (normally it should give TRUE).         }
  { ------------------------------------------------------------   }
  fromword := $1000;
  lb1 := longbool(getword);
- WriteLn('word -> longbool : Value should be TRUE...',lb1);
+ Test('word -> longbool : Value should be TRUE...',lb1);
  { ------------------------------------------------------------   }
  { WARNING : This test fails under Borland Pascal v7, but         }
  { works under Delphi 3.0 (normally it should give TRUE).         }
  { ------------------------------------------------------------   }
  fromlong := $00000100;
  lb1 := longbool(getlongint);
- WriteLn('longint -> longbool : Value should be TRUE...',lb1);
+ Test('longint -> longbool : Value should be TRUE...',lb1);
 {$ifdef fpc}
  fromint64 := $10000000;
  lb1 := longbool(getint64);
- WriteLn('int64 -> longbool : Value should be TRUE...',lb1);
+ Test('int64 -> longbool : Value should be TRUE...',lb1);
 {$endif}
 (* CURRENTLY NEVER GOES INTO THE LOC_FLAGS LOCATION!
  { left : LOC_FLAGS  }
- WriteLn('Testing LOC_FLAGS...');
+ Test('Testing LOC_FLAGS...');
  frombyte := 10;
  fromword := 2;
  bb1 := bytebool(frombyte > fromword);
- WriteLn('Value should be TRUE...',bb1);
+ Test('Value should be TRUE...',bb1);
  frombyte := $10;
  fromword := 2;
  wb1 := wordbool(frombyte > fromword);
- WriteLn('Value should be TRUE...',wb1);
+ Test('Value should be TRUE...',wb1);
  fromword := $1000;
  fromlong := $4000;
  wb1 := wordbool(fromlong > fromword);
- WriteLn('Value should be TRUE...',wb1);
+ Test('Value should be TRUE...',wb1);
  frombyte := $10;
  fromword := $20;
  lb1 := longbool(fromword > frombyte);
- WriteLn('Value should be TRUE...',lb1);
+ Test('Value should be TRUE...',lb1);
  fromword := $1000;
  fromlong := $0100;
  lb1 := longbool(fromlong > fromword);
- WriteLn('Value should be FALSE...',lb1);
+ Test('Value should be FALSE...',lb1);
 {$ifdef fpc}
  fromint64 := $10000000;
  fromlong := $02;
  lb1 := longbool(fromint64 > fromlong);
- WriteLn('Value should be TRUE...',lb1);
+ Test('Value should be TRUE...',lb1);
 {$endif}
 *)
+  if failed then
+   begin
+     Writeln('Some tests failed!');
+     halt(1);
+   end;
 end.
 
 {
    $Log$
-   Revision 1.1  2001-08-31 23:56:45  carl
+   Revision 1.2  2002-03-29 12:36:03  peter
+     * add check if tests are successfull or not
+
+   Revision 1.1  2001/08/31 23:56:45  carl
    + first revision (missing LOC_FLAGS location test)