Add containsSubsequence examples

This commit is contained in:
Joel Costigliola 2017-11-06 22:56:16 +13:00
parent f193ca5181
commit ada2ad562e
2 changed files with 11 additions and 1 deletions

View File

@ -363,6 +363,8 @@ public class IterableAssertionsExamples extends AbstractAssertionsExamples {
assertThat(list).doesNotContainSubsequence("Superman", "is", "great")
.doesNotContainSubsequence(newArrayList("Superman", "is", "great"));
List<String> title = newArrayList("A", " ", "Game", " ", "of", " ", "Thrones", " ");
assertThat(title).containsSubsequence("Game", "Thrones");
}
@Test

View File

@ -57,16 +57,24 @@ public class StringAssertionsExamples extends AbstractAssertionsExamples {
.containsSequence("George", " ", "Martin");
assertThat(bookDescription).containsSubsequence("'title'", ":", "'A Game of Thrones'")
.containsSubsequence("{", "A Game of Thrones", "George Martin", "}")
.containsSubsequence("{", "title", "A Game of Thrones", "}")
.containsSubsequence(asList("{", "title", "A Game of Thrones", "}"))
.containsSubsequence("A", "Game", "of", "George");
try {
assertThat(bookDescription).containsSequence(":", "'title'", "'A Game of Thrones'");
assertThat(bookDescription).containsSubsequence(":", "'title'", "'A Game of Thrones'");
} catch (AssertionError e) {
logAssertionErrorMessage("String containsSequence with incorrect order", e);
}
assertThat("a-b-c").containsSubsequence("b", "-", "c")
.containsSubsequence("a", "c")
.containsSubsequence("b", "c")
.containsSubsequence("-", "-")
.containsSubsequence("-", "b", "-")
.containsSubsequence("-", "c");
// you can ignore case for equals check
assertThat("Frodo").isEqualToIgnoringCase("FROdO").hasSameSizeAs("12345");
assertThat("Frodo".length()).isGreaterThan("Sam".length());