33package org .hamcrest .core ;
44
55import static org .hamcrest .core .StringContains .containsString ;
6+ import static org .hamcrest .core .StringContains .containsStringIgnoringCase ;
67
78import org .hamcrest .AbstractMatcherTest ;
89import org .hamcrest .Matcher ;
@@ -23,12 +24,21 @@ public void testMatchesSubstrings() {
2324 assertMatches (stringContains , "START" + EXCERPT );
2425 assertMatches (stringContains , "START" + EXCERPT + "END" );
2526 assertMatches (stringContains , EXCERPT + EXCERPT );
27+ assertDoesNotMatch (stringContains , "XC" );
28+
2629 assertMismatchDescription ("was \" Something else\" " , stringContains , "Something else" );
27- assertMismatchDescription ( "was \" XC \" " , stringContains , "XC" );
30+ assertDescription ( "a string containing \" EXCERPT \" " , stringContains );
2831 }
2932
33+ public void testMatchesSubstringsIgnoringCase () {
34+ final Matcher <String > ignoringCase = containsStringIgnoringCase ("ExCert" );
35+ assertMatches (ignoringCase , "eXcERT" + "END" );
36+ assertMatches (ignoringCase , "START" + "EXCert" );
37+ assertMatches (ignoringCase , "START" + "excERT" + "END" );
38+ assertMatches (ignoringCase , "eXCert" + "excErt" );
39+ assertDoesNotMatch (ignoringCase , "xc" );
3040
31- public void testHasAReadableDescription () {
32- assertDescription ("a string containing \" EXCERPT \" " , stringContains );
41+ assertMismatchDescription ( "was \" Something else \" " , ignoringCase , "Something else" );
42+ assertDescription ("a string containing \" ExCert \" ignoring case " , ignoringCase );
3343 }
3444}
0 commit comments