On Mon, Nov 5, 2012 at 2:45 PM, Michael Van Canneyt <mich...@freepascal.org> wrote: > > > 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>" > > Michael. > _______________________________________________ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/mailman/listinfo/fpc-pascal _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal