Michael Van Canneyt wrote 27 lines
On Mon, 5 Nov 2012, ik wrote:
> Hello,
>
> I wish to test if a method has raised an exception for a value
> (something that should make the test pass) or not.
>
> For example:
>
> function TestNum(ch : Char) : Byte;
> begin
> if UpCase(ch) in ['A'..'F', '0'..'9'] then
> ...
> else
> raise Exception.Create('Invalid char was given.');
> end;
>
> I want to test the code with Char like 'y' for example, to make sure
> that it does raises the exception.
>
>
> Does AssertException is the proper method for such test ?
Yes.
So how do I do it ?
TRunMethod = procedure of object;
If I pass it a function, it don't really like it:
AssertException(ExceptionWasNotRaisd, EMsgPackWrongType, @MsgPackType.AsByte);
convert_testcase.pas(592,60) Error: Incompatible type for arg no. 3: Got "<procedure variable type of function:Byte of object;Register>", expected "<procedure variable type of procedure of object;Register>"
Show quoted text 5 lines