Пример #1
0
 @Test
 public void test3Ways() {
   int size = 3;
   int trues = 2;
   boolean[][] expected = {
     {false, true, true},
     {true, false, true},
     {true, true, false}
   };
   boolean[][] actuals = Utils.allWaysToPut(trues, size);
   for (int i = 0; i < expected.length; i++) {
     assertTrue(Arrays.equals(expected[i], actuals[i]));
   }
 }
Пример #2
0
  @Test
  public void testScoreCardGeneration() {
    ScoreCard sc;
    boolean[][] variations;
    boolean[] usedIndexes = new boolean[ScoreCard.MAX_INDEX];

    for (int filled = 14; filled >= 0; filled--) {
      variations = Utils.allWaysToPut(filled, 15);

      for (boolean[] way : variations) {
        sc = new ScoreCard();
        int i = 0;
        for (Category cat : Category.values()) {
          if (way[i++]) sc.fillScore(cat);
        }
        assertFalse(usedIndexes[sc.getIndex()]);
        usedIndexes[sc.getIndex()] = true;
      }
    }
  }