Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Test calculation of the average student grade.
- */
- void test_calc_avg() {
- //Using the included grades.txt file, check the averages of a few students.
- //One with less than max student grades, one with max.
- Students test;
- std::string testFile = "grades.txt";
- test.read_file(testFile);
- double grade;
- grade = test.calc_avg(test.getStudentGrades(0), test.getMaxGradeCount());
- TS_ASSERT_EQUALS(grade, 49);
- grade = test.calc_avg(test.getStudentGrades(97), test.getMaxGradeCount());
- //Check to 4 decimal places.
- TS_ASSERT_DELTA(grade, 86.4545, .00009);
- grade = test.calc_avg(test.getStudentGrades(99), test.getMaxGradeCount());
- //Check to 4 decimal places.
- TS_ASSERT_DELTA(grade, 71.3636, .00009);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement