Skip to content

Commit fdab7f4

Browse files
committed
Added additional test cases and added it to the code generator so that
it'll appear on the "Matchers" factory utility which was initially missing from Kevin Pauli's patch.
1 parent 5ed2d06 commit fdab7f4

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

hamcrest-library/matchers.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<factory class="org.hamcrest.collection.IsEmptyIterable"/>
3131
<factory class="org.hamcrest.collection.IsIterableContainingInOrder"/>
3232
<factory class="org.hamcrest.collection.IsIterableContainingInAnyOrder"/>
33+
<factory class="org.hamcrest.collection.IsIterableContainingInRelativeOrder"/>
3334
<factory class="org.hamcrest.collection.IsIterableWithSize"/>
3435
<factory class="org.hamcrest.collection.IsMapContaining"/>
3536
<factory class="org.hamcrest.collection.IsIn"/>

hamcrest-library/src/test/java/org/hamcrest/collection/IsIterableContainingInRelativeOrderTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ public void testMatchesWithMoreElementsThanExpectedInBetween() throws Exception
4141
assertMatches("More elements in between", containsInRelativeOrder(1, 3), asList(1, 2, 3));
4242
}
4343

44+
public void testMatchesSubSection() throws Exception {
45+
assertMatches("Sub section of iterable", containsInRelativeOrder(2, 3), asList(1, 2, 3, 4));
46+
}
47+
48+
public void testMatchesWithSingleGapAndNotFirstOrLast() throws Exception {
49+
assertMatches("Sub section with single gaps without a first or last match", containsInRelativeOrder(2, 4), asList(1, 2, 3, 4, 5));
50+
}
51+
52+
public void testMatchingSubSectionWithManyGaps() throws Exception {
53+
assertMatches("Sub section with many gaps iterable", containsInRelativeOrder(2, 4, 6), asList(1, 2, 3, 4, 5, 6, 7));
54+
}
55+
4456
public void testDoesNotMatchWithFewerElementsThanExpected() throws Exception {
4557
List<WithValue> valueList = asList(make(1), make(2));
4658
assertMismatchDescription("value with <3> was not found after <WithValue 2>", contains123, valueList);

0 commit comments

Comments
 (0)