Your task is to implement and test the following functions
value rounded to
nearest multiple of 100; e,g:
round_nearest_100(204) == 200
round_nearest_100(361) == 400
true (1) if value is odd, false (0) if value is even
a double value
double x 3x2 + 6x + 12
temperature in Fahrenheit,
which is mathematically
equal to (tempC * 9/5) + 32
Just as you did in Lab 18, use the ASSERT_EQUALS function to check that each function computes the correct result for a particular input value. Specifically, the first argument value should be the expected value, and the second should be a call to the function that you want to test.
function of your
program should look something like this:
/* More tests here... */
printf("All tests passed\n");
Each function should have at least 4 tests.
If you have a solution open in Visual Studio, close it (File->Close Solution).
Download lab19.zip. Import it into Visual Studio (File->Import...).
Add your code to the source file called Functions.c.
Get one function and its tests completely working before
to the next.
Try writing the tests for a function before writing the function itself. You should try to write tests that differ from each other: for example, your tests for the is_odd function should include cases for all possible combinations of even/odd and positive/negative numbers.
For the functions returning a double value, the expected value should be computed using an expression that mimics the computation that the function your are testing will perform. For example:
ASSERT_EQUALS( 3*(2.0*2.0) + 6*2.0 + 12, poly(2.0) );