mirror of
https://github.com/termux/termux-app
synced 2024-06-14 13:26:39 +00:00
31 lines
1.0 KiB
Java
31 lines
1.0 KiB
Java
package com.termux.app;
|
|
|
|
import org.junit.Assert;
|
|
import org.junit.Test;
|
|
|
|
import java.util.Collections;
|
|
import java.util.LinkedHashSet;
|
|
|
|
public class TermuxActivityTest {
|
|
|
|
private void assertUrlsAre(String text, String... urls) {
|
|
LinkedHashSet<String> expected = new LinkedHashSet<>();
|
|
Collections.addAll(expected, urls);
|
|
Assert.assertEquals(expected, TermuxUrlUtils.extractUrls(text));
|
|
}
|
|
|
|
@Test
|
|
public void testExtractUrls() {
|
|
assertUrlsAre("hello http://example.com world", "http://example.com");
|
|
|
|
assertUrlsAre("http://example.com\nhttp://another.com", "http://example.com", "http://another.com");
|
|
|
|
assertUrlsAre("hello http://example.com world and http://more.example.com with secure https://more.example.com",
|
|
"http://example.com", "http://more.example.com", "https://more.example.com");
|
|
|
|
assertUrlsAre("hello https://example.com/#bar https://example.com/foo#bar",
|
|
"https://example.com/#bar", "https://example.com/foo#bar");
|
|
}
|
|
|
|
}
|