stringex 1.5.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +74 -0
- data/README.rdoc +22 -1
- data/Rakefile +46 -223
- data/VERSION +1 -0
- data/init.rb +1 -0
- data/lib/stringex.rb +11 -3
- data/lib/stringex/acts_as_url.rb +49 -97
- data/lib/stringex/acts_as_url/adapter.rb +26 -0
- data/lib/stringex/acts_as_url/adapter/active_record.rb +23 -0
- data/lib/stringex/acts_as_url/adapter/base.rb +188 -0
- data/lib/stringex/acts_as_url/adapter/data_mapper.rb +67 -0
- data/lib/stringex/acts_as_url/adapter/mongoid.rb +36 -0
- data/lib/stringex/configuration.rb +4 -0
- data/lib/stringex/configuration/acts_as_url.rb +44 -0
- data/lib/stringex/configuration/base.rb +58 -0
- data/lib/stringex/configuration/configurator.rb +25 -0
- data/lib/stringex/configuration/string_extensions.rb +19 -0
- data/lib/stringex/localization.rb +98 -0
- data/lib/stringex/localization/backend/i18n.rb +53 -0
- data/lib/stringex/localization/backend/internal.rb +51 -0
- data/lib/stringex/localization/conversion_expressions.rb +148 -0
- data/lib/stringex/localization/converter.rb +121 -0
- data/lib/stringex/localization/default_conversions.rb +88 -0
- data/lib/stringex/rails/railtie.rb +10 -0
- data/lib/stringex/string_extensions.rb +153 -208
- data/lib/stringex/unidecoder.rb +6 -101
- data/lib/stringex/unidecoder_data/x00.yml +1 -1
- data/lib/stringex/unidecoder_data/x02.yml +5 -5
- data/lib/stringex/unidecoder_data/x05.yml +1 -1
- data/lib/stringex/unidecoder_data/x06.yml +1 -1
- data/lib/stringex/unidecoder_data/x07.yml +3 -3
- data/lib/stringex/unidecoder_data/x09.yml +1 -1
- data/lib/stringex/unidecoder_data/x0e.yml +2 -2
- data/lib/stringex/unidecoder_data/x1f.yml +2 -2
- data/lib/stringex/unidecoder_data/x20.yml +1 -1
- data/lib/stringex/unidecoder_data/xfb.yml +1 -1
- data/lib/stringex/unidecoder_data/xff.yml +1 -1
- data/lib/stringex/version.rb +8 -0
- data/locales/da.yml +73 -0
- data/locales/en.yml +66 -0
- data/stringex.gemspec +77 -18
- data/test/acts_as_url/adapter/active_record.rb +72 -0
- data/test/acts_as_url/adapter/data_mapper.rb +82 -0
- data/test/acts_as_url/adapter/mongoid.rb +73 -0
- data/test/acts_as_url_configuration_test.rb +51 -0
- data/test/acts_as_url_integration_test.rb +271 -0
- data/test/localization/da_test.rb +117 -0
- data/test/localization/default_test.rb +113 -0
- data/test/localization/en_test.rb +117 -0
- data/test/localization_test.rb +123 -0
- data/test/redcloth_to_html_test.rb +37 -0
- data/test/string_extensions_test.rb +59 -91
- data/test/test_helper.rb +2 -0
- data/test/unicode_point_suite/basic_greek_test.rb +113 -0
- data/test/unicode_point_suite/basic_latin_test.rb +142 -0
- data/test/unicode_point_suite/codepoint_test_helper.rb +32 -0
- data/test/unidecoder/bad_localization.yml +1 -0
- data/test/unidecoder/localization.yml +4 -0
- data/test/unidecoder_test.rb +3 -5
- metadata +145 -37
- data/test/acts_as_url_test.rb +0 -272
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'stringex'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubygems'
|
6
|
+
require 'RedCloth'
|
7
|
+
rescue LoadError
|
8
|
+
puts
|
9
|
+
puts ">> Could not load RedCloth. String#to_html was not tested."
|
10
|
+
puts ">> Please gem install RedCloth if you'd like to use this functionality."
|
11
|
+
puts
|
12
|
+
end
|
13
|
+
|
14
|
+
class RedclothToHTMLTest < Test::Unit::TestCase
|
15
|
+
if defined?(RedCloth)
|
16
|
+
def test_to_html
|
17
|
+
{
|
18
|
+
"h1. A Solution" => "<h1>A Solution</h1>",
|
19
|
+
"I hated wrapping textilize around a string.\n\nIt always felt dirty." =>
|
20
|
+
"<p>I hated wrapping textilize around a string.</p>\n<p>It always felt dirty.</p>",
|
21
|
+
"I think _this_ is awesome" => "<p>I think <em>this</em> is awesome</p>",
|
22
|
+
"Um... _*really*_, man" => "<p>Um… <em><strong>really</strong></em>, man</p>"
|
23
|
+
}.each do |plain, html|
|
24
|
+
assert_equal html, plain.to_html
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_to_html_lite
|
29
|
+
{
|
30
|
+
"I have no pee on me" => "I have no pee on me",
|
31
|
+
"But I _do_ get Textile!" => "But I <em>do</em> get Textile!"
|
32
|
+
}.each do |plain, html|
|
33
|
+
assert_equal html, plain.to_html(:lite)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -1,39 +1,15 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
$KCODE = "U"
|
3
2
|
|
4
|
-
require "
|
3
|
+
require "test_helper"
|
4
|
+
require "stringex"
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
if RUBY_VERSION.to_f < 1.9
|
7
|
+
$KCODE = "U"
|
8
|
+
end
|
8
9
|
|
9
10
|
class StringExtensionsTest < Test::Unit::TestCase
|
10
|
-
def
|
11
|
-
|
12
|
-
require "RedCloth"
|
13
|
-
{
|
14
|
-
"h1. A Solution" => "<h1>A Solution</h1>",
|
15
|
-
"I hated wrapping textilize around a string.\n\nIt always felt dirty." =>
|
16
|
-
"<p>I hated wrapping textilize around a string.</p>\n<p>It always felt dirty.</p>",
|
17
|
-
"I think _this_ is awesome" => "<p>I think <em>this</em> is awesome</p>",
|
18
|
-
"Um... _*really*_, man" => "<p>Um… <em><strong>really</strong></em>, man</p>"
|
19
|
-
}.each do |plain, html|
|
20
|
-
assert_equal html, plain.to_html
|
21
|
-
end
|
22
|
-
rescue LoadError
|
23
|
-
puts "\n>> Could not load RedCloth. String#to_html was not tested.\n>> Please gem install RedCloth if you'd like to use this functionality."
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_to_html_lite
|
27
|
-
require "rubygems"
|
28
|
-
require "RedCloth"
|
29
|
-
{
|
30
|
-
"I have no pee on me" => "I have no pee on me",
|
31
|
-
"But I _do_ get Textile!" => "But I <em>do</em> get Textile!"
|
32
|
-
}.each do |plain, html|
|
33
|
-
assert_equal html, plain.to_html(:lite)
|
34
|
-
end
|
35
|
-
rescue LoadError
|
36
|
-
puts "\n>> Could not load RedCloth. String#to_html (with :lite argument) was not tested.\n>> Please gem install RedCloth if you'd like to use this functionality."
|
11
|
+
def setup
|
12
|
+
Stringex::Localization.reset!
|
37
13
|
end
|
38
14
|
|
39
15
|
def test_to_url
|
@@ -77,7 +53,7 @@ class StringExtensionsTest < Test::Unit::TestCase
|
|
77
53
|
"21'17ʼ51" =>
|
78
54
|
"21-17-51",
|
79
55
|
"ITCZ÷1 (21°17ʼ51.78”N / 89°35ʼ28.18”O / 26-04-08 / 09:00 am)" =>
|
80
|
-
"itcz-
|
56
|
+
"itcz-divided-by-1-21-degrees-17-51-dot-78-n-slash-89-degrees-35-28-dot-18-o-slash-26-04-08-slash-09-00-am",
|
81
57
|
"/" =>
|
82
58
|
"slash",
|
83
59
|
"私はガラスを食べられます。それは私を傷つけません。" =>
|
@@ -93,7 +69,9 @@ class StringExtensionsTest < Test::Unit::TestCase
|
|
93
69
|
"AVアンプ、ホームシアターシステム、スピーカーシステム等" =>
|
94
70
|
"avanpu-homusiatasisutemu-supikasisutemudeng",
|
95
71
|
"У лукоморья дуб зеленый" =>
|
96
|
-
"u-lukomoria-dub-zielienyi"
|
72
|
+
"u-lukomoria-dub-zielienyi",
|
73
|
+
"Here are some {braces}" =>
|
74
|
+
"here-are-some-braces"
|
97
75
|
}.each do |html, plain|
|
98
76
|
assert_equal plain, html.to_url
|
99
77
|
end
|
@@ -103,6 +81,18 @@ class StringExtensionsTest < Test::Unit::TestCase
|
|
103
81
|
assert_equal "So Fucking Special", "So Fucking Special".to_url(:exclude => "So Fucking Special")
|
104
82
|
end
|
105
83
|
|
84
|
+
def test_to_url_without_forcing_downcase
|
85
|
+
assert_equal "I-have-CAPS", "I have CAPS".to_url(:force_downcase => false)
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_to_url_with_limit
|
89
|
+
assert_equal "I am much too long".to_url(:limit => 13), "i-am-much-too"
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_to_url_with_alternate_whitespace_replacement
|
93
|
+
assert_equal "under_scores", "Under Scores".to_url(:replace_whitespace_with => "_")
|
94
|
+
end
|
95
|
+
|
106
96
|
def test_remove_formatting
|
107
97
|
{
|
108
98
|
"<p>This has 100% too much <em>formatting</em></p>" =>
|
@@ -128,7 +118,7 @@ class StringExtensionsTest < Test::Unit::TestCase
|
|
128
118
|
end
|
129
119
|
end
|
130
120
|
|
131
|
-
def
|
121
|
+
def test_convert_accented_html_entities
|
132
122
|
{
|
133
123
|
"å" => "a",
|
134
124
|
"è" => "e",
|
@@ -138,60 +128,41 @@ class StringExtensionsTest < Test::Unit::TestCase
|
|
138
128
|
"Ñ" => "N",
|
139
129
|
"ç" => "c"
|
140
130
|
}.each do |entitied, plain|
|
141
|
-
assert_equal plain, entitied.
|
131
|
+
assert_equal plain, entitied.convert_accented_html_entities
|
142
132
|
end
|
143
133
|
end
|
144
134
|
|
145
|
-
def
|
135
|
+
def test_localized_vulgar_fractions_conversion
|
136
|
+
Stringex::Localization.backend = :internal
|
137
|
+
Stringex::Localization.store_translations :de, :vulgar_fractions, {
|
138
|
+
:one_fourth => "en fjerdedel",
|
139
|
+
:half => "en halv"
|
140
|
+
}
|
141
|
+
Stringex::Localization.locale = :de
|
142
|
+
|
146
143
|
{
|
147
|
-
"¼" => "
|
148
|
-
"
|
149
|
-
"¼" => "one fourth",
|
150
|
-
"½" => "half",
|
151
|
-
"½" => "half",
|
152
|
-
"½" => "half",
|
153
|
-
"¾" => "three fourths",
|
154
|
-
"¾" => "three fourths",
|
155
|
-
"¾" => "three fourths",
|
156
|
-
"⅓" => "one third",
|
157
|
-
"⅓" => "one third",
|
158
|
-
"⅔" => "two thirds",
|
159
|
-
"⅔" => "two thirds",
|
160
|
-
"⅕" => "one fifth",
|
161
|
-
"⅕" => "one fifth",
|
162
|
-
"⅖" => "two fifths",
|
163
|
-
"⅖" => "two fifths",
|
164
|
-
"⅗" => "three fifths",
|
165
|
-
"⅗" => "three fifths",
|
166
|
-
"⅘" => "four fifths",
|
167
|
-
"⅘" => "four fifths",
|
168
|
-
"⅙" => "one sixth",
|
169
|
-
"⅙" => "one sixth",
|
170
|
-
"⅚" => "five sixths",
|
171
|
-
"⅚" => "five sixths",
|
172
|
-
"⅛" => "one eighth",
|
173
|
-
"⅛" => "one eighth",
|
174
|
-
"⅜" => "three eighths",
|
175
|
-
"⅜" => "three eighths",
|
176
|
-
"⅝" => "five eighths",
|
177
|
-
"⅝" => "five eighths",
|
178
|
-
"⅞" => "seven eighths",
|
179
|
-
"⅞" => "seven eighths"
|
144
|
+
"¼" => "en fjerdedel",
|
145
|
+
"½" => "en halv"
|
180
146
|
}.each do |entitied, plain|
|
181
147
|
assert_equal plain, entitied.convert_vulgar_fractions
|
182
148
|
end
|
183
149
|
end
|
184
150
|
|
185
|
-
def
|
151
|
+
def test_localized_html_entities_conversion
|
152
|
+
Stringex::Localization.backend = :internal
|
153
|
+
Stringex::Localization.store_translations :de, :html_entities, {
|
154
|
+
:amp => "und",
|
155
|
+
:ellipsis => " prik prik prik",
|
156
|
+
:frac14 => "en fjerdedel"
|
157
|
+
}
|
158
|
+
Stringex::Localization.locale = :de
|
159
|
+
|
186
160
|
{
|
187
|
-
"
|
188
|
-
"
|
189
|
-
"
|
190
|
-
"Foo Bar" => "Foo Bar",
|
191
|
-
"100£" => "100 pound",
|
192
|
-
"35°" => "35 degrees"
|
161
|
+
"Tea & Sympathy" => "Tea und Sympathy",
|
162
|
+
"To be continued…" => "To be continued prik prik prik",
|
163
|
+
"Det var til ¼ af prisen" => "Det var til en fjerdedel af prisen"
|
193
164
|
}.each do |entitied, plain|
|
194
|
-
assert_equal plain, entitied.
|
165
|
+
assert_equal plain, entitied.convert_miscellaneous_html_entities
|
195
166
|
end
|
196
167
|
end
|
197
168
|
|
@@ -205,18 +176,19 @@ class StringExtensionsTest < Test::Unit::TestCase
|
|
205
176
|
end
|
206
177
|
end
|
207
178
|
|
208
|
-
def
|
179
|
+
def test_localized_character_conversions
|
180
|
+
Stringex::Localization.backend = :internal
|
181
|
+
Stringex::Localization.store_translations :de, :characters, {
|
182
|
+
"and" => "und",
|
183
|
+
:percent => "procent"
|
184
|
+
}
|
185
|
+
Stringex::Localization.locale = :de
|
186
|
+
|
209
187
|
{
|
210
|
-
"
|
211
|
-
"
|
212
|
-
"foo@bar.com" => "foo at bar dot com",
|
213
|
-
"100% of yr love" => "100 percent of yr love",
|
214
|
-
"Kisses are $3.25 each" => "Kisses are 3 dollars 25 cents each",
|
215
|
-
"That CD is £3.25 plus tax" => "That CD is 3 pounds 25 pence plus tax",
|
216
|
-
"This CD is ¥1000 instead" => "This CD is 1000 yen instead",
|
217
|
-
"Food+Drink" => "Food plus Drink"
|
188
|
+
"ich & dich" => "ich und dich",
|
189
|
+
"det var 100% godt" => "det var 100 procent godt"
|
218
190
|
}.each do |misc, plain|
|
219
|
-
assert_equal plain, misc.
|
191
|
+
assert_equal plain, misc.convert_miscellaneous_characters
|
220
192
|
end
|
221
193
|
end
|
222
194
|
|
@@ -242,8 +214,4 @@ class StringExtensionsTest < Test::Unit::TestCase
|
|
242
214
|
|
243
215
|
assert_equal "now-with-hyphens", "----now---------with-hyphens--------".collapse("-")
|
244
216
|
end
|
245
|
-
|
246
|
-
def test_to_url_limit
|
247
|
-
assert_equal "I am much too long".to_url(:limit => 13), "i-am-much-too"
|
248
|
-
end
|
249
217
|
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require "test/unit"
|
4
|
+
require "stringex"
|
5
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), "codepoint_test_helper.rb")
|
6
|
+
include CodepointTestHelper
|
7
|
+
|
8
|
+
class BasicGreekTest < Test::Unit::TestCase
|
9
|
+
# This test suite is just regression test and debugging
|
10
|
+
# to better transliterate the Basic Latin Unicode codepoints
|
11
|
+
#
|
12
|
+
# http://unicode.org/charts/
|
13
|
+
# http://unicode.org/charts/PDF/U0000.pdf
|
14
|
+
|
15
|
+
# NOTE: I can't figure out how to test control characters.
|
16
|
+
# Get weird results trying to pack them to unicode.
|
17
|
+
|
18
|
+
def test_greek_letters
|
19
|
+
{
|
20
|
+
"Α" => "A",
|
21
|
+
"Ά" => "A",
|
22
|
+
"Β" => "B",
|
23
|
+
"Γ" => "G",
|
24
|
+
"Δ" => "D",
|
25
|
+
"Ε" => "E",
|
26
|
+
"Έ" => "E",
|
27
|
+
"Ζ" => "Z",
|
28
|
+
"Η" => "H",
|
29
|
+
"Θ" => "Th",
|
30
|
+
"Ι" => "I",
|
31
|
+
"Ί" => "I",
|
32
|
+
"Ϊ" => "I",
|
33
|
+
"Κ" => "K",
|
34
|
+
"Λ" => "L",
|
35
|
+
"Μ" => "M",
|
36
|
+
"Ν" => "N",
|
37
|
+
"Ξ" => "Ks",
|
38
|
+
"Ο" => "O",
|
39
|
+
"Ό" => "O",
|
40
|
+
"Π" => "P",
|
41
|
+
"Ρ" => "R",
|
42
|
+
"Σ" => "S",
|
43
|
+
"Τ" => "T",
|
44
|
+
"Υ" => "Y",
|
45
|
+
"Ϋ" => "Y",
|
46
|
+
"Ύ" => "Y",
|
47
|
+
"Φ" => "Ph",
|
48
|
+
"Χ" => "Ks",
|
49
|
+
"Ψ" => "Ps",
|
50
|
+
"Ω" => "O",
|
51
|
+
"Ώ" => "O",
|
52
|
+
"α" => "a",
|
53
|
+
"ά" => "a",
|
54
|
+
"β" => "b",
|
55
|
+
"γ" => "g",
|
56
|
+
"δ" => "d",
|
57
|
+
"ε" => "e",
|
58
|
+
"έ" => "e",
|
59
|
+
"ζ" => "z",
|
60
|
+
"η" => "i",
|
61
|
+
"ή" => "i",
|
62
|
+
"θ" => "th",
|
63
|
+
"ι" => "i",
|
64
|
+
"ί" => "i",
|
65
|
+
"ϊ" => "i",
|
66
|
+
"ΐ" => "i",
|
67
|
+
"κ" => "k",
|
68
|
+
"λ" => "l",
|
69
|
+
"μ" => "m",
|
70
|
+
"ν" => "n",
|
71
|
+
"ξ" => "ks",
|
72
|
+
"ο" => "o",
|
73
|
+
"ό" => "o",
|
74
|
+
"π" => "p",
|
75
|
+
"ρ" => "r",
|
76
|
+
"σ" => "s",
|
77
|
+
"ς" => "s",
|
78
|
+
"τ" => "t",
|
79
|
+
"υ" => "u",
|
80
|
+
"ύ" => "u",
|
81
|
+
"ϋ" => "u",
|
82
|
+
"ΰ" => "u",
|
83
|
+
"φ" => "ph",
|
84
|
+
"χ" => "x",
|
85
|
+
"ψ" => "ps",
|
86
|
+
"ω" => "o",
|
87
|
+
"ώ" => "o"
|
88
|
+
}.each do |letter, ascii|
|
89
|
+
assert_equal letter.to_ascii, ascii
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
def test_greek_words
|
95
|
+
{
|
96
|
+
"Καλημέρα" => "Kalimera",
|
97
|
+
"Προϊόν" => "Proion",
|
98
|
+
"Θαλασσογραφία" => "Thalassographia",
|
99
|
+
"Να μας πάρεις μακριά" => "Na mas pareis makria",
|
100
|
+
"να μας πας στα πέρα μέρη" => "na mas pas sta pera meri",
|
101
|
+
"φύσα θάλασσα πλατιά" => "phusa thalassa platia",
|
102
|
+
"φύσα αγέρι φύσα αγέρι" => "phusa ageri phusa ageri",
|
103
|
+
"Αν θέλεις να λέγεσαι άνθρωπος" => "An theleis na legesai anthropos",
|
104
|
+
"δεν θα πάψεις ούτε στιγμή ν΄αγωνίζεσαι για την ειρήνη και" => "den tha papseis oute stigmi nagonizesai gia tin eirini kai",
|
105
|
+
"για το δίκαιο." => "gia to dikaio.",
|
106
|
+
"Θα βγείς στους δρόμους, θα φωνάξεις, τα χείλια σου θα" => "Tha bgeis stous dromous, tha phonakseis, ta xeilia sou tha",
|
107
|
+
"ματώσουν απ΄τις φωνές" => "matosoun aptis phones",
|
108
|
+
"το πρόσωπό σου θα ματώσει από τις σφαίρες – μα ούτε βήμα πίσω." => "to prosopo sou tha matosei apo tis sphaires -- ma oute bima piso.",
|
109
|
+
}.each do |letter, ascii|
|
110
|
+
assert_equal letter.to_ascii, ascii
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require "test/unit"
|
4
|
+
require "stringex"
|
5
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), "codepoint_test_helper.rb")
|
6
|
+
include CodepointTestHelper
|
7
|
+
|
8
|
+
class BasicLatinTest < Test::Unit::TestCase
|
9
|
+
# This test suite is just regression test and debugging
|
10
|
+
# to better transliterate the Basic Latin Unicode codepoints
|
11
|
+
#
|
12
|
+
# http://unicode.org/charts/
|
13
|
+
# http://unicode.org/charts/PDF/U0000.pdf
|
14
|
+
|
15
|
+
# NOTE: I can't figure out how to test control characters.
|
16
|
+
# Get weird results trying to pack them to unicode.
|
17
|
+
|
18
|
+
def test_spaces
|
19
|
+
assert_equal_encoded " ", %w{0020 00a0}
|
20
|
+
assert_equal_encoded "", %w{200b 2060}
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_exclamation_marks
|
24
|
+
assert_equal_encoded "!", %w{0021 2762}
|
25
|
+
assert_equal_encoded "!!", "203c"
|
26
|
+
assert_equal_encoded "", "00a1"
|
27
|
+
assert_equal_encoded "?!", "203d"
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_quotation_marks
|
31
|
+
assert_equal_encoded "\"", %w{0022 02ba 2033 3003}
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_apostrophes
|
35
|
+
assert_equal_encoded "'", %w{0027 02b9 02bc 02c8 2032}
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_asterisks
|
39
|
+
assert_equal_encoded "*", %w{002a 066d 204e 2217 26b9 2731}
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_commas
|
43
|
+
assert_equal_encoded ",", %w{002c 060c}
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_periods
|
47
|
+
assert_equal_encoded ".", %w{002e 06d4}
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_hyphens
|
51
|
+
assert_equal_encoded "-", %w{002d 2010 2011 2012 2212}
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_endash
|
55
|
+
assert_equal_encoded "--", %w{2013 2015}
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_emdash
|
59
|
+
assert_equal_encoded "---", %w{2014}
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_dotleader
|
63
|
+
assert_equal_encoded "..", %w{2025}
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_ellipsis
|
67
|
+
assert_equal_encoded "...", %w{2026}
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_slashes
|
71
|
+
assert_equal_encoded "/", %w{002f 2044 2215}
|
72
|
+
assert_equal_encoded "\\", %w{005c 2216}
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_colons
|
76
|
+
assert_equal_encoded ":", %w{003a 2236}
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_semicolons
|
80
|
+
assert_equal_encoded ";", %w{003b 061b}
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_less_thans
|
84
|
+
assert_equal_encoded "<", %w{003c 2039 2329 27e8 3008}
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_equals
|
88
|
+
assert_equal_encoded "=", "003d"
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_greater_thans
|
92
|
+
assert_equal_encoded ">", %w{003e 203a 232a 27e9 3009}
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_question_marks
|
96
|
+
assert_equal_encoded "?", %w{003f 061f}
|
97
|
+
assert_equal_encoded "", "00bf"
|
98
|
+
assert_equal_encoded "?!", %w{203d 2048}
|
99
|
+
assert_equal_encoded "!?", "2049"
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_circumflexes
|
103
|
+
assert_equal_encoded "^", %w{005e 2038 2303}
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_underscores
|
107
|
+
assert_equal_encoded "_", %w{005f 02cd 2017}
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_grave_accents
|
111
|
+
assert_equal_encoded "'", %w{0060 02cb 2035}
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_bars
|
115
|
+
assert_equal_encoded "|", %w{007c 2223 2758}
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_tildes
|
119
|
+
assert_equal_encoded "~", %w{007e 02dc 2053 223c ff5e}
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_related_letters
|
123
|
+
{
|
124
|
+
"B" => "212c",
|
125
|
+
"C" => %w{2102 212d},
|
126
|
+
"E" => %w{2107 2130},
|
127
|
+
"F" => "2131",
|
128
|
+
"H" => %w{210b 210c 210d},
|
129
|
+
"I" => %w{0130 0406 04c0 2110 2111 2160},
|
130
|
+
"K" => "212a",
|
131
|
+
"L" => "2112",
|
132
|
+
"M" => "2133",
|
133
|
+
"N" => "2115",
|
134
|
+
"P" => "2119",
|
135
|
+
"Q" => "211a",
|
136
|
+
"R" => %w{211b 211c 211d},
|
137
|
+
"Z" => %w{2124 2128}
|
138
|
+
}.each do |expected, encode_mes|
|
139
|
+
assert_equal_encoded expected, encode_mes
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|