🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.software.testing
Article #11

Q: assertions before and after testing

#11
From: Owen Veenstra
Date: Fri, 08 Sep 1995 00:11
60 lines
2272 bytes
Howdi All,

I am using assertions to detect simple programming and interface 
problems (ie valid ranges etc).  Having the program die during 
execution at this point is therefor acceptable.

However, in the system it will be intgrated into, it is 
unacceptable to have the module simply crash the system because 
an assertion failed.  Therefore, assertions would be removed.

How do I handle those situations where in the "real" use of the 
module the assertion would fail *if* they were enabled?  (I expect 
this situation to be possible, but not necessarily likely, since 
parameters could be algorithmically generated as opposed to just 
declarted.)

If you return status values as a solution, does that just replace 
the assertion with a conditional test?

If it helps, the following is an example of my function using assertions:
/*
 * function:    RC_Generic_Array__Set
 *
 * designNotes:
 *
 * structuredEnglish:
 *
 *      BEGIN
 *      .   Set the entry specified by the index in the array
 *      END
 */
RC_Generic_Array__Set(
    RC_GENERIC_ARRAY_PTR_T      generic_array_ptr,
    int                         index,
    RC_GENERIC_ARRAY_ITEM_PTR_T generic_array_item_ptr )
{
#   ifdef DEBUG
    assert( NULL!=generic_array_ptr );
    assert( NULL!=generic_array_item_ptr );
    assert( index>=0 );
    assert( index<generic_array_ptr->Max_Nb_Entries );
#   endif /* DEBUG */

    generic_array_ptr->Generic_Array[ index ]
        = generic_array_item_ptr ;

}   /* end RC_Generic_Array__Set() */

Adv[ Thanks ]ance.

O.


---------------------------------------------
Owen Veenstra                Adacel Pty. Ltd.
Software Engineer      Adis Project - HMI R&D

email: owen@adacel.com.au      250 Bay Street
phone: +061 3 9596 2991     Brighton Victoria
fax:   +061 3 9596 2960       Australia  3186
Technical Details
Message-ID: <42o1ns$qdk@itchy.adacel.com.au>
Path: arc1-ca.pugleaf.net!itchy.adacel.com.au!not-for-mail

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!itchy.adacel.com.au!not-for-mail
From: owen@itchy.adacel.com.au (Owen Veenstra)
Newsgroups: comp.software.testing,comp.lang.c
Subject: Q: assertions before and after testing
Date: 8 Sep 1995 10:11:40 +1000
Organization: Adacel Pty Ltd, Melbourne, Australia
Distribution: world
Message-ID: <42o1ns$qdk@itchy.adacel.com.au>
NNTP-Posting-Host: itchy.adacel.com.au
Keywords: assert test