Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add unit tests for Unicode supplementary characters #35

Merged
merged 2 commits into from

2 participants

@keitaf
Collaborator

This adds unit test cases to verify that Extractor and Autolink work correctly with text containing Unicode supplementary characters.

@j3h
Collaborator
j3h commented

Ship it!

@keitaf keitaf merged commit 87e818c into punct_before_url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 18 additions and 0 deletions.
  1. +6 −0 spec/autolinking_spec.rb
  2. +12 −0 spec/extractor_spec.rb
View
6 spec/autolinking_spec.rb
@@ -541,6 +541,12 @@ def original_text; "Single char file ext http://www.bestbuy.com/site/Currie+Tech
auto_linked.should_not include('hashtag_classname')
end
+ it "should autolink url/hashtag/mention in text with Unicode supplementary characters" do
+ auto_linked = @linker.auto_link("#{[0x10400].pack('U')} #hashtag #{[0x10400].pack('U')} @mention #{[0x10400].pack('U')} http://twitter.com/")
+ auto_linked.should have_autolinked_hashtag('#hashtag')
+ auto_linked.should link_to_screen_name('mention')
+ auto_linked.should have_autolinked_url('http://twitter.com/')
+ end
end
end
View
12 spec/extractor_spec.rb
@@ -100,6 +100,10 @@ class TestExtractor
end
needed.should == []
end
+
+ it "should extract screen name in text with supplementary character" do
+ @extractor.extract_mentioned_screen_names_with_indices("#{[0x10400].pack('U')} @alice").should == [{:screen_name => "alice", :indices => [2, 8]}]
+ end
end
describe "replies" do
@@ -214,6 +218,10 @@ class TestExtractor
extracted_url[:indices].last.should == 11 + url.chars.to_a.size
end
end
+
+ it "should extract URL in text with supplementary character" do
+ @extractor.extract_urls_with_indices("#{[0x10400].pack('U')} http://twitter.com").should == [{:url => "http://twitter.com", :indices => [2, 20]}]
+ end
end
describe "invalid URLS" do
@@ -345,5 +353,9 @@ def not_match_hashtag_in_text(text)
it "should not extract numeric hashtags" do
not_match_hashtag_in_text("#1234")
end
+
+ it "should extract hashtag in text with supplementary character" do
+ match_hashtag_in_text("hashtag", "#{[0x10400].pack('U')} #hashtag", 2)
+ end
end
end
Something went wrong with that request. Please try again.