[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [pdf-devel] time module unit test cases
From: |
gerel |
Subject: |
Re: [pdf-devel] time module unit test cases |
Date: |
Fri, 18 Apr 2008 17:18:18 -0300 |
> Date: Fri, 18 Apr 2008 20:55:05 +0200
> From: address@hidden
>
>
> > Passing an invalid object to the function (an invalid pointer) will
> > surely cause the application to crash. It is generally not possible in
> > C to determine if a pointer is a "valid" one (if it points to
> > appropiately allocated _and_ appropriately initialized memory). Even
> > if you expect a crash (and test for the presence of a crash in the
> > process) you may be dissapointed: the application may survive if the
> > garbage contained in the pointer points to a valid memory
> > address. So it is not useful to define negative unit tests with
> > invalid pointers.
> >
> > I hope that helps.
> >
>
> NULL pointers indeed are invalid and should always be checked on.
>
> I disagree. Anish is talking about expecting a coherent failure
> behaviour from a function in case you pass an invalid pointer as a
> parameter. To check for NULL pointers in a function expecting a
> pointer parameter is a waste of time. Most pointer variables are
> automatic variables and thus they are not initialized to 0. In that
> context to check for NULL is like to check for 24.
>
> What makes sense and of course is mandatory is to check for a NULL
> pointer after calling a function that _explicitly_ set the return
> value as NULL when there is a failure or some other condition.
Let's use an example so I get your point.
##
/*
* Test: pdf_list_create_002
* Description:
* Try to create an empty list given a NULL list pointer.
* Success condition:
* Returns PDF_EBADDATA
*/
START_TEST (pdf_list_create_002)
{
fail_if (pdf_list_create (l_comp, l_disp, 0, NULL) != PDF_EBADDATA);
}
END_TEST
###
Is that unit test useless ? If so, I wasted a long time checking for NULL
pointers and doing those tests. :-/ (dumb me)
-gerel
- [pdf-devel] time module unit test cases, anish patil, 2008/04/07
- Re: [pdf-devel] time module unit test cases, jemarch, 2008/04/07
- Re: [pdf-devel] time module unit test cases, anish patil, 2008/04/10
- Re: [pdf-devel] time module unit test cases, jemarch, 2008/04/10
- Re: [pdf-devel] time module unit test cases, anish patil, 2008/04/17
- Re: [pdf-devel] time module unit test cases, jemarch, 2008/04/17
- Re: [pdf-devel] time module unit test cases, gerel, 2008/04/17
- Re: [pdf-devel] time module unit test cases, gerel, 2008/04/17
- Re: [pdf-devel] time module unit test cases, jemarch, 2008/04/18
- Re: [pdf-devel] time module unit test cases,
gerel <=
- Re: [pdf-devel] time module unit test cases, gerel, 2008/04/18
- Re: [pdf-devel] time module unit test cases, jemarch, 2008/04/19
- Re: [pdf-devel] time module unit test cases, jemarch, 2008/04/19
- Re: [pdf-devel] time module unit test cases, gerel, 2008/04/19
- Re: [pdf-devel] time module unit test cases, jemarch, 2008/04/20
- Re: [pdf-devel] time module unit test cases, Eder, 2008/04/20
- Re: [pdf-devel] time module unit test cases, Eder, 2008/04/20
- pdf_XXX_t variables creation (Was: [pdf-devel] time module unit test cases), jemarch, 2008/04/20
- Re: pdf_XXX_t variables creation (Was: [pdf-devel] time module unit test cases), Eder, 2008/04/21
- Re: pdf_XXX_t variables creation (Was: [pdf-devel] time module unit test cases), gerel, 2008/04/21