Przeglądaj źródła

* Added unsigned versions of the "tval" tests

J. Gareth "Curious Kit" Moreton 1 rok temu
rodzic
commit
0418078805
2 zmienionych plików z 67 dodań i 0 usunięć
  1. 32 0
      tests/test/cg/tval1a.pp
  2. 35 0
      tests/test/cg/tval2a.pp

+ 32 - 0
tests/test/cg/tval1a.pp

@@ -0,0 +1,32 @@
+{ %OPT=-O3 }
+
+{$mode objfpc}
+
+program tval1a;
+
+function TryStrToInt(const s: string; out i: LongWord): boolean; inline;
+var
+  Error : word;
+begin
+  Val(s, i, Error);
+  TryStrToInt:=(Error=0)
+end;
+
+procedure DoTest;
+var
+  Output: LongWord;
+begin
+  if TryStrToInt('Invalid', Output) then
+    Halt(1);
+
+  if not TryStrToInt('2', Output) then
+    Halt(2);
+	
+  if Output <> 2 then
+    Halt(3);
+end;
+
+begin
+  DoTest(); { This is so "Output" is a local variable rather than global }
+  WriteLn('ok');
+end.

+ 35 - 0
tests/test/cg/tval2a.pp

@@ -0,0 +1,35 @@
+{ %OPT=-O3 }
+
+{$mode objfpc}
+
+program tval2a;
+
+const
+  SResStr = 'Invalid2';
+
+function TryStrToInt(const s: string; out i: LongWord): boolean; inline;
+var
+  Error : word;
+begin
+  Val(s, i, Error);
+  TryStrToInt:=(Error=0)
+end;
+
+procedure DoTest;
+var
+  Output: LongWord;
+begin
+  if TryStrToInt(SResStr, Output) then
+    Halt(1);
+
+  if not TryStrToInt(SResStr[8], Output) then
+    Halt(2);
+	
+  if Output <> 2 then
+    Halt(3);
+end;
+
+begin
+  DoTest(); { This is so "Output" is a local variable rather than global }
+  WriteLn('ok');
+end.