Anagrams { public Set<String> generateFor(String input) { Set<String> results = new HashSet<String>(); results.add(input); char[] reverse = new char[input.length()]; for (int i = input.length() -1; i >= 0; i--) { reverse[input.length() - 1 - i] = input.charAt(i); } results.add(new String(reverse)); return results; }  Set<String> generateFor(String input);  }
@Test public void itDoesNotAffectSingleCharacters() throws Exception { Set<String> results = anagrams.generateFor("a"); assertThat(results.size()).isEqualTo(1); assertThat(results).contains("a"); }
@Test public void returnsAllAnagramsForTwoCharacterInput() throws Exception { Set<String> results = anagrams.generateFor("ab"); assertThat(results.size()).isEqualTo(2); assertThat(results).contains("ab"); assertThat(results).contains("ba"); }