コード例 #1
0
 @Override
 public boolean matches(Object actual) {
   this.actual = actual;
   if (expected == null) return (actual == null);
   if (!(actual instanceof String)) {
     return false;
   }
   if (expected.equals(actual)) return true;
   String actualString = (String) actual;
   java.util.regex.Matcher m = pattern.matcher(actualString);
   while (m.find()) {
     actualLines.add(actualString.substring(m.start(), m.end()));
   }
   return expectedLines.equals(actualLines);
 }
コード例 #2
0
 public MultiLineStringMatcher(String expected, String ls) {
   this.expected = expected;
   if (ls.equals("\r")) {
     this.pattern = Pattern.compile(".+(\\r|$)");
   } else if (ls.equals("\n")) {
     this.pattern = Pattern.compile(".+(\\n|$)");
   } else {
     this.pattern = Pattern.compile(".+(\\r\\n|$)");
   }
   if (expected != null) {
     java.util.regex.Matcher m = pattern.matcher(expected);
     while (m.find()) {
       expectedLines.add(expected.substring(m.start(), m.end()));
     }
   }
 }