那么,有人可以解释一下我的测试中尾部斜杠发生了什么吗?还是 WEB_URL 模式的错误?
@Test
public void testWebUrl() {
String url = "http://www.google.com/foo/";
String test = "A string that fails is this: " + url + " <-- see that?";
Matcher m = Patterns.WEB_URL.matcher(test);
while (m.find()) {
assertTrue(Patterns.WEB_URL.matcher(url).matches()); // PASSES
assertEquals(m.group(), url); // FAILS
// Here, m.group() == "http://www.google.com/foo", without the trailing "/"
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
519 次 |
| 最近记录: |