### Question:
Substring { public static Pattern last(String str) { if (str.length() == 1) { return last(str.charAt(0)); } return new Pattern() { @Override Match match(String input, int fromIndex) { int index = input.lastIndexOf(str); return index >= fromIndex ? new Match(input, index, str.length()) : null; } @Override public String toString() { return "last('" + str + "')"; } }; } private  Substring(); static Prefix prefix(String prefix); static Prefix prefix(char prefix); static Suffix suffix(String suffix); static Suffix suffix(char suffix); static Pattern substring(String str); static Pattern first(String str); static Pattern first(char character); static Pattern first(java.util.regex.Pattern regexPattern); static Pattern first(java.util.regex.Pattern regexPattern, int group); static Pattern spanningInOrder(String stop1, String stop2, String... moreStops); static Pattern last(String str); static Pattern last(char character); static Pattern before(Pattern delimiter); static Pattern after(Pattern delimiter); static Pattern upToIncluding(Pattern pattern); static Pattern between(Pattern open, Pattern close); static final Pattern NONE; static final Pattern BEGINNING; static final Pattern END; }### Answer:
@Test public void lastSnippet_toString() { assertThat(last("foo").toString()).isEqualTo("last('foo')"); }
@Test public void lastSnippet_noMatch() { assertThat(last("foo").in("bar")).isEmpty(); assertThat(last("foo").in("")).isEmpty(); assertThat(last("foo").iterateIn("bar")).isEmpty(); assertThat(last("f").iterateIn("")).isEmpty(); }
@Test public void lastChar_noMatch() { assertThat(last('f').in("bar")).isEmpty(); assertThat(last('f').in("")).isEmpty(); assertThat(last('f').iterateIn("bar")).isEmpty(); assertThat(last('f').iterateIn("")).isEmpty(); assertThat(last("f").in("bar")).isEmpty(); assertThat(last("f").in("")).isEmpty(); assertThat(last("f").iterateIn("bar")).isEmpty(); assertThat(last("f").iterateIn("")).isEmpty(); }