Skip to content

Commit

Permalink
Add a test to check that there is enough memory to run a very complex…
Browse files Browse the repository at this point in the history
… match
  • Loading branch information
matco committed Oct 4, 2023
1 parent ee321c9 commit e890e35
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions source/test/MatchTest.mc
Original file line number Diff line number Diff line change
Expand Up @@ -628,4 +628,42 @@ module MatchTest {

return true;
}

function scorePoints(match, points) {
for(var i = 0; i < points; i++) {
match.score(YOU);
match.score(OPPONENT);
}
}

(:test)
function testMemory(logger) {
//create a very complex match
var match = new Match(create_match_config(SINGLE, Match.MAX_SETS, YOU, true, 21, 30));
//set 1, won by YOU
scorePoints(match, 29);
match.score(YOU);
//set 2, won by OPPONENT
match.nextSet();
scorePoints(match, 29);
match.score(OPPONENT);
//set 3, won by YOU
match.nextSet();
scorePoints(match, 29);
match.score(YOU);
//set 4, won by OPPONENT
match.nextSet();
scorePoints(match, 29);
match.score(OPPONENT);
//set 5, won by YOU
match.nextSet();
scorePoints(match, 29);
match.score(YOU);
//end of match, won by YOU 3-2
BetterTest.assertTrue(match.hasEnded(), "Match has ended if all its sets have ended");
BetterTest.assertEqual(match.getTotalScore(YOU), 148, "Total score of player 1 is 148");
BetterTest.assertEqual(match.getTotalScore(OPPONENT), 147, "Total score of player 2 is 147");

return true;
}
}

0 comments on commit e890e35

Please sign in to comment.