| CSC 161 | Grinnell College | Fall, 2011 |
| Imperative Problem Solving and Data Structures | ||
The goal of this lab is to learn how to test the correctness of programs and to learn the testing frame of mind.
The program motors-test.c is a program
that sets the motor speeds of the Scribbler to the given leftspeed and
rightspeed.
Initialize the variables leftspeed and rightspeed to 1.
Initialize the variables leftspeed and rightspeed to -1 and -1 respectively.
Initialize the variables leftspeed and rightspeed to 2 and -1.
respectively.
Now try 6 and 5 respectively.
Try other numbers that you might need to figure out what works and what doesn't.
Explain why these results turned out the way they did. Why did some of the numbers work and why did some not work?
Add the preconditions and postconditions of rMotors to the
appropriate place.
Hint: You may want to use MyroC.h
assert Function in CModify 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.
Copy the program object-avoid.c to your working directory and explain what the program does and how it works.
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:
Black-box testing is when the problem is examined to determine the logical cases that might arise. Test cases are developed without reference to details of code.
White-box testing is when the code is examined to determine each of the possible conditions that may arise, and tests are developed to exercise each part of the code.
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.
Run follower-test.c with all the cases from your
test plan to be sure it works correctly.
Fix the program follower-test.c if you had found
errors.
Run follower-test.c again with all the cases from your
test plan to be sure that it now works correctly.
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.walker.cs.grinnell.edu/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 |
|
| For more information, please contact Henry M. Walker at walker@cs.grinnell.edu. |