[fpc-pascal] fpcUnit testing Exceptions

Graeme Geldenhuys graemeg.lists at gmail.com
Fri Jul 14 14:50:21 CEST 2006


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



More information about the fpc-pascal mailing list