Skip to content

Commit

Permalink
IFDEF for XE around AreNotEqual was wrong (AreNotEqual for integers w…
Browse files Browse the repository at this point in the history
…as deactivated in versions after XE)
  • Loading branch information
jensweigele committed Oct 13, 2014
1 parent 9f27776 commit 20e5cae
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
7 changes: 3 additions & 4 deletions DUnitX.TestFramework.pas
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,8 @@ Assert = class
{$IFDEF DELPHI_XE_UP}
//Delphi 2010 compiler bug breaks this
class procedure AreNotEqual<T>(const left, right : T; const message : string = '');overload;
{$ELSE}
class procedure AreNotEqual(const left, right : Integer; const message : string = '');overload;
{$ENDIF}
class procedure AreNotEqual(const left, right : Integer; const message : string = '');overload;
class procedure AreNotEqualMemory(const left : Pointer; const right : Pointer; const size : Cardinal; const message : string = '');

class procedure AreSame(const left, right : TObject; const message : string = '');overload;
Expand Down Expand Up @@ -1163,13 +1162,13 @@ class procedure Assert.AreNotEqual<T>(const left, right: T; const message: strin
Fail(Format('left %s equals right %s %s',[leftValue.ToString, rightValue.ToString, message]), ReturnAddress);
end;
end;
{$ELSE}
{$ENDIF}

class procedure Assert.AreNotEqual(const left, right: Integer; const message: string);
begin
if left = right then
Fail(Format('left %d equals right %d %s' ,[left, right, message]), ReturnAddress);
end;
{$ENDIF}

class procedure Assert.AreNotEqual(const left, right: Extended; const message: string);
var
Expand Down
22 changes: 22 additions & 0 deletions Tests/DUnitX.Tests.Assert.pas
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ TTestsAssert = class
[Test]
procedure AreEqual_Throws_No_Exception_When_Values_Are_Exactly_Equal;
[Test]
procedure AreNotEqual_Integer_Throws_No_Exception_When_Values_Are_NotEqual;
[Test]
procedure AreNotEqual_Integer_Throws_Exception_When_Values_Are_Equal;
[Test]
procedure WillRaise_Without_Exception_Class_Will_Capture_Any_Exception;
[Test]
procedure WillRaiseWithMessage_Exception_And_Message_Will_Check_ExceptionClass_And_Exception_Message;
Expand Down Expand Up @@ -714,6 +718,24 @@ procedure TTestsAssert.Test_AreNotSameOnSameObjectWithDifferentInterfaces_Throws
end, ETestFailure);
end;

procedure TTestsAssert.AreNotEqual_Integer_Throws_No_Exception_When_Values_Are_NotEqual;
begin
Assert.WillNotRaise(
procedure
begin
Assert.AreNotEqual(1, 2);
end, ETestFailure);
end;

procedure TTestsAssert.AreNotEqual_Integer_Throws_Exception_When_Values_Are_Equal;
begin
Assert.WillRaise(
procedure
begin
Assert.AreNotEqual(1, 1);
end, ETestFailure);
end;

initialization
TDUnitX.RegisterTestFixture(TTestsAssert);
end.

0 comments on commit 20e5cae

Please sign in to comment.