Advertisement
B1KMusic

[Highscore test] main.cpp

Jan 25th, 2016
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #include "highscoretable.h"
  4.  
  5. void testControl(HighscoreTable *scoreTable){
  6.     printf("Initial:\n");
  7.     scoreTable->report();
  8. }
  9.  
  10. void testScore(HighscoreTable *scoreTable, int score, const char *name, const char *note){
  11.     scoreTable->insert(score, name);
  12.     printf("\nAfter insert (score = %i, name = %s): %s\n", score, name, note);
  13.     scoreTable->report();
  14. }
  15.  
  16. void testScoreNotHighEnough(HighscoreTable *scoreTable){
  17.     testScore(scoreTable, 99, "CHU", "(Nothing should change)");
  18. }
  19.  
  20. void testScoreIsRight(HighscoreTable *scoreTable){
  21.     testScore(scoreTable, 101, "NII", "(should appear at #5)");
  22. }
  23.  
  24. void testSuperHighScore(HighscoreTable *scoreTable){
  25.     testScore(scoreTable, 40000, "BRA", "(should appear at #1)");
  26. }
  27.  
  28. int main(){
  29.     HighscoreTable *scoreTable = new HighscoreTable();
  30.  
  31.     testControl(scoreTable);
  32.     testScoreNotHighEnough(scoreTable);
  33.     testScoreIsRight(scoreTable);
  34.     testSuperHighScore(scoreTable);
  35.  
  36.     delete scoreTable;
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement