Checklist


Data Reference Errors

  1. Are all variables properly initialized? (are all instance variables initialized in all constructors?)
  2. Do all pointers have a legal value? (i.e. NULL or pointing to a valid location)
  3. Are pointers tested on being NULL where necessary?
  4. Alias problems? (e.g. several pointers pointing to the same object)
  5. Are there any off-by-one errors? (e.g. strings without terminating EOS byte)
  6. Could range bound errors occur? Eg: int array[max]; array[max]=0;
  7. Is garbage collection properly implemented? (e.g: are all dynamically allocated objects (by new) eventually deallocated (by delete)?) If not, does this represent an oversight?
  8. Are there any scope ambiguities? Do variable declarations hide other declarations? If yes, is this an oversight? E.g:
    class C {
      public: C() { object* o = new object; }
      private: object* o;
    };
    
  9. (C++ experts only:) Do all base classes have a virtual destructor? If not, does this represent an oversight?

slide: Data Reference Errors


Computation Errors

  1. Are there errors in implicit type casts? (E.g: mixed mode arithmetic (float/int conversion))
  2. Are underflow/overflow errors possible in math. computations?
  3. Is the precedence of operators always correct? (E.g: x = 3+4 / 5)

slide: Computation Errors


Control-flow Errors

  1. Will every loop eventually terminate ?
  2. Will the program, module, procedure eventually terminate ?
  3. Are there any off-by-one errors? (one too many/few) iterations?
  4. Are there any non-exhaustive decisions (E.g: does every switch statement cover all possible cases?) If not, does this represent an oversight?
  5. Does every if statement have a corresponding else clause? If not, does this represent an oversight?

slide: Control-flow Errors


File I/O

  1. Are all files used correctly opened/closed?
  2. Does the program handle failures due to non-existing or inaccessible files?

slide: File I/O


C++ Tcl interface

  1. Are all options of new defined Tcl commands recognized by properly processing all arguments?
  2. Does the program give a proper error message if incorrect arguments are passed?
  3. Does the program return a result to the Tcl interpreter each time a Tcl command is evoked?

slide: C++ Tcl interface


Adapted from: G.J Myers, The Art of Software Testing, Wiley & Sons, 1979

See also Introduction to debugging a C/C++ program.