aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/multibyte_conformance.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/test/multibyte_conformance.rb')
-rw-r--r--activesupport/test/multibyte_conformance.rb30
1 files changed, 15 insertions, 15 deletions
diff --git a/activesupport/test/multibyte_conformance.rb b/activesupport/test/multibyte_conformance.rb
index 6ec9a839af..b3b477bb75 100644
--- a/activesupport/test/multibyte_conformance.rb
+++ b/activesupport/test/multibyte_conformance.rb
@@ -27,21 +27,21 @@ end
class MultibyteConformanceTest < Test::Unit::TestCase
include MultibyteTestHelpers
-
+
UNIDATA_URL = "http://www.unicode.org/Public/#{ActiveSupport::Multibyte::Unicode::UNICODE_VERSION}/ucd"
UNIDATA_FILE = '/NormalizationTest.txt'
CACHE_DIR = File.join(Dir.tmpdir, 'cache')
-
+
def setup
FileUtils.mkdir_p(CACHE_DIR)
Downloader.download(UNIDATA_URL + UNIDATA_FILE, CACHE_DIR + UNIDATA_FILE)
@proxy = ActiveSupport::Multibyte::Chars
end
-
+
def test_normalizations_C
each_line_of_norm_tests do |*cols|
col1, col2, col3, col4, col5, comment = *cols
-
+
# CONFORMANCE:
# 1. The following invariants must be true for all conformant implementations
#
@@ -56,7 +56,7 @@ class MultibyteConformanceTest < Test::Unit::TestCase
assert_equal_codepoints col4, @proxy.new(col5).normalize(:c), "Form C - Col 4 has to be C(5) - #{comment}"
end
end
-
+
def test_normalizations_D
each_line_of_norm_tests do |*cols|
col1, col2, col3, col4, col5, comment = *cols
@@ -71,10 +71,10 @@ class MultibyteConformanceTest < Test::Unit::TestCase
assert_equal_codepoints col5, @proxy.new(col5).normalize(:d), "Form D - Col 5 has to be NFD(5) - #{comment}"
end
end
-
+
def test_normalizations_KC
each_line_of_norm_tests do | *cols |
- col1, col2, col3, col4, col5, comment = *cols
+ col1, col2, col3, col4, col5, comment = *cols
#
# NFKC
# c4 == NFKC(c1) == NFKC(c2) == NFKC(c3) == NFKC(c4) == NFKC(c5)
@@ -85,10 +85,10 @@ class MultibyteConformanceTest < Test::Unit::TestCase
assert_equal_codepoints col4, @proxy.new(col5).normalize(:kc), "Form D - Col 4 has to be NFKC(5) - #{comment}"
end
end
-
+
def test_normalizations_KD
each_line_of_norm_tests do | *cols |
- col1, col2, col3, col4, col5, comment = *cols
+ col1, col2, col3, col4, col5, comment = *cols
#
# NFKD
# c5 == NFKD(c1) == NFKD(c2) == NFKD(c3) == NFKD(c4) == NFKD(c5)
@@ -99,7 +99,7 @@ class MultibyteConformanceTest < Test::Unit::TestCase
assert_equal_codepoints col5, @proxy.new(col5).normalize(:kd), "Form KD - Col 5 has to be NFKD(5) - #{comment}"
end
end
-
+
protected
def each_line_of_norm_tests(&block)
lines = 0
@@ -108,21 +108,21 @@ class MultibyteConformanceTest < Test::Unit::TestCase
until f.eof? || (max_test_lines > 38 and lines > max_test_lines)
lines += 1
line = f.gets.chomp!
- next if (line.empty? || line =~ /^\#/)
-
+ next if (line.empty? || line =~ /^\#/)
+
cols, comment = line.split("#")
cols = cols.split(";").map{|e| e.strip}.reject{|e| e.empty? }
next unless cols.length == 5
-
+
# codepoints are in hex in the test suite, pack wants them as integers
cols.map!{|c| c.split.map{|codepoint| codepoint.to_i(16)}.pack("U*") }
cols << comment
-
+
yield(*cols)
end
end
end
-
+
def inspect_codepoints(str)
str.to_s.unpack("U*").map{|cp| cp.to_s(16) }.join(' ')
end