diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-08-20 01:04:02 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-08-20 03:57:13 +0900 |
commit | 1ef49de83483e6f78bfe9c795a473ccfb29db150 (patch) | |
tree | f6c48f28801763a95372f143b2cdea5564b96336 /test | |
parent | ce384ef5a95b809f248e089c1608e60753dabe45 (diff) |
[Bug #18955] format single character for `%c`
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6258
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_m17n.rb | 2 | ||||
-rw-r--r-- | test/ruby/test_sprintf.rb | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb index 2c6fcee004..a50507a528 100644 --- a/test/ruby/test_m17n.rb +++ b/test/ruby/test_m17n.rb @@ -893,7 +893,7 @@ class TestM17N < Test::Unit::TestCase "%s%s" % [s("\xc2\xa1"), e("\xc2\xa1")] } - "%c" % "\u3042".encode('Windows-31J') + assert_equal("\u3042".encode('Windows-31J'), "%c" % "\u3042\u3044".encode('Windows-31J')) end def test_sprintf_p diff --git a/test/ruby/test_sprintf.rb b/test/ruby/test_sprintf.rb index b05f4f3e44..618e67264a 100644 --- a/test/ruby/test_sprintf.rb +++ b/test/ruby/test_sprintf.rb @@ -362,7 +362,8 @@ class TestSprintf < Test::Unit::TestCase def test_char assert_equal("a", sprintf("%c", 97)) assert_equal("a", sprintf("%c", ?a)) - assert_raise(ArgumentError) { sprintf("%c", sprintf("%c%c", ?a, ?a)) } + assert_equal("a", sprintf("%c", "a")) + assert_equal("a", sprintf("%c", sprintf("%c%c", ?a, ?a))) assert_equal(" " * (BSIZ - 1) + "a", sprintf(" " * (BSIZ - 1) + "%c", ?a)) assert_equal(" " * (BSIZ - 1) + "a", sprintf(" " * (BSIZ - 1) + "%-1c", ?a)) assert_equal(" " * BSIZ + "a", sprintf("%#{ BSIZ + 1 }c", ?a)) |