[fpc-pascal] fpcUnit testing Exceptions

dhkblaszyk at zeelandnet.nl dhkblaszyk at zeelandnet.nl
Fri Jul 14 15:10:36 CEST 2006


Graeme,

I would try and test this:

AssertException('Failing on 3', EUnknownSlideType,
TRunMethod(@si.SlideTypeDB));

Haven't been able to test though, but it's what comes to mind. Perhaps it
helps.

Darius


> Hi,
>
> Is it possible to test the code below using the AssertException()
> call?  I am sure it must be, I am just not sure how to use it.
>
> This is the work-around I have now, untill I can figure out how to use
> AssertException() correctly.
> ------------------------
>   try
>     si.SetSlideName('006~sa.swf');
>     si.SlideTypeDB;  { <<== method raises an error if type unknown }
>   except
>     on E: exception do
>     begin
>       AssertEquals('Failing on 3', EUnknownSlideType.ClassName,
> E.ClassName);
>     end;
>   end;
> ------------------------
>
> I tried the following, but got a compiler error on each one.
>
> -----------------------------
>   si.SetSlideName('006~sa.swf');
>   { none of the following worked... }
>   AssertException('Failing on 3', EUnknownSlideType, @si.SlideTypeDB);
>   AssertException('Failing on 3', EUnknownSlideType, si. at SlideTypeDB);
>   AssertException('Failing on 3', EUnknownSlideType, si.^SlideTypeDB);
> -----------------------------
>
> Regards,
>   Graeme.
>
>
> --
> There's no place like 127.0.0.1
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>





More information about the fpc-pascal mailing list