View Issue Details

IDProjectCategoryView StatusLast Update
0012753FPCFCLpublic2009-03-20 13:00
ReporterGraeme Geldenhuys Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionfixed 
Platformx86OSUbuntu Linux 
Product Version2.3.1 
Fixed in Version2.4.0 
Summary0012753: [patch] - fpcunit and DUnit interface compatibility
DescriptionAttached is a minor patch to add a few more functions for better FPCUnit & DUnit compatibility.

Could this please be merged to FPC 2.2.3 as well? It is not an invasive patch.

NOTE:
  Patch needs to be applied from the 'packages' directory.

TagsNo tags attached.
Fixed in Revision12302
FPCOldBugId
FPCTarget
Attached Files

Activities

2008-12-05 10:18

 

fcl-fpcunit.patch (3,050 bytes)   
Index: fcl-fpcunit/src/fpcunit.pp
===================================================================
--- fcl-fpcunit/src/fpcunit.pp	(revision 12301)
+++ fcl-fpcunit/src/fpcunit.pp	(working copy)
@@ -309,7 +309,13 @@
 uses
   testutils;
 
+Const
+  sExpectedButWasFmt = 'Expected:' + LineEnding + '"%s"' + LineEnding + 'But was:' + LineEnding + '"%s"';
+  sExpectedButWasAndMessageFmt = '%s' + LineEnding + sExpectedButWasFmt;
+  sMsgActualEqualsExpFmt = '%s' + LineEnding + 'Expected ' + LineEnding + '< %s > ' + LineEnding + 'equals actual ' + LineEnding + '< %s >';
+  sActualEqualsExpFmt = 'Expected ' + LineEnding + '< %s > ' + LineEnding + 'equals actual ' + LineEnding + '< %s >';
 
+
 { This lets us use a single include file for both the Interface and
   Implementation sections. }
 {$undef read_interface}
Index: fcl-fpcunit/src/DUnitCompatibleInterface.inc
===================================================================
--- fcl-fpcunit/src/DUnitCompatibleInterface.inc	(revision 12301)
+++ fcl-fpcunit/src/DUnitCompatibleInterface.inc	(working copy)
@@ -19,9 +19,14 @@
     class procedure CheckIs(obj :TObject; pClass: TClass; msg: string = ''); overload;
     class procedure CheckSame(expected, actual: TObject; msg: string = ''); overload;
     class procedure FailNotEquals(expected, actual: string; msg: string = ''; errorAddr: Pointer = nil); virtual;
+    class procedure CheckTrue(condition: Boolean; msg: string);
+    class procedure CheckFalse(condition: Boolean; msg: string);
+    class function  EqualsErrorMessage(const expected, actual: string; const ErrorMsg: string): string;
+    class function  NotEqualsErrorMessage(const expected, actual: string; const ErrorMsg: string): string;
 
     class function Suite: TTest;
 
+
     {
     *** TODO  ***
     procedure CheckEqualsBin(expected, actual: longword; msg: string = ''; digits: integer=32); virtual;
@@ -135,6 +140,36 @@
   Fail(msg + ComparisonMsg(Expected, Actual));
 end;
 
+class procedure TAssert.CheckTrue(condition: Boolean; msg: string);
+begin
+  if (not condition) then
+      FailNotEquals(BoolToStr(true, true), BoolToStr(false, true), msg, nil);
+end;
+
+class procedure TAssert.CheckFalse(condition: Boolean; msg: string);
+begin
+  if (condition) then
+      FailNotEquals(BoolToStr(false, true), BoolToStr(true, true), msg, nil);
+end;
+
+class function TAssert.EqualsErrorMessage(const expected, actual: string;
+    const ErrorMsg: string): string;
+begin
+  if (ErrorMsg <> '') then
+    Result := Format(sMsgActualEqualsExpFmt, [ErrorMsg + ', ', expected, actual])
+  else
+    Result := Format(sActualEqualsExpFmt, [expected, actual])
+end;
+
+class function TAssert.NotEqualsErrorMessage(const expected, actual: string;
+    const ErrorMsg: string): string;
+begin
+  if (ErrorMsg <> '') then
+    Result := Format(sExpectedButWasAndMessageFmt, [ErrorMsg, expected, actual])
+  else
+    Result := Format(sExpectedButWasFmt, [expected, actual]);
+end;
+
 class function TAssert.Suite: TTest;
 begin
   result := TTestSuite.Create(self);
fcl-fpcunit.patch (3,050 bytes)   

Michael Van Canneyt

2008-12-05 10:47

administrator   ~0023680

Applied, thanks for the patch.

Issue History

Date Modified Username Field Change
2008-12-05 10:18 Graeme Geldenhuys New Issue
2008-12-05 10:18 Graeme Geldenhuys File Added: fcl-fpcunit.patch
2008-12-05 10:46 Michael Van Canneyt Status new => assigned
2008-12-05 10:46 Michael Van Canneyt Assigned To => Michael Van Canneyt
2008-12-05 10:47 Michael Van Canneyt Fixed in Revision => 12302
2008-12-05 10:47 Michael Van Canneyt Status assigned => resolved
2008-12-05 10:47 Michael Van Canneyt Fixed in Version => 2.3.1
2008-12-05 10:47 Michael Van Canneyt Resolution open => fixed
2008-12-05 10:47 Michael Van Canneyt Note Added: 0023680
2009-03-20 13:00 Jonas Maebe Status resolved => closed