Homework 2: Testing wc

Homework is important practice for you, but it’s not graded so you don’t have to submit it.

Overview

For this second homework assignment you will develop a basic test framework for the wc program from Homework 1. This involves some simple shell scripting which may seem scary at first (“Yet another language, are you serious?”), but you are free to base your own script on the examples posted on Piazza.

You will also have to work up some actual test cases. For now we’re doing simple input-output testing, so you just have to try to come up with a variety of “challenging” inputs and what the corresponding outputs should be. (There are some hints about this below.)

Deliverables

Homework 1 required a very simple Makefile that just sets the compiler options using the CFLAGS variable. For this homework assignment, your Makefile should support all of the following:

You should also have a shell script testwc.sh that will run the test cases. As discussed in lecture, the script should make no output whatsoever if all test cases pass; for test cases that fail, the script should give some indication of which test case failed and how it failed. (The latter is not too difficult, see the example shell script posted on Piazza.)

For the actual test cases, please follow the naming convention we used in lecture: something.in contains the input for a test case, something.out contains the expected output.

Hints

Things to look into…

It can be hard to figure out when you have “enough” test cases. We’ll chat about a few heuristics (“rules of thumb”) for this in lecture, but there are also slightly more “objective” approaches. You may want to look up the terms “code coverage” (and “line coverage” in particular) to get an idea of what we’d like to do. Hopefully we’ll find the time to “cover” (hah!) coverage analysis in lecture soon.