[fpc-pascal] Testing if exception raised in fpcUnit

Michael Van Canneyt michael at freepascal.org
Mon Nov 5 14:07:10 CET 2012



On Mon, 5 Nov 2012, Graeme Geldenhuys wrote:

> On 2012-11-05 12:49, ik wrote:
>>
>> So how do I do it ?
>
> Create a method of the test class, and pass that to AssertException.
>
> Alternatively, do it manually as follows:
>
>  try
>    si.SetSlideName('001~z~1~a~4~d~1.1.2.swf');
>    si.SlideTypeDB;
>  except
>    on E: exception do
>    begin
>      CheckEquals(EUnknownSlideType.ClassName, E.ClassName, 'Failing on 2');
>    end;
>  end;

This will not detect if no exception is raised, only if the right exception is raised in case one is raised.

Michael.



More information about the fpc-pascal mailing list