### Question:
StringsCompare implements Comparator<String> { @Override public int compare(String left, String right) { for (int i = 0; i < Math.min(left.length(), right.length()); i++) { if (left.charAt(i) != right.charAt(i)) { return left.charAt(i) - right.charAt(i); } } return left.length() - right.length(); }  @Override int compare(String left, String right);  }### Answer:
@Test public void whenStringsAreEqualThenZero() { StringsCompare compare = new StringsCompare(); int rst = compare.compare( "Ivanov", "Ivanov" ); assertThat(rst, is(0)); }
@Test public void whenLeftLessThanRightResultShouldBeNegative() { StringsCompare compare = new StringsCompare(); int rst = compare.compare( "Ivanov", "Ivanova" ); assertThat(rst, lessThan(0)); }
@Test public void whenLeftGreaterThanRightResultShouldBePositive() { StringsCompare compare = new StringsCompare(); int rst = compare.compare( "Petrov", "Ivanova" ); assertThat(rst, greaterThan(0)); }
@Test public void secondCharOfLeftLessThanRightShouldBeNegative() { StringsCompare compare = new StringsCompare(); int rst = compare.compare( "Patrova", "Petrov" ); assertThat(rst, lessThan(0)); }