Project 4 Extra Notes
Quick Hints and Reminders
- Do not copy the interface (.h) file into your account. You should use
the path to the original in your code. Because the interface file will
not change, you do not need to include it in your makefile.
- You absolutely cannot use operator== to compare against NAN
(technically you can for INFINITY)
- Use “finite” as shown in the demo program to test for NAN and
INFINITY
- To return NAN and INFINITY, write the names in all caps.
- You need to use symbolic constants (for PI, epsilon, etc.) either from
the cmath library or created by yourself.
Incremental Development
- Some of the functions depend on other functions. Therefore, there is
no point in writing the dependent functions until the functions they
rely on are working.
- For some functions, it will be hard to handle all possible input
values on your first attempt. For example, "modulo" must handle negative
values, and in the same way that "fmod" from cmath does. First, get it
to work just for positive values.
Testing Principles
This is the first project with a “driver” module for testing. You will need
many test cases for each function.
Test cases fall into two categories:
- Error conditions (where output is undefined)
- The function needs to (a) not fail, and (b) return some specific
error value (e.g. as defined by project specifications).
- Normal conditions
- The function needs to (a) not fail, and (b) return the correct
result.
- You need to test various values throughout the range of valid
values.
- ex. In functions with parameters of type "double", you must test
large and small, positive and negative input.
- ex. In "sine" and "cosine", you need to test each values from each
quadrant of the unit circle.
Testing Modules ("Drivers")
Absolutely required:
- You must label your output. It must be clear what the function, input,
and output are.
- You must format it so that it is easy to read -- break the output into
sections for each function\
At the very minimum, you will need to do something like this for every
test:
cout << "fac
torial("
<<
15 << ") = " << factorial(15)
<< endl;
Recommended (for now):
- You should compare the output of your functions with output from the
“cmath” library. Otherwise, you're just guessing that the results are
correct.
- You can use "setw()" from "iomanip" to create columns. Note that you
must use "setw()" before every field individually.
Testing Functions
You will find it massively helpful to create auxiliary testing functions
like this:
void testFactorial(int x) {
cout << "fac
torial("
<<
x << ") = " << factorial(x) <<
endl;
}
Then, you can just call these auxiliary functions repeatedly in
order to test your library functions, rather than
copying and pasting the whole output line.
Last edited 2/5/13