summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-06 06:18:38 +0000
committerduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-06 06:18:38 +0000
commite8dde46b6064c07e2b11a42046e2948bcbc2dd06 (patch)
tree177ff208b84602b305071d32d747d17bdad3662b /test/ruby
parentb217dc81f3e08207a381b9c7cdb86d4909c579e6 (diff)
* test/ruby/enc/test_regex_casefold.rb: Added data-based testing for
String#downcase :fold. * enc/unicode.c: Fixed a range error (lowest non-ASCII character affected by case operations is U+00B5, MICRO SIGN) * test/ruby/enc/test_case_mapping.rb: Explicit test for case folding of MICRO SIGN to Greek mu. (with Kimihito Matsui) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/enc/test_case_mapping.rb1
-rw-r--r--test/ruby/enc/test_regex_casefold.rb14
2 files changed, 15 insertions, 0 deletions
diff --git a/test/ruby/enc/test_case_mapping.rb b/test/ruby/enc/test_case_mapping.rb
index 2c712e4..0336e3f 100644
--- a/test/ruby/enc/test_case_mapping.rb
+++ b/test/ruby/enc/test_case_mapping.rb
@@ -63,6 +63,7 @@ class TestCaseMappingPreliminary < Test::Unit::TestCase
check_downcase_properties 'ss', 'ß', :fold
check_downcase_properties 'fifl', 'fifl', :fold
check_downcase_properties 'σ', 'ς', :fold
+ check_downcase_properties 'μ', 'µ', :fold # MICRO SIGN -> Greek mu
end
def test_turcic
diff --git a/test/ruby/enc/test_regex_casefold.rb b/test/ruby/enc/test_regex_casefold.rb
index 825a02a..808ea14 100644
--- a/test/ruby/enc/test_regex_casefold.rb
+++ b/test/ruby/enc/test_regex_casefold.rb
@@ -8,6 +8,15 @@ class TestCaseFold < Test::Unit::TestCase
UNICODE_VERSION = UnicodeNormalize::UNICODE_VERSION
CaseTest = Struct.new :source, :target, :kind, :line
+ def check_downcase_properties(expected, start, *flags)
+ assert_equal expected, start.downcase(*flags)
+ temp = start
+ assert_equal expected, temp.downcase!(*flags)
+ assert_equal expected, expected.downcase(*flags)
+ temp = expected
+ assert_nil temp.downcase!(*flags)
+ end
+
def read_tests
IO.readlines(File.expand_path("../../../enc/unicode/data/#{UNICODE_VERSION}/CaseFolding.txt", __dir__))
.collect.with_index { |linedata, linenumber| [linenumber.to_i+1, linedata.chomp] }
@@ -75,7 +84,12 @@ class TestCaseFold < Test::Unit::TestCase
end
end
end
+ end
+ def test_downcase_fold
+ @@tests.each do |test|
+ check_downcase_properties test.target, test.source, :fold
+ end
end
# start with good encodings only