CMPS-3350 Coding Exam

Useful materials and links:
program framework
unit-test data
utest.cpp

Assignment: Write an automated unit-test.

Do your work in your Odin /3350/b/ folder.

Start with the given C++ program: uvlab11

Write a unit-test procedure to test a function named normalize().
Sample output from a program run....

./lab11

3350 software engineering           
                                    
Calculation of vector lengths:      
                                    
     x         y         length     
     --------  --------  ---------- 
  1   1.00000   0.00000     1.00000
  2   1.00000   1.00000     1.41421
  3  -1.20000   2.50000     2.77308
  4  99.90000  99.90000   141.27993
  5   2.20000  -1.20000     2.50599

Program complete.


Add the following components to this assignment.

1. A unit-test of the normalize() member function.
   
   You are testing the value returned from the normalize() member function.
   You are testing the vector length calculation.

   a. Get the test data from unit-test data
   b. Use the data to perform your unit-test.
   c. Show nice output similar to the example below.
   d. Do not modify the normailze() member function!

2. Isolate your unit-test.
   Isolate the code with preprocessor directives such as #ifdef, #endif.
   a. Use a #define name of UTEST.
   b. Isolate all components of your unit-test.
   c. Store the unit-test data in an external array.
      Name your file: utest.cpp
      We will do this together in class on the big-screen.

3. Provide a Makefile to produce two executable files.
   a. One is the original program.
   b. The second executable is the unit-test program.
   c. The original program executable must work normally when run.

4. Add a tolerance value for checking actual data against expected data.
   a. Tolerance value must be entered as a command-line argument.
   b. Tolerance is used to judge data that is "close enough" as acceptable.
   c. If tolerance is not entered when in utest mode,
      show a Usage statement.

5. Program output format should be similar the sample below.
$ ./xtest 0.01
     
3350 software engineering                       
                                                
Unit test of normalize() member function:             
tolerance: 0.010000
                                                
     x         y         expected    actual     
     --------  --------  ----------  ---------- 
  1   1.66622  -4.72532     5.00936     5.01048
  2  -3.58422  -6.24916     7.21136     7.20407
  3   8.01263  -4.61471     9.26151     9.24650 <-- error
  4  -0.24896  -5.64986     5.67034     5.65534 <-- error
  5   8.95260   7.07561    11.40624    11.41110
  6  -8.22569  -0.56500     8.24240     8.24507
  7  -7.88243   1.68622     8.06835     8.06077

...
...
(more output is here)
...
...

Unit test complete.
errors found: 4

notes:
       Do not print "more output is here" in your solution.
       Do not print the "..." in your solution.

       You may display only the errors, if you wish.

Files to be collected:
   uvlab11.cpp
   utest.cpp
   Makefile