CompressString { public String compressRecursive(String src) { validateInput(src); if (src.length() <= 1) { return src; } return compressRecursiveInner(src, new StringBuilder(), 1, src.charAt(0), 1); }  String compress(String src); String compressRecursive(String src);  }
@Test(expected = IllegalArgumentException.class) public void shouldNotAcceptNullStringsAsInputRecursive() { compressString.compressRecursive(null); }
@Test public void shouldNotCompressEmptyWordsRecursive() { String wordToCompress = ""; String result = compressString.compressRecursive(wordToCompress); assertEquals("", result); }
@Test public void shouldNotCompressWordsWithJustOneCharRecursive() { String wordToCompress = "a"; String result = compressString.compressRecursive(wordToCompress); assertEquals("a", result); }
@Test public void shouldCompressWordsFullOfTheSameCharsRecursive() { String wordToCompress = "aaa"; String result = compressString.compressRecursive(wordToCompress); assertEquals("a3", result); }
@Test public void shouldCompressWordsRecursive() { String wordToCompress = "aabcccccaaa"; String result = compressString.compressRecursive(wordToCompress); assertEquals("a2bc5a3", result); }