Add containsSubsequence examples
This commit is contained in:
parent
f193ca5181
commit
ada2ad562e
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Reference in New Issue