1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix some wrong String extensions tests

* ASCII_STRING was not an ASCII String
* BYTE_STRING was not an in valid UTF-8 String
* added an assertion for non-UTF-8 String
This commit is contained in:
Akira Matsuda 2013-01-23 01:02:28 +09:00
parent 389ae055ae
commit 9b0f3faab4

View file

@ -361,22 +361,24 @@ class StringBehaviourTest < ActiveSupport::TestCase
end
class CoreExtStringMultibyteTest < ActiveSupport::TestCase
UNICODE_STRING = 'こにちわ'
ASCII_STRING = 'ohayo'
BYTE_STRING = "\270\236\010\210\245"
UTF8_STRING = 'こにちわ'
ASCII_STRING = 'ohayo'.encode('US-ASCII')
EUC_JP_STRING = 'さよなら'.encode('EUC-JP')
INVALID_UTF8_STRING = "\270\236\010\210\245"
def test_core_ext_adds_mb_chars
assert_respond_to UNICODE_STRING, :mb_chars
assert_respond_to UTF8_STRING, :mb_chars
end
def test_string_should_recognize_utf8_strings
assert UNICODE_STRING.is_utf8?
assert UTF8_STRING.is_utf8?
assert ASCII_STRING.is_utf8?
assert !BYTE_STRING.is_utf8?
assert !EUC_JP_STRING.is_utf8?
assert !INVALID_UTF8_STRING.is_utf8?
end
def test_mb_chars_returns_instance_of_proxy_class
assert_kind_of ActiveSupport::Multibyte.proxy_class, UNICODE_STRING.mb_chars
assert_kind_of ActiveSupport::Multibyte.proxy_class, UTF8_STRING.mb_chars
end
end