diff options
author | NARUSE, Yui <[email protected]> | 2021-01-24 15:55:22 +0900 |
---|---|---|
committer | NARUSE, Yui <[email protected]> | 2021-01-24 15:57:13 +0900 |
commit | 1bd27a78827109f85357f80827a9975fae9bb2a5 (patch) | |
tree | 067847e59c939cf06beb251b2d541cae99cca992 /test/ruby/test_m17n_comb.rb | |
parent | d6e43e472356d8e0753f054278e71f1b299fdb4b (diff) |
Add test for String#casecmp?
String#casecmp? also normalize upper case characters in legacy encodings.
Diffstat (limited to 'test/ruby/test_m17n_comb.rb')
-rw-r--r-- | test/ruby/test_m17n_comb.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/ruby/test_m17n_comb.rb b/test/ruby/test_m17n_comb.rb index 49141790f0..e48a1948be 100644 --- a/test/ruby/test_m17n_comb.rb +++ b/test/ruby/test_m17n_comb.rb @@ -593,6 +593,21 @@ class TestM17NComb < Test::Unit::TestCase } end + def test_str_casecmp? + strings = STRINGS.dup + strings.push( + # prevent wrong single byte optimization + "\xC0".force_encoding("ISO-8859-1"), + "\xE0".force_encoding("ISO-8859-1"), + ) + combination(strings, strings) {|s1, s2| + #puts "#{encdump(s1)}.casecmp(#{encdump(s2)})" + next unless s1.valid_encoding? && s2.valid_encoding? && Encoding.compatible?(s1, s2) + r = s1.casecmp?(s2) + assert_equal(s1.downcase(:fold) == s2.downcase(:fold), r) + } + end + def test_str_center combination(STRINGS, [0,1,2,3,10]) {|s1, width| t = s1.center(width) |