[fpc-pascal] Re: fpUnit - AssertEquals gives Access violation
Graeme Geldenhuys
graemeg.lists at gmail.com
Fri Oct 6 11:55:58 CEST 2006
Oh, I forgot to mention. If the ObjectStates match, the test passes
fine, and doesn't give an access violation.
While creating the new AssertEquals method, I purposefully created a
failure with then gives the access violation, instead to the
comparison message I expected:
"Failing on 1: Expected <posClean> but got <posEmpty>"
Regards,
- Graeme -
On 06/10/06, Graeme Geldenhuys <graemeg.lists at gmail.com> wrote:
> Hi,
>
> AssertEquals always gives an Access violation error for some reason.
> First some background info is needed....
>
> I first write some of my tests using AssertTrue as follows:
> AssertTrue('Failed on 2', posClean = lNode1.ObjectState);
>
> This just raise the exception when they didn't match. I preferred to
> have the style expected <> but got <> message. So I started change
> those tests to the following:
>
> AssertEquals('Failed on 5', ObjectStateToString(posClean),
> ObjectStateToString(lList.ObjectState));
>
> This worked fine, but after doing this for a while I realized I am
> typing my life away with all those ObjectStateToString() calls. Then
> I thought, why don't I create a new AssertEquals method for my
> projects that take TPerObjectState as parameters. So I created this
> in my custom test case class.
>
> { defined under Public }
> procedure TM2TestCase.AssertEquals(const pMessage: string; pExpected,
> pActual: TPerObjectState);
> begin
> AssertEquals(pMessage,
> ObjectStateToString(pExpected),
> ObjectStateToString(pActual));
> end;
>
> BTW: TPerObjectState is define as follows...
>
> TPerObjectState = (
> posEmpty,
> posPK,
> posCreate,
> posUpdate,
> posDelete,
> posDeleted,
> posClean
> ) ;
>
>
>
> Now changing my test to the following, which is much easier to type and read:
>
> AssertEquals('Failed on 1', posEmpty, lLang.ObjectState);
>
>
> Finally, getting back to the problem. Using this new AssertEquals
> always gives me a Access violation error. I know there is a
> AssertEquals that uses TClass, could that interfere with this? I even
> tried changing my new AssertEquals to use a different name
> AssertEqualsObjState(), but that didn't help either.
>
> What could be causing the problem?
>
> Regards,
> - Graeme -
>
>
> --
> There's no place like 127.0.0.1
>
--
There's no place like 127.0.0.1
More information about the fpc-pascal
mailing list