CSC 161 Grinnell College Fall, 2011
 
Imperative Problem Solving and Data Structures
 

Laboratory Exercise on Testing

Goals

The goal of this lab is to learn how to test the correctness of programs and to learn the testing frame of mind.

Pre- and Post-Conditions

  1. The program motors-test.c is a program that sets the motor speeds of the Scribbler to the given leftspeed and rightspeed.

    1. Initialize the variables leftspeed and rightspeed to 1.

    2. Initialize the variables leftspeed and rightspeed to -1 and -1 respectively.

    3. Initialize the variables leftspeed and rightspeed to 2 and -1. respectively.

    4. Now try 6 and 5 respectively.

    5. Try other numbers that you might need to figure out what works and what doesn't.

    6. Explain why these results turned out the way they did. Why did some of the numbers work and why did some not work?

  2. Add the preconditions and postconditions of rMotors to the appropriate place.

    Hint: You may want to use MyroC.h

The assert Function in C

  1. Modify the same code, motors-test.c, to use assert  so that it will test the precondition(s) you wrote for rMotors in motors-test.c.

Choosing Test Cases

  1. Copy the program object-avoid.c to your working directory and explain what the program does and how it works.

  2. Develop two test plans for object-avoid.c to figure out if the program works correctly. That is, apply both black-box and white box testing by identify tests cases that will cover a full range of situations that might be encountered in executing the program object-avoid.c . Remember that:

  3. How many times do you think the iterations should be going for? Now look at the code carefully. How many times is it going for? Explain why you think so.

Debugging

  1. Develop two test plans for follower-test.c. Apply both black-box and white box testing by identify tests cases that will cover a full range of situations that might be encountered.

  2. Run follower-test.c  with all the cases from your test plan to be sure it works correctly.

  3. Fix the program follower-test.c  if you had found errors.

  4. Run follower-test.c  again with all the cases from your test plan to be sure that it now works correctly.

Reminder: Complete Evaluation Form

When you have finished this lab, be sure to fill out its evaluation form in the "Lab Evaluation" section for CSC 161 on Pioneer Web.


This document is available on the World Wide Web as

     http://www.cs.grinnell.edu/~walker/courses/161.fa11/modules/module-arrays-functions/testing.shtml

created: 21 July 2011 by Dilan Ustek
last full revision: 21 July 2011 by Dilan Ustek & Erik Opavsky
minor editing 25 September 2011 by Henry M. Walker
Valid HTML 4.01! Valid CSS!
For more information, please contact Henry M. Walker at walker@cs.grinnell.edu.