diff options
author | Akira Matsuda <ronnie@dio.jp> | 2013-01-23 01:02:28 +0900 |
---|---|---|
committer | Akira Matsuda <ronnie@dio.jp> | 2013-01-23 13:30:55 +0900 |
commit | 9b0f3faab4ec128a8fafd10d9d34e76b95b162cc (patch) | |
tree | 8bce620db131ad56c2e07452966d9bef433dedb6 /activesupport/test/core_ext | |
parent | 389ae055aede8bce1721c0e7ab60c9aaec2109ee (diff) | |
download | rails-9b0f3faab4ec128a8fafd10d9d34e76b95b162cc.tar.gz rails-9b0f3faab4ec128a8fafd10d9d34e76b95b162cc.tar.bz2 rails-9b0f3faab4ec128a8fafd10d9d34e76b95b162cc.zip |
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
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r-- | activesupport/test/core_ext/string_ext_test.rb | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb index 4ee78ad0d4..9b22a305c8 100644 --- a/activesupport/test/core_ext/string_ext_test.rb +++ b/activesupport/test/core_ext/string_ext_test.rb @@ -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 |