Hello, Paul Spain:
I'm using your DUnit2, thanks for your works.
I had found some bugs(?) in the DUnit2 source, maybe you can check it.
in the line 293--310 of TestFramework.pas,you written:
{$IFNDEF CLR}
{$IFNDEF UNICODE}
procedure CheckEquals(const expected, actual: WideString;
const ErrorMsg: string= ''); overload;
procedure CheckNotEquals(const expected, actual: WideString;
const ErrorMsg: string = ''); overload;
procedure CheckEqualsMem(const expected, actual: pointer;
const size:longword;
const ErrorMsg: string= '');
procedure CheckNotEqualsMem(const expected, actual: pointer;
const size:longword;
const ErrorMsg:string='');
{$ENDIF}
procedure CheckEqualsWideString(const expected, actual: WideString;
const ErrorMsg: string= '');
procedure CheckNotEqualsWideString(const expected, actual: WideString;
const ErrorMsg: string = '');
{$ENDIF}
according to the DUnit 9.4 in Delphi XE and my experience, I think it should be:
{$IFNDEF CLR}
{$IFDEF UNICODE}
procedure CheckEquals(expected, actual: RawByteString; msg: string = ''); overload; //orignal: Delphi XE
procedure CheckNotEquals(expected, actual: RawByteString; msg: string = ''); overload; //orignal: Delphi XE
{$else}
procedure CheckEquals(const expected, actual: WideString;
const ErrorMsg: string= ''); overload;
procedure CheckNotEquals(const expected, actual: WideString;
const ErrorMsg: string = ''); overload;
{$ENDIF}
procedure CheckEqualsWideString(const expected, actual: WideString;
const ErrorMsg: string= '');
procedure CheckNotEqualsWideString(const expected, actual: WideString;
const ErrorMsg: string = '');
procedure CheckEqualsMem(const expected, actual: pointer; //CheckEqualsMem should available in Delphi XE
const size:longword;
const ErrorMsg: string= '');
procedure CheckNotEqualsMem(const expected, actual: pointer; //CheckEqualsMem should available in Delphi XE
const size:longword;
const ErrorMsg:string='');
{$ENDIF}
the implement is:
{$IFNDEF CLR}
{$IFDEF UNICODE}
procedure TTestProc.CheckEquals(expected, actual: RawByteString; msg: string = '');
begin//copy from Delphi XE
//FCheckCalled := True;
OnCheckCalled;
if expected <> actual then
FailNotEquals(WideString(expected), WideString(actual), msg, CallerAddr);
end;
procedure TTestProc.CheckNotEquals(expected, actual: RawByteString; msg: string = '');
begin//copy from Delphi XE
//FCheckCalled := True;
OnCheckCalled;
if expected = actual then
FailEquals(WideString(expected), WideString(actual), msg, CallerAddr);
end;
{$ELSE}
procedure TTestProc.CheckEquals(const expected, actual: WideString;
const ErrorMsg: string);
begin
OnCheckCalled;
if expected <> actual then
FailNotEquals(expected, actual, ErrorMsg, CallerAddr);
end;
procedure TTestProc.CheckNotEquals(const expected, actual: WideString;
const ErrorMsg: string);
begin
OnCheckCalled;
if expected = actual then
FailEquals(expected, actual, ErrorMsg, CallerAddr);
end;
{$ENDIF}
procedure TTestProc.CheckEqualsWideString(const expected, actual: WideString;
const ErrorMsg: string);
begin
OnCheckCalled;
if expected <> actual then
FailNotEquals(expected, actual, ErrorMsg, CallerAddr);
end;
procedure TTestProc.CheckNotEqualsWideString(const expected, actual: WideString;
const ErrorMsg: string);
begin
OnCheckCalled;
if expected = actual then
FailEquals(expected, actual, ErrorMsg, CallerAddr);
end;
procedure TTestProc.CheckEqualsMem(const expected, actual: pointer;
const size: longword;
const ErrorMsg: string);
begin
OnCheckCalled;
if not CompareMem(expected, actual, size) then
Fail(GetMemDiffStr(expected, actual, size, ErrorMsg), CallerAddr);
end;
procedure TTestProc.CheckNotEqualsMem(const expected, actual: pointer;
const size: longword;
const ErrorMsg: string);
begin
OnCheckCalled;
if CompareMem(expected, actual, size) then
begin
if (ErrorMsg <> '') then
Fail(ErrorMsg + ', ' + 'Memory content was identical', CallerAddr)
else
Fail(ErrorMsg + 'Memory content was identical', CallerAddr)
end;
end;
{$ENDIF}
if you need more detail, give me a mail: hardnut@126.com