Re: [fpc-pascal] Testing if exception raised in fpcUnit

2012-11-05 Thread ik
On Mon, Nov 5, 2012 at 3:15 PM, Graeme Geldenhuys wrote: > On 2012-11-05 13:07, Michael Van Canneyt wrote: >> >> This will not detect if no exception is raised, only if the right >> exception is raised in case one is raised. > > > You are correct. An extra test is needed just before the except blo

Re: [fpc-pascal] Testing if exception raised in fpcUnit

2012-11-05 Thread Graeme Geldenhuys
On 2012-11-05 13:07, Michael Van Canneyt wrote: > > This will not detect if no exception is raised, only if the right > exception is raised in case one is raised. You are correct. An extra test is needed just before the except block. As your example shows, simply calling Fail(...) if no exceptio

Re: [fpc-pascal] Testing if exception raised in fpcUnit

2012-11-05 Thread Michael Van Canneyt
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

Re: [fpc-pascal] Testing if exception raised in fpcUnit

2012-11-05 Thread Graeme Geldenhuys
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 CheckEq

Re: [fpc-pascal] Testing if exception raised in fpcUnit

2012-11-05 Thread Michael Van Canneyt
On Mon, 5 Nov 2012, ik wrote: On Mon, Nov 5, 2012 at 2:45 PM, Michael Van Canneyt 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) : By

Re: [fpc-pascal] Testing if exception raised in fpcUnit

2012-11-05 Thread ik
On Mon, Nov 5, 2012 at 2:45 PM, Michael Van Canneyt 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; >> begi

Re: [fpc-pascal] Testing if exception raised in fpcUnit

2012-11-05 Thread Michael Van Canneyt
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('I

[fpc-pascal] Testing if exception raised in fpcUnit

2012-11-05 Thread ik
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;