diff --git a/activesupport/test/multibyte_chars_test.rb b/activesupport/test/multibyte_chars_test.rb index 63cfadb..96a33b1 100644 --- a/activesupport/test/multibyte_chars_test.rb +++ b/activesupport/test/multibyte_chars_test.rb @@ -76,6 +76,24 @@ class CharsTest < Test::Unit::TestCase assert_kind_of ActiveSupport::Multibyte::Chars, word.chars.split(//).first, "Split should return Chars instances" end + def test_normalization + handler = ActiveSupport::Multibyte::Handlers::UTF8Handler + composed = handler.normalize("bös") + decomposed = handler.normalize("bös", :kd) + reverse_composed = handler.normalize("söb") + reverse_decomposed = handler.normalize("söb", :kd) + +# assert_equal composed.chars, decomposed.chars # not sure if this should pass or not + + # this passes + assert_equal reverse_composed, composed.chars.reverse + # this fails, but shouldn't + assert [reverse_composed, reverse_decomposed].include?(decomposed.chars.reverse), + "decomposed.chars.reverse was expected to be " + + [reverse_composed, reverse_decomposed].map(&:inspect).join(" or ") + + " but was #{decomposed.chars.reverse.to_s.inspect}" + end + def test_regexp with_kcode('none') do assert_equal 12, (@s[:utf8].chars =~ /ffi/),