From 0971cab4d0cb730292461d16ac72c430aa23cc10 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 17 May 2019 09:53:47 +0900 Subject: [PATCH] Test to disable ASCII-only optimization Examples why ASCII-only optimization cannot apply multi-byte encodings which have 7-bit trailing bytes. Suggested by @duerst at https://github.com/ruby/ruby/pull/2187#issuecomment-492949218 --- test/ruby/enc/test_case_mapping.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/ruby/enc/test_case_mapping.rb b/test/ruby/enc/test_case_mapping.rb index aa20531783..31acdc4331 100644 --- a/test/ruby/enc/test_case_mapping.rb +++ b/test/ruby/enc/test_case_mapping.rb @@ -210,6 +210,16 @@ class TestCaseMappingPreliminary < Test::Unit::TestCase assert_equal "\u10D0\u10D1\u10D2", "\u10D0\u10D1\u10D2".capitalize end + def test_shift_jis_downcase_ascii + s = ("A".."Z").map {|c| "\x89#{c}"}.join("").force_encoding("Shift_JIS") + assert_equal s, s.downcase(:ascii) + end + + def test_shift_jis_upcase_ascii + s = ("a".."z").map {|c| "\x89#{c}"}.join("").force_encoding("Shift_JIS") + assert_equal s, s.upcase(:ascii) + end + def no_longer_a_test_buffer_allocations assert_equal 'TURKISH*ı'*10, ('I'*10).downcase(:turkic) assert_equal 'TURKISH*ı'*100, ('I'*100).downcase(:turkic)