View Issue Details

IDProjectCategoryView StatusLast Update
0034164FPCRTLpublic2018-08-21 16:20
ReporterFr0sTAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version3.1.1Product Build 
Target Version3.2.0Fixed in Version3.3.1 
Summary0034164: FPCUnit - Add AssertCount increment to TAssert.CheckIs and use ComparisonMsg in TAssert.CheckNotEquals
DescriptionThe patch adds AssertCount increment to TAssert.CheckIs (to eliminate "no assertions" warning) and replaces `msg + ComparisonMsg` with overloaded version `ComparisonMsg(msg` thus unifying construction of assert message.
TagsNo tags attached.
Fixed in Revision39660
FPCOldBugId
FPCTarget
Attached Files
  • dunit.diff (2,384 bytes)
    Index: DUnitCompatibleInterface.inc
    ===================================================================
    --- DUnitCompatibleInterface.inc	(revision 39659)
    +++ DUnitCompatibleInterface.inc	(working copy)
    @@ -106,7 +106,7 @@
     class procedure TAssert.CheckNotEquals(expected, actual: string; msg: string);
     begin
       if AnsiCompareStr(Expected, Actual) = 0 then
    -    Fail(msg + ComparisonMsg(Expected, Actual, false))
    +    Fail(ComparisonMsg(msg, Expected, Actual, false))
       else
         Inc(AssertCount);
     end;
    @@ -114,7 +114,7 @@
     class procedure TAssert.CheckNotEquals(expected, actual: unicodestring; msg: string);
     begin
       if (Expected=Actual) then
    -    Fail(msg + ComparisonMsg(Expected, Actual, false))
    +    Fail(ComparisonMsg(msg, Expected, Actual, false))
       else
         Inc(AssertCount);
     end;
    @@ -122,7 +122,7 @@
     class procedure TAssert.CheckNotEquals(expected, actual: integer; msg: string);
     begin
       if (expected = actual) then
    -    Fail(msg + ComparisonMsg(IntToStr(expected), IntToStr(actual), false))
    +    Fail(ComparisonMsg(msg, IntToStr(expected), IntToStr(actual), false))
       else
         Inc(AssertCount);
     end;
    @@ -130,7 +130,7 @@
     class procedure TAssert.CheckNotEquals(expected, actual: boolean; msg: string);
     begin
       if (expected = actual) then
    -    Fail(msg + ComparisonMsg(BoolToStr(expected), BoolToStr(actual), false))
    +    Fail(ComparisonMsg(msg, BoolToStr(expected), BoolToStr(actual), false))
       else
         Inc(AssertCount);
     end;
    @@ -148,7 +148,7 @@
       msg: string);
     begin
       if (expected = actual) then
    -    Fail(msg + ComparisonMsg(IntToStr(expected), IntToStr(actual), false))
    +    Fail(ComparisonMsg(msg, IntToStr(expected), IntToStr(actual), false))
       else
         Inc(AssertCount);
     end;
    @@ -157,7 +157,7 @@
       msg: string);
     begin
       if (expected = actual) then
    -    Fail(msg + ComparisonMsg(IntToStr(expected), IntToStr(actual), false))
    +    Fail(ComparisonMsg(msg, IntToStr(expected), IntToStr(actual), false))
       else
         Inc(AssertCount);
     end;
    @@ -188,7 +188,9 @@
       if obj = nil then
         Fail(ComparisonMsg(msg, pClass.ClassName, 'nil'))
       else if not obj.ClassType.InheritsFrom(pClass) then
    -    Fail(ComparisonMsg(msg, pClass.ClassName, obj.ClassName));
    +    Fail(ComparisonMsg(msg, pClass.ClassName, obj.ClassName))
    +  else
    +    Inc(AssertCount);
     end;
     
     class procedure TAssert.CheckSame(expected, actual: TObject; msg: string);
    
    dunit.diff (2,384 bytes)

Activities

Fr0sT

2018-08-21 15:17

reporter  

