Skip to content
This repository was archived by the owner on Sep 18, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tests/com/twitter/ExtractorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.junit.BeforeClass;

import com.twitter.Extractor.Entity.Type;

import junit.framework.TestCase;
Expand All @@ -23,6 +25,11 @@ public static Test suite() {
public void setUp() throws Exception {
extractor = new Extractor();
}

@BeforeClass
public void extractURLWithoutProtocol() {
extractor.setExtractURLWithoutProtocol(true);
}

public static class OffsetConversionTest extends ExtractorTest {

Expand Down Expand Up @@ -83,6 +90,12 @@ public void testConvertIndices() {

assertOffsetConversionOk("\ud83d\ude02a\ud83d\ude02a\ud83d\ude02", "a");
}

public void testExtractURLWithoutProtocol() {

assertEquals(true, extractor.isExtractURLWithoutProtocol());

}

private void assertOffsetConversionOk(String testData, String patStr) {
// Build an entity at the location of patStr
Expand Down
3 changes: 3 additions & 0 deletions tests/com/twitter/RegexTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public void testAutoLinkHashtags() {
assertCaptureCount(3, Regex.VALID_HASHTAG, "#日本語ハッシュタグ");
assertCaptureCount(3, Regex.VALID_HASHTAG, "#日本語ハッシュタグ");

assertCaptureCount(3, Regex.VALID_HASHTAG, "#مرحبا شباب");//Arabic


assertTrue(Regex.VALID_HASHTAG.matcher("これはOK #ハッシュタグ").find());
assertTrue(Regex.VALID_HASHTAG.matcher("これもOK。#ハッシュタグ").find());
assertFalse(Regex.VALID_HASHTAG.matcher("これはダメ#ハッシュタグ").find());
Expand Down