Thread: driver function

  1. #1
    Registered User axon's Avatar
    Join Date
    Feb 2003
    Posts
    2,572

    driver function

    hello,

    My question is regarding driver functions for debugging, and error checking. I looked through search but couldn't find anything that would explain it.

    How should a driver function look? where should it be placed? do I implemet it in the program, or is it seperate? Also, if it is implemented, should it be commented as well?

    thanks,

    axon

    some entropy with that sink? entropysink.com

    there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    What do you mean by a driver function? It sounds like you are talking about a test driver conditionally compiled into a library to test it:
    Code:
    // Library functions go here
    
    #ifdef DRIVER
    int main()
    {
      // Test library functions here
    }
    #endif
    -Prelude
    My best code is written with the delete key.

  3. #3
    Registered User axon's Avatar
    Join Date
    Feb 2003
    Posts
    2,572
    yes, my book/teacher calls it a driver function...but I think that the test driver means the same thing.

    axon

    some entropy with that sink? entropysink.com

    there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka

  4. #4
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    often called a test harness in the trade.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  5. #5
    Registered User axon's Avatar
    Join Date
    Feb 2003
    Posts
    2,572
    Originally posted by Stoned_Coder
    often called a test harness in the trade.
    great, can you help me understand it?

    axon

    some entropy with that sink? entropysink.com

    there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka

  6. #6
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    sure.

    When for instance you write a new class before plugging it into your full scale work you can write a small program that calls each of the functions you have written,stresses them if possible and makes sure expected things happen. This makes it easy to debug class by class.
    Libraries by their nature are not executable programs (barring some forms of dlls) and are only compiled to a .lib. Most libraries are a collection of classes and a few free functions. If most of our classes have already been debugged then the test harness you need build for the library will also not need to be so involved.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 05-13-2011, 08:28 AM
  2. Replies: 1
    Last Post: 06-27-2008, 06:41 PM
  3. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  4. dllimport function not allowed
    By steve1_rm in forum C++ Programming
    Replies: 5
    Last Post: 03-11-2008, 03:33 AM
  5. using a driver function to test my code??
    By tommy69 in forum C Programming
    Replies: 24
    Last Post: 03-20-2004, 07:12 PM