dunit.diff (2,384 bytes)
Index: DUnitCompatibleInterface.inc
===================================================================
--- DUnitCompatibleInterface.inc	(revision 39659)
+++ DUnitCompatibleInterface.inc	(working copy)
@@ -106,7 +106,7 @@
 class procedure TAssert.CheckNotEquals(expected, actual: string; msg: string);
 begin
   if AnsiCompareStr(Expected, Actual) = 0 then
-    Fail(msg + ComparisonMsg(Expected, Actual, false))
+    Fail(ComparisonMsg(msg, Expected, Actual, false))
   else
     Inc(AssertCount);
 end;
@@ -114,7 +114,7 @@
 class procedure TAssert.CheckNotEquals(expected, actual: unicodestring; msg: string);
 begin
   if (Expected=Actual) then
-    Fail(msg + ComparisonMsg(Expected, Actual, false))
+    Fail(ComparisonMsg(msg, Expected, Actual, false))
   else
     Inc(AssertCount);
 end;
@@ -122,7 +122,7 @@
 class procedure TAssert.CheckNotEquals(expected, actual: integer; msg: string);
 begin
   if (expected = actual) then
-    Fail(msg + ComparisonMsg(IntToStr(expected), IntToStr(actual), false))
+    Fail(ComparisonMsg(msg, IntToStr(expected), IntToStr(actual), false))
   else
     Inc(AssertCount);
 end;
@@ -130,7 +130,7 @@
 class procedure TAssert.CheckNotEquals(expected, actual: boolean; msg: string);
 begin
   if (expected = actual) then
-    Fail(msg + ComparisonMsg(BoolToStr(expected), BoolToStr(actual), false))
+    Fail(ComparisonMsg(msg, BoolToStr(expected), BoolToStr(actual), false))
   else
     Inc(AssertCount);
 end;
@@ -148,7 +148,7 @@
   msg: string);
 begin
   if (expected = actual) then
-    Fail(msg + ComparisonMsg(IntToStr(expected), IntToStr(actual), false))
+    Fail(ComparisonMsg(msg, IntToStr(expected), IntToStr(actual), false))
   else
     Inc(AssertCount);
 end;
@@ -157,7 +157,7 @@
   msg: string);
 begin
   if (expected = actual) then
-    Fail(msg + ComparisonMsg(IntToStr(expected), IntToStr(actual), false))
+    Fail(ComparisonMsg(msg, IntToStr(expected), IntToStr(actual), false))
   else
     Inc(AssertCount);
 end;
@@ -188,7 +188,9 @@
   if obj = nil then
     Fail(ComparisonMsg(msg, pClass.ClassName, 'nil'))
   else if not obj.ClassType.InheritsFrom(pClass) then
-    Fail(ComparisonMsg(msg, pClass.ClassName, obj.ClassName));
+    Fail(ComparisonMsg(msg, pClass.ClassName, obj.ClassName))
+  else
+    Inc(AssertCount);
 end;
 
 class procedure TAssert.CheckSame(expected, actual: TObject; msg: string);
dunit.diff (2,384 bytes)

Michael Van Canneyt

2018-08-21 15:25

administrator   ~0110192

Checked and applied. Thanks for the patch!

Fr0sT

2018-08-21 16:20

reporter   ~0110198

Wow that was really fast :)

Issue History

Date Modified Username Field Change
2018-08-21 15:17 Fr0sT New Issue
2018-08-21 15:17 Fr0sT File Added: dunit.diff
2018-08-21 15:22 Michael Van Canneyt Assigned To => Michael Van Canneyt
2018-08-21 15:22 Michael Van Canneyt Status new => assigned
2018-08-21 15:25 Michael Van Canneyt Fixed in Revision => 39660
2018-08-21 15:25 Michael Van Canneyt Note Added: 0110192
2018-08-21 15:25 Michael Van Canneyt Status assigned => resolved
2018-08-21 15:25 Michael Van Canneyt Fixed in Version => 3.3.1
2018-08-21 15:25 Michael Van Canneyt Resolution open => fixed
2018-08-21 15:25 Michael Van Canneyt Target Version => 3.2.0
2018-08-21 16:20 Fr0sT Note Added: 0110198
2018-08-21 16:20 Fr0sT Status resolved => closed