コード例 #1
0
  @Test
  public void testCharArea2() {
    char[][] grid =
        new char[][] {
          {'c', 'a', ' '},
          {'b', ' ', 'b'},
          {' ', ' ', 'a'}
        };

    CharGrid cg = new CharGrid(grid);

    assertEquals(6, cg.charArea('a'));
    assertEquals(3, cg.charArea('b'));
    assertEquals(1, cg.charArea('c'));
    assertEquals(9, cg.charArea(' '));
  }
コード例 #2
0
  @Test
  public void testCharArea3() {
    char[][] grid =
        new char[][] {
          {'.', 'a', ','},
          {'b', 'a', 'b'},
          {'+', ',', 'a'}
        };

    CharGrid cg = new CharGrid(grid);

    assertEquals(6, cg.charArea('a'));
    assertEquals(3, cg.charArea('b'));
    assertEquals(0, cg.charArea('c'));
    assertEquals(6, cg.charArea(','));
    assertEquals(1, cg.charArea('+'));
  }
コード例 #3
0
  @Test
  public void testCharArea1() {
    char[][] grid =
        new char[][] {
          {'a', 'y', ' '},
          {'x', 'a', 'z'},
        };

    CharGrid cg = new CharGrid(grid);

    assertEquals(4, cg.charArea('a'));
    assertEquals(1, cg.charArea('z'));
  }
コード例 #4
0
  public void testCharArea4() {
    char[][] grid =
        new char[][] {
          {'.', 'a', ',', 'd', 'b', 'j'},
          {'b', 'a', 'b', ',', 'b', '+'},
          {'+', ',', 'a', 'b', '+', '.'}
        };

    CharGrid cg = new CharGrid(grid);

    assertEquals(18, cg.charArea('.'));
    assertEquals(1, cg.charArea('j'));
    assertEquals(15, cg.charArea('b'));
    assertEquals(9, cg.charArea(','));
    assertEquals(12, cg.charArea('+'));
    assertEquals(1, cg.charArea('d'));
  }