コード例 #1
0
  @Test
  public void canCountNumbersOfLetters() throws Exception {
    String string = "abcd abc";

    WordCounter wc = new WordCounter(string);

    assertEquals(2, wc.getCountOf('a'));
    assertEquals(1, wc.getCountOf('d'));
    assertEquals(0, wc.getCountOf('z'));
  }
コード例 #2
0
  @Test
  public void shouldWorkWithEmptyStrings() {
    WordCounter wordCounter = new WordCounter("");

    assertEquals(0, wordCounter.getCountOf('a'));
  }