1 package org.hamcrest.text; 2 3 import org.hamcrest.AbstractMatcherTest; 4 import org.hamcrest.Matcher; 5 6 import static java.util.Arrays.asList; 7 8 9 public class StringContainsInOrderTest extends AbstractMatcherTest { 10 StringContainsInOrder m = new StringContainsInOrder(asList("a", "b", "c")); 11 12 @Override createMatcher()13 protected Matcher<?> createMatcher() { 14 return m; 15 } 16 testMatchesOnlyIfStringContainsGivenSubstringsInTheSameOrder()17 public void testMatchesOnlyIfStringContainsGivenSubstringsInTheSameOrder() { 18 assertMatches("substrings in order", m, "abc"); 19 assertMatches("substrings separated", m, "1a2b3c4"); 20 21 assertDoesNotMatch("substrings out of order", m, "cab"); 22 assertDoesNotMatch("no substrings in string", m, "xyz"); 23 assertDoesNotMatch("substring missing", m, "ac"); 24 assertDoesNotMatch("empty string", m, ""); 25 } 26 testHasAReadableDescription()27 public void testHasAReadableDescription() { 28 assertDescription("a string containing \"a\", \"b\", \"c\" in order", m); 29 } 30 } 31