Sha256: 770d1228a763f9d645178fed44c1797232c62404f095774ab857c5c6756a5e96
Contents?: true
Size: 1.84 KB
Versions: 2
Compression:
Stored size: 1.84 KB
Contents
# encoding: utf-8 require "test_helper" class CharsetTest < Test::Unit::TestCase context "is_gsm method" do should "return true if all characters are in GSM 03.38 charset" do TextMagic::API.is_gsm(("a".."z").to_a.join).should == true TextMagic::API.is_gsm(("A".."Z").to_a.join).should == true TextMagic::API.is_gsm(("0".."9").to_a.join).should == true TextMagic::API.is_gsm("@£$¥€").should == true TextMagic::API.is_gsm("\n\r\e\f\\\"").should == true TextMagic::API.is_gsm("èéùìòÇØøÅåÉÆæß").should == true TextMagic::API.is_gsm("ΔΦΓΛΩΠΨΣΘΞ").should == true TextMagic::API.is_gsm("^{}[~]| !#¤%&'()").should == true TextMagic::API.is_gsm("*+,-./_:;<=>?¡¿§").should == true TextMagic::API.is_gsm("ÖÑÜöñüàäÄ").should == true end should "return false if some characters are outside of GSM 03.38 charset" do TextMagic::API.is_gsm("Arabic: مرحبا فيلما").should == false TextMagic::API.is_gsm("Chinese: 您好").should == false TextMagic::API.is_gsm("Cyrilic: Вильма Привет").should == false TextMagic::API.is_gsm("Thai: สวัสดี").should == false end end context "real_length method" do should "count escaped characters as two and all others as one for non-unicode text" do escaped = "{}\\~[]|€" unescaped = random_string text = "#{escaped}#{unescaped}".scan(/./).sort_by { rand }.join TextMagic::API.real_length(text, false).should == unescaped.size + escaped.size * 2 end should "count all characters as one for unicode text" do escaped = "{}\\~[]|€" unescaped = random_string text = "#{escaped}#{unescaped}".scan(/./).sort_by { rand }.join TextMagic::API.real_length(text, true).should == unescaped.size + escaped.size end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
textmagic-0.5.0 | test/test_charset.rb |
textmagic-0.4.0 | test/test_charset.rb |