[fpc-pascal] Testing if exception raised in fpcUnit
Michael Van Canneyt
michael at freepascal.org
Mon Nov 5 13:45:38 CET 2012
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.
Michael.
More information about the fpc-pascal
mailing list