コード例 #1
0
  @Test
  public void testGetRoundThirteenForFourteenTeams() {
    this.doubleRoundRobinGenerator = new DoubleRoundRobinGenerator(14);

    Map<Integer, Integer> roundExpected = new HashMap<Integer, Integer>();
    roundExpected.put(13, 0);
    roundExpected.put(12, 1);
    roundExpected.put(11, 2);
    roundExpected.put(10, 3);
    roundExpected.put(9, 4);
    roundExpected.put(8, 5);
    roundExpected.put(7, 6);

    Map<Integer, Integer> round = doubleRoundRobinGenerator.getRound(13);
    // 13 is the first revenge round

    assertEquals(roundExpected.size(), round.size());

    for (Map.Entry<Integer, Integer> match : roundExpected.entrySet()) {
      Integer home = match.getKey();
      Integer away = match.getValue();

      assertTrue(round.containsKey(home));
      assertTrue(round.containsValue(away));

      assertFalse(round.containsKey(away));
      assertFalse(round.containsValue(home));
    }
  }
コード例 #2
0
  @Test
  public void testGetRoundZeroForFourteenTeams() {
    this.doubleRoundRobinGenerator = new DoubleRoundRobinGenerator(14);

    Map<Integer, Integer> roundExpected = new HashMap<Integer, Integer>();
    roundExpected.put(0, 13);
    roundExpected.put(1, 12);
    roundExpected.put(2, 11);
    roundExpected.put(3, 10);
    roundExpected.put(4, 9);
    roundExpected.put(5, 8);
    roundExpected.put(6, 7);

    Map<Integer, Integer> round = doubleRoundRobinGenerator.getRound(0);

    assertEquals(roundExpected.size(), round.size());

    for (Map.Entry<Integer, Integer> match : roundExpected.entrySet()) {
      Integer home = match.getKey();
      Integer away = match.getValue();

      assertTrue(round.containsKey(home));
      assertTrue(round.containsValue(away));

      assertFalse(round.containsKey(away));
      assertFalse(round.containsValue(home));
    }
  }
コード例 #3
0
  @Test(expected = IllegalArgumentException.class)
  public void testGetRoundOutOfBounds() {
    this.doubleRoundRobinGenerator = new DoubleRoundRobinGenerator(5);

    // Maximum valid parameter is 9. This line should throw
    // IllegalArgumentException.
    doubleRoundRobinGenerator.getRound(10);
  }
コード例 #4
0
  @Test
  public void testGetRoundZeroFiveTeams() {
    this.doubleRoundRobinGenerator = new DoubleRoundRobinGenerator(5);

    Map<Integer, Integer> roundExpected = new HashMap<Integer, Integer>();
    roundExpected.put(0, 0);
    roundExpected.put(1, 4);
    roundExpected.put(2, 3);

    Map<Integer, Integer> round = doubleRoundRobinGenerator.getRound(0);

    assertEquals(roundExpected.size(), round.size());

    for (Map.Entry<Integer, Integer> match : roundExpected.entrySet()) {
      Integer home = match.getKey();
      Integer away = match.getValue();

      assertTrue(round.containsKey(home));
      assertTrue(round.containsValue(away));
    }
  }