aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorMarcel Molina <marcel@vernix.org>2007-07-31 04:59:10 +0000
committerMarcel Molina <marcel@vernix.org>2007-07-31 04:59:10 +0000
commitbe196f3f7ec86e072d455cdca6acae1fd8782066 (patch)
treebff8a29f107e7a5042e713f69d957e62f9b9116d /activesupport/test
parentea07212d9780841fbfb3368247ccc0b4bdee5bf5 (diff)
downloadrails-be196f3f7ec86e072d455cdca6acae1fd8782066.tar.gz
rails-be196f3f7ec86e072d455cdca6acae1fd8782066.tar.bz2
rails-be196f3f7ec86e072d455cdca6acae1fd8782066.zip
Add support for []= on ActiveSupport::Multibyte::Chars. Closes #9142. [ewan, manfred]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7257 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/multibyte_handler_test.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/activesupport/test/multibyte_handler_test.rb b/activesupport/test/multibyte_handler_test.rb
index ea728aa555..e4744def6c 100644
--- a/activesupport/test/multibyte_handler_test.rb
+++ b/activesupport/test/multibyte_handler_test.rb
@@ -199,6 +199,40 @@ module UTF8HandlingTest
assert_raise(ActiveSupport::Multibyte::Handlers::EncodingError) { @handler.index(@bytestring, "\010") }
end
+ def test_indexed_insert
+ s = "Καλη!"
+ @handler[s, 2] = "a"
+ assert_equal "Καaη!", s
+ @handler[s, 2] = "ηη"
+ assert_equal "Καηηη!", s
+ assert_raises(IndexError) { @handler[s, 10] = 'a' }
+ assert_equal "Καηηη!", s
+ @handler[s, 2] = 32
+ assert_equal "Κα ηη!", s
+ @handler[s, 3, 2] = "λλλ"
+ assert_equal "Κα λλλ!", s
+ @handler[s, 1, 0] = "λ"
+ assert_equal "Κλα λλλ!", s
+ assert_raises(IndexError) { @handler[s, 10, 4] = 'a' }
+ assert_equal "Κλα λλλ!", s
+ @handler[s, 4..6] = "ηη"
+ assert_equal "Κλα ηη!", s
+ assert_raises(RangeError) { @handler[s, 10..12] = 'a' }
+ assert_equal "Κλα ηη!", s
+ @handler[s, /ηη/] = "λλλ"
+ assert_equal "Κλα λλλ!", s
+ assert_raises(IndexError) { @handler[s, /ii/] = 'a' }
+ assert_equal "Κλα λλλ!", s
+ @handler[s, /(λλ)(.)/, 2] = "α"
+ assert_equal "Κλα λλα!", s
+ assert_raises(IndexError) { @handler[s, /()/, 10] = 'a' }
+ assert_equal "Κλα λλα!", s
+ @handler[s, "α"] = "η"
+ assert_equal "Κλη λλα!", s
+ @handler[s, "λλ"] = "ααα"
+ assert_equal "Κλη αααα!", s
+ end
+
def test_strip
# A unicode aware version of strip should strip all 26 types of whitespace. This includes the NO BREAK SPACE
# aka BOM (byte order mark). The byte order mark has no place in UTF-8 because it's used to detect LE and BE.