diff options
author | Nobuyoshi Nakada <[email protected]> | 2020-04-11 12:06:59 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2020-04-11 12:59:45 +0900 |
commit | e56e089b1f92dbc55d3239b6843dd0786be9000e (patch) | |
tree | 22e5083e9d942e46bf7cff719806212a6dc79e6c /test/ruby/test_dir.rb | |
parent | bae16b427765d237aabd8939557325f1530d623b (diff) |
Assertions for basic use of `encoding:` option
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3018
Diffstat (limited to 'test/ruby/test_dir.rb')
-rw-r--r-- | test/ruby/test_dir.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ruby/test_dir.rb b/test/ruby/test_dir.rb index 3e33eef5e6..13b9c1ddf2 100644 --- a/test/ruby/test_dir.rb +++ b/test/ruby/test_dir.rb @@ -320,6 +320,9 @@ class TestDir < Test::Unit::TestCase assert_entries(Dir.open(@root) {|dir| dir.entries}) assert_entries(Dir.entries(@root)) assert_raise(ArgumentError) {Dir.entries(@root+"\0")} + [Encoding::UTF_8, Encoding::ASCII_8BIT].each do |enc| + assert_equal(enc, Dir.entries(@root, encoding: enc).first.encoding) + end end def test_foreach @@ -332,12 +335,19 @@ class TestDir < Test::Unit::TestCase Dir.mkdir(newdir) File.write(newdir+"/a", "") assert_equal(%w[. .. a], e.to_a.sort) + [Encoding::UTF_8, Encoding::ASCII_8BIT].each do |enc| + e = Dir.foreach(newdir, encoding: enc) + assert_equal(enc, e.to_a.first.encoding) + end end def test_children assert_entries(Dir.open(@root) {|dir| dir.children}, true) assert_entries(Dir.children(@root), true) assert_raise(ArgumentError) {Dir.children(@root+"\0")} + [Encoding::UTF_8, Encoding::ASCII_8BIT].each do |enc| + assert_equal(enc, Dir.children(@root, encoding: enc).first.encoding) + end end def test_each_child @@ -350,6 +360,10 @@ class TestDir < Test::Unit::TestCase Dir.mkdir(newdir) File.write(newdir+"/a", "") assert_equal(%w[a], e.to_a) + [Encoding::UTF_8, Encoding::ASCII_8BIT].each do |enc| + e = Dir.each_child(newdir, encoding: enc) + assert_equal(enc, e.to_a.first.encoding) + end end def test_dir_enc |