Browse Source

Check condition before getting error address / only execute when needed

Martin 2 months ago
parent
commit
a291258bf8
1 changed files with 5 additions and 1 deletions
  1. 5 1
      packages/fcl-fpcunit/src/fpcunit.pp

+ 5 - 1
packages/fcl-fpcunit/src/fpcunit.pp

@@ -758,9 +758,13 @@ end;
 class procedure TAssert.AssertFalse(const AMessage: string; ACondition: boolean; AErrorAddrs: Pointer = nil
   );
 begin
+  if not ACondition then begin
+    Inc(AssertCount); // Fail will increae AssertCount
+    exit;
+  end;
   if AErrorAddrs=Nil then
     AErrorAddrs:=CallerAddr;
-  AssertTrue(AMessage, not ACondition,AErrorAddrs);
+  Fail(AMessage, AErrorAddrs);
 end;
 
 class procedure TAssert.AssertFalse(const AMessage: string; const AFormatArgs: array of const;