1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* test/ruby/enc/test_case_comprehensive.rb: Add tests for full Unicode

swapcase.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
duerst 2016-06-13 07:58:57 +00:00
parent f54490251a
commit 86e9f85553
2 changed files with 33 additions and 1 deletions

View file

@ -1,3 +1,8 @@
Mon Jun 13 16:58:53 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
* test/ruby/enc/test_case_comprehensive.rb: Add tests for full Unicode
swapcase.
Sun Jun 12 14:48:00 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
* test/ruby/enc/test_case_comprehensive.rb: Add tests for ASCII-only

View file

@ -45,9 +45,11 @@ class TestComprehensiveCaseFold < Test::Unit::TestCase
upcase = Hash.new { |h, c| h[c] = c }
titlecase = Hash.new { |h, c| h[c] = c }
casefold = Hash.new { |h, c| h[c] = c }
swapcase = Hash.new { |h, c| h[c] = c }
turkic_upcase = Hash.new { |h, c| h[c] = upcase[c] }
turkic_downcase = Hash.new { |h, c| h[c] = downcase[c] }
turkic_titlecase = Hash.new { |h, c| h[c] = titlecase[c] }
turkic_swapcase = Hash.new { |h, c| h[c] = swapcase[c] }
ascii_upcase = Hash.new { |h, c| h[c] = c =~ /^[a-zA-Z]$/ ? upcase[c] : c }
ascii_downcase = Hash.new { |h, c| h[c] = c =~ /^[a-zA-Z]$/ ? downcase[c] : c }
ascii_titlecase = Hash.new { |h, c| h[c] = c =~ /^[a-zA-Z]$/ ? titlecase[c] : c }
@ -78,15 +80,40 @@ class TestComprehensiveCaseFold < Test::Unit::TestCase
end
end
@@codepoints.each do |c|
if upcase[c] != c
if downcase[c] != c
swapcase[c] = turkic_swapcase[c] =
case c
when "\u01C5" then "\u0064\u017D"
when "\u01C8" then "\u006C\u004A"
when "\u01CB" then "\u006E\u004A"
when "\u01F2" then "\u0064\u005A"
else # Greek
downcase[upcase[c][0]] + "\u0399"
end
else
swapcase[c] = upcase[c]
turkic_swapcase[c] = turkic_upcase[c]
end
else
if downcase[c] != c
swapcase[c] = downcase[c]
turkic_swapcase[c] = turkic_downcase[c]
end
end
end
tests = [
CaseTest.new(:downcase, [], downcase),
CaseTest.new(:upcase, [], upcase),
CaseTest.new(:capitalize, [], titlecase, downcase),
# swapcase?????!!!!!
CaseTest.new(:swapcase, [], swapcase),
CaseTest.new(:downcase, [:fold], casefold),
CaseTest.new(:upcase, [:turkic], turkic_upcase),
CaseTest.new(:downcase, [:turkic], turkic_downcase),
CaseTest.new(:capitalize, [:turkic], turkic_titlecase, turkic_downcase),
CaseTest.new(:swapcase, [:turkic], turkic_swapcase),
CaseTest.new(:upcase, [:ascii], ascii_upcase),
CaseTest.new(:downcase, [:ascii], ascii_downcase),
CaseTest.new(:capitalize, [:ascii], ascii_titlecase, ascii_downcase),