|
@@ -285,12 +285,13 @@ type
|
|
property StartingTime: TDateTime read FStartingTime;
|
|
property StartingTime: TDateTime read FStartingTime;
|
|
end;
|
|
end;
|
|
|
|
|
|
- function ComparisonMsg(const aExpected: string; const aActual: string): string;
|
|
|
|
|
|
+ function ComparisonMsg(const aExpected: string; const aActual: string; const aCheckEqual: boolean=true): string;
|
|
|
|
|
|
|
|
|
|
Resourcestring
|
|
Resourcestring
|
|
|
|
|
|
SCompare = ' expected: <%s> but was: <%s>';
|
|
SCompare = ' expected: <%s> but was: <%s>';
|
|
|
|
+ SCompareNotEqual = ' expected: not equal to <%s> but was: <%s>';
|
|
SExpectedNotSame = 'expected not same';
|
|
SExpectedNotSame = 'expected not same';
|
|
SExceptionCompare = 'Exception %s expected but %s was raised';
|
|
SExceptionCompare = 'Exception %s expected but %s was raised';
|
|
SMethodNotFound = 'Method <%s> not found';
|
|
SMethodNotFound = 'Method <%s> not found';
|
|
@@ -332,9 +333,13 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
-function ComparisonMsg(const aExpected: string; const aActual: string): string;
|
|
|
|
|
|
+function ComparisonMsg(const aExpected: string; const aActual: string; const aCheckEqual: boolean=true): string;
|
|
|
|
+// aCheckEqual=false gives the error message if the test does *not* expect the results to be the same.
|
|
begin
|
|
begin
|
|
- Result := format(SCompare, [aExpected, aActual]);
|
|
|
|
|
|
+ if aCheckEqual then
|
|
|
|
+ Result := format(SCompare, [aExpected, aActual])
|
|
|
|
+ else {check unequal requires opposite error message}
|
|
|
|
+ Result := format(SCompareNotEqual, [aExpected, aActual]);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -375,7 +380,10 @@ end;
|
|
|
|
|
|
function TTestFailure.GetExceptionClassName: string;
|
|
function TTestFailure.GetExceptionClassName: string;
|
|
begin
|
|
begin
|
|
- Result := FRaisedExceptionClass.ClassName;
|
|
|
|
|
|
+ if Assigned(FRaisedExceptionClass) then
|
|
|
|
+ Result := FRaisedExceptionClass.ClassName
|
|
|
|
+ else
|
|
|
|
+ Result := '<NIL>'
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -570,8 +578,18 @@ end;
|
|
|
|
|
|
|
|
|
|
class procedure TAssert.AssertEquals(const AMessage: string; Expected, Actual: TClass);
|
|
class procedure TAssert.AssertEquals(const AMessage: string; Expected, Actual: TClass);
|
|
|
|
+
|
|
|
|
+ Function GetN(C : TClass) : string;
|
|
|
|
+ begin
|
|
|
|
+ if C=Nil then
|
|
|
|
+ Result:='<NIL>'
|
|
|
|
+ else
|
|
|
|
+ Result:=C.ClassName;
|
|
|
|
+ end;
|
|
|
|
+
|
|
begin
|
|
begin
|
|
- AssertTrue(AMessage + ComparisonMsg(Expected.ClassName, Actual.ClassName), Expected = Actual);
|
|
|
|
|
|
+ If (Expected<>Nil) then
|
|
|
|
+ AssertTrue(AMessage + ComparisonMsg(GetN(Expected), GetN(Actual)), Expected = Actual);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -892,6 +910,7 @@ var
|
|
i: integer;
|
|
i: integer;
|
|
tc: TTestCaseClass;
|
|
tc: TTestCaseClass;
|
|
begin
|
|
begin
|
|
|
|
+ TAssert.AssertNotNull(AClass);
|
|
Create(AClass.ClassName);
|
|
Create(AClass.ClassName);
|
|
if AClass.InheritsFrom(TTestCase) then
|
|
if AClass.InheritsFrom(TTestCase) then
|
|
begin
|
|
begin
|