

Next we are going to explore some of the common tools for quickly and automatically comparing output files head-to-head to see if any differences exist and, if so, what those differences are. triangleA to redirect output into a file that otherwise would have gone to our screen. Run the input files provided through each version of the program. Recompile the program and rename the executable to triangleB. For example, swap the “else if” and output statements for the isosceles and equilateral cases in report(). Now introduce a simple bug of some kind into triangle.cpp. Unpack the archive ( unzip head2headFiles.zip).Ĭompile the program on Linux (use the command “ make”). Luckily, there are simple tools that you can use to find and highlight those differences. Spotting those differences can be quite tricky, however, if they are buried in a sea of nearly identical outputs or if the differences are “invisible” changes like adding blanks at the ends of lines or improperly indenting output. Whatever the reason, it’s the differences in outputs that are particularly interesting. Or they might represent the new behavior or functionality and that you were working to add ot the old program. Or they might be due to bugs in the old code that you have just successfully fixed. Those differences might represent bugs in your new code. Run your new code on the same set of inputs, capturing the outputs into a different file.Ĭompare the two output files to see what, if any, differences you can find between them. Run the old code on a set of inputs, capturing the outputs into a file. Whenever you find yourself working on a system for which you already have a (nearly) working executable, you can take advantage of this by doing head to head testing, in which you

Much more often, you will be adding new features to an existing program, or fixing bugs in an existing program, or trying to improve the performance of an existing program.Įven if you are developing a whole new program, there may be an older one already in use that is being replaced because it is in a older programming language that no one in the company cares to maintain, or runs only on older hardware or operating systems that are due for replacement, etc.Īnd in the academic world, you will often find that instructors\footnote provide executable solutions to assignments so that you can see what the finished product of an assignment is supposed to look like. In the real world, very few programming assignments are to write something new from scratch.

There are many circumstances where you are working on a program but have access to a working (or nearly working) executable.

2 Problem Description: Triangle Diagnosis
