Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1.     /**
  2.      * Test calculation of the average student grade.
  3.      */
  4.     void test_calc_avg() {
  5.         //Using the included grades.txt file, check the averages of a few students.
  6.         //One with less than max student grades, one with max.
  7.         Students test;
  8.         std::string testFile = "grades.txt";
  9.         test.read_file(testFile);
  10.         double grade;
  11.         grade = test.calc_avg(test.getStudentGrades(0), test.getMaxGradeCount());
  12.         TS_ASSERT_EQUALS(grade, 49);
  13.        
  14.         grade = test.calc_avg(test.getStudentGrades(97), test.getMaxGradeCount());
  15.         //Check to 4 decimal places.
  16.         TS_ASSERT_DELTA(grade, 86.4545, .00009);
  17.        
  18.         grade = test.calc_avg(test.getStudentGrades(99), test.getMaxGradeCount());
  19.         //Check to 4 decimal places.
  20.         TS_ASSERT_DELTA(grade, 71.3636, .00009);
  21.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement