|
1 | 1 | package net.discordjug.javabot.systems.help; |
2 | 2 |
|
3 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| 4 | +import static org.junit.jupiter.api.Assertions.assertFalse; |
| 5 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
4 | 6 |
|
5 | 7 | import java.io.IOException; |
6 | 8 | import java.sql.SQLException; |
@@ -89,6 +91,21 @@ void testFraction() { |
89 | 91 | assertEquals(81, repo.getByUserId(1).get().getExperience()); |
90 | 92 | } |
91 | 93 |
|
| 94 | + @Test |
| 95 | + void testXPHalfLife() { |
| 96 | + int startXP = 1_000; |
| 97 | + int half = startXP/2; |
| 98 | + repo.insert(new HelpAccount(1, startXP)); |
| 99 | + for (int i = 0; i < 55; i++) { |
| 100 | + repo.removeExperienceFromAllAccounts(1.25, 0, 1_000); |
| 101 | + double actualXP = repo.getByUserId(1).get().getExperience(); |
| 102 | + assertTrue(actualXP > half, "In iteration "+i+", XP have decayed by more than 50%, user has "+actualXP+"XP after iteration"); |
| 103 | + } |
| 104 | + repo.removeExperienceFromAllAccounts(1.25, 0, 1_000); |
| 105 | + double actualXP = repo.getByUserId(1).get().getExperience(); |
| 106 | + assertFalse(actualXP > half, "After all iterations, XP have not decayed by more than 50%, user has "+actualXP+"XP at the end"); |
| 107 | + } |
| 108 | + |
92 | 109 | @Test |
93 | 110 | void testMultipleUsers() { |
94 | 111 | repo.insert(new HelpAccount(79, 79));//below min |
|
0 commit comments