diff options
Diffstat (limited to 'activesupport/test/multibyte_chars_test.rb')
-rw-r--r-- | activesupport/test/multibyte_chars_test.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activesupport/test/multibyte_chars_test.rb b/activesupport/test/multibyte_chars_test.rb index e1c4b705f8..8d4d9d736c 100644 --- a/activesupport/test/multibyte_chars_test.rb +++ b/activesupport/test/multibyte_chars_test.rb @@ -413,12 +413,24 @@ class MultibyteCharsUTF8BehaviourTest < ActiveSupport::TestCase assert_equal 'にち', @chars.slice!(1..2) end + def test_slice_bang_returns_nil_on_out_of_bound_arguments + assert_equal nil, @chars.mb_chars.slice!(9..10) + end + def test_slice_bang_removes_the_slice_from_the_receiver chars = 'úüù'.mb_chars chars.slice!(0,2) assert_equal 'ù', chars end + def test_slice_bang_returns_nil_and_does_not_modify_receiver_if_out_of_bounds + string = 'úüù' + chars = string.mb_chars + assert_nil chars.slice!(4, 5) + assert_equal 'úüù', chars + assert_equal 'úüù', string + end + def test_slice_should_throw_exceptions_on_invalid_arguments assert_raise(TypeError) { @chars.slice(2..3, 1) } assert_raise(TypeError) { @chars.slice(1, 2..3) } |