2 * Quoridor server and related libraries
3 * Copyright (C) 2009-2010 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. Look for COPYING file in the top folder.
16 * If not, see http://www.gnu.org/licenses/.
19 package cz.xelfi.quoridor.statistics;
21 import org.junit.Test;
22 import static org.junit.Assert.*;
28 public class EloTest extends Object {
30 public EloTest() throws Exception {
33 @Test public void testEloList() throws Exception {
34 EloList eloList = new EloList();
35 eloList.putResult("p1", "p2");
36 assertFalse("empty list", eloList.getFinalList().isEmpty());
37 eloList.putResult("p3", "p4");
38 assertTrue("wrong list", eloList.getFinalList().get(0).getElo().equals(eloList.getFinalList().get(1).getElo()));
39 eloList.putResult("p2", "p1");
40 eloList.putResult("p2", "p1");
41 eloList.putResult("p2", "p1");
42 assertTrue("wrong list", eloList.getFinalList().get(0).player.equals("p2"));
45 @Test public void testEloResults() throws Exception {
46 EloList eloList = new EloList();
47 setTestPlayer(eloList, "p1", 1335, 120);
48 setTestPlayer(eloList, "p2", 1380, 20);
49 setTestPlayer(eloList, "p3", 1264, 110);
50 setTestPlayer(eloList, "p4", 1281, 140);
52 // eloList.putResult("p1", "p2");
53 eloList.putResult("p1", "p3");
54 eloList.putResult("p1", "p4");
56 eloList.putResult("p2", "p1");
57 eloList.putResult("p1", "p2");
61 private void setTestPlayer(EloList eloList, String player, double elo, int games){
62 eloList.players.put(player, elo);
63 eloList.playerGames.put(player, games);
66 private void printList(EloList eloList){
67 for(EloEntry entry: eloList.getFinalList()){
68 System.out.println(entry);
70 System.out.println("------------");