Add unit tests for Unicode supplementary characters #35

Merged
merged 2 commits into from Feb 7, 2012
Jump to file or symbol
Failed to load files and symbols.
+18 −0
Diff settings

Always

Just for now

View
@@ -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
@@ -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