Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

Commit 7e00f7c

Browse files
dev/codeforces/ Добавил тесты для RatingCalculator
1 parent 6a94375 commit 7e00f7c

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/main/java/com/cf/cfteam/utils/codeforces/RatingCalculator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
public final class RatingCalculator {
88

9-
public static double getWinProbability(double ra, double rb) {
9+
private static double getWinProbability(double ra, double rb) {
1010
return 1.0 / (1.0 + Math.pow(10.0, (rb - ra) / 400.0));
1111
}
1212

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.cf.cfteam.utils.codeforces;
2+
3+
import com.cf.cfteam.transfer.responses.codeforces.PlayerResponse;
4+
import org.junit.jupiter.api.Test;
5+
import org.springframework.test.context.ActiveProfiles;
6+
7+
import java.util.List;
8+
9+
import static org.assertj.core.api.Assertions.assertThat;
10+
11+
@ActiveProfiles("test")
12+
class RatingCalculatorTest {
13+
14+
@Test
15+
void testCalculateSoloRating() {
16+
PlayerResponse response = PlayerResponse.builder()
17+
.id(1L)
18+
.login("login")
19+
.rating(1000.)
20+
.build();
21+
List<PlayerResponse> players = List.of(response);
22+
var result = RatingCalculator.aggregateRatings(players);
23+
24+
assertThat(result).isEqualTo(1000.);
25+
}
26+
}

0 commit comments

Comments
 (0)