Sha256: f429555a9198f582ed063ba0a4972a0e26241f4d9757b8a2b3963ed502a94811
Contents?: true
Size: 1.84 KB
Versions: 4
Compression:
Stored size: 1.84 KB
Contents
require 'test_helper' require 'json' 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
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
bobes-textmagic-0.3.2 | test/test_charset.rb |
bobes-textmagic-0.3.3 | test/test_charset.rb |
textmagic-0.3.2 | test/test_charset.rb |
textmagic-0.3.3 | test/test_charset.rb |