diff options
author | duerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-01-17 11:10:45 +0000 |
---|---|---|
committer | duerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-01-17 11:10:45 +0000 |
commit | 57d74bf836ad68dac11a2e00b8ae22190989f9d1 (patch) | |
tree | a0ce6d1776115ac0d8eaa7c1fdbb37dc3df7c595 /test/ruby/enc/test_case_mapping.rb | |
parent | 2f5e35da5a57e89e55d96f8216ab37dd590644b0 (diff) | |
download | ruby-57d74bf836ad68dac11a2e00b8ae22190989f9d1.tar.gz |
* enc/unicode.c: Fixed a logical error and some comments.
* test/ruby/enc/test_case_mapping.rb: Made tests more general.
(with Kimihito Matsui)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/enc/test_case_mapping.rb')
-rw-r--r-- | test/ruby/enc/test_case_mapping.rb | 55 |
1 files changed, 43 insertions, 12 deletions
diff --git a/test/ruby/enc/test_case_mapping.rb b/test/ruby/enc/test_case_mapping.rb index eb36d7d665..6191883637 100644 --- a/test/ruby/enc/test_case_mapping.rb +++ b/test/ruby/enc/test_case_mapping.rb @@ -5,22 +5,53 @@ require "test/unit" # preliminary tests, using :lithuanian as a guard # to test new implementation strategy class TestCaseMappingPreliminary < Test::Unit::TestCase + # checks, including idempotence and non-modification; not always guaranteed + def check_upcase_properties(expected, start, *flags) + assert_equal expected, start.upcase(*flags) + temp = start + assert_equal expected, temp.upcase!(*flags) + assert_equal expected, expected.upcase(*flags) + temp = expected + assert_nil temp.upcase!(*flags) + end + + 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 check_capitalize_properties(expected, start, *flags) + assert_equal expected, start.capitalize(*flags) + temp = start + assert_equal expected, temp.capitalize!(*flags) + assert_equal expected, expected.capitalize(*flags) + temp = expected + assert_nil temp.capitalize!(*flags) + end + + # different properties; careful: roundtrip isn't always guaranteed + def check_swapcase_properties(expected, start, *flags) + assert_equal expected, start.swapcase(*flags) + temp = start + assert_equal expected, temp.swapcase!(*flags) + assert_equal start, start.swapcase(*flags).swapcase(*flags) + assert_equal expected, expected.swapcase(*flags).swapcase(*flags) + end + def test_ascii - assert_equal 'yukihiro matsumoto (matz)', - 'Yukihiro MATSUMOTO (MATZ)'.downcase(:lithuanian) - assert_equal 'YUKIHIRO MATSUMOTO (MATZ)', - 'yukihiro matsumoto (matz)'.upcase(:lithuanian) - assert_equal 'Yukihiro matsumoto (matz)', - 'yukihiro MATSUMOTO (MATZ)'.capitalize(:lithuanian) - assert_equal 'yUKIHIRO matsumoto (MAtz)', - 'Yukihiro MATSUMOTO (maTZ)'.swapcase(:lithuanian) + check_downcase_properties 'yukihiro matsumoto (matz)', 'Yukihiro MATSUMOTO (MATZ)', :lithuanian + check_upcase_properties 'YUKIHIRO MATSUMOTO (MATZ)', 'yukihiro matsumoto (matz)', :lithuanian + check_capitalize_properties 'Yukihiro matsumoto (matz)', 'yukihiro MATSUMOTO (MATZ)', :lithuanian + check_swapcase_properties 'yUKIHIRO matsumoto (MAtz)', 'Yukihiro MATSUMOTO (maTZ)', :lithuanian end def test_turcic - assert_equal 'yukihiro matsumoto (matz)', - 'Yukihiro MATSUMOTO (MATZ)'.downcase(:turkic, :lithuanian) - assert_equal 'YUKİHİRO MATSUMOTO (MATZ)', - 'Yukihiro Matsumoto (matz)'.upcase(:turkic, :lithuanian) + check_downcase_properties 'yukihiro matsumoto (matz)', 'Yukihiro MATSUMOTO (MATZ)', :turkic, :lithuanian + check_upcase_properties 'YUKİHİRO MATSUMOTO (MATZ)', 'Yukihiro Matsumoto (matz)', :turkic, :lithuanian end def no_longer_a_test_buffer_allocations |