ReverseString { public String reverseIterative(String input) { validateInput(input); StringBuilder stringBuilder = new StringBuilder(); for (int i = input.length() - 1; i >= 0; i--) { stringBuilder.append(input.charAt(i)); } return stringBuilder.toString(); }  String reverseIterative(String input); String reverseRecursive(String input);  }
@Test(expected = IllegalArgumentException.class) public void shouldNotAcceptNullStringsIterative() { reverseString.reverseIterative(null); }
@Test public void shouldReturnAnEmptyStringIfTheInputIsEmptyIterative() { String result = reverseString.reverseIterative(""); assertEquals("", result); }
@Test public void shouldReturnTheSameStringIfTheInputStringContainsJustOneCharIterative() { String result = reverseString.reverseIterative("a"); assertEquals("a", result); }
@Test public void shouldReverseStringIterative() { String result = reverseString.reverseIterative("Pedro"); assertEquals("ordeP", result); }