diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-03 15:39:44 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-03 15:39:44 +0000 |
commit | a20e7896a7d8c56276cf47b025bc0ea54e547df2 (patch) | |
tree | c3f8996c1d67dd6c1b827dd10bb0d0639db798f4 /test | |
parent | 20d4b0b717c75fd116e403704d80280c1470cf58 (diff) | |
download | ruby-a20e7896a7d8c56276cf47b025bc0ea54e547df2.tar.gz ruby-a20e7896a7d8c56276cf47b025bc0ea54e547df2.tar.xz ruby-a20e7896a7d8c56276cf47b025bc0ea54e547df2.zip |
* test/etc/test_etc.rb(test_getpwnam, test_getgrgid, test_getgrnam):
support an envirionment that has duplicative entries. a patch from
Tomoyuki Chikanaga <chikanag at nippon-control-system.co.jp> in
[ruby-dev:37882].
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@22021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/etc/test_etc.rb | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/test/etc/test_etc.rb b/test/etc/test_etc.rb index add7d6365..4e44eda19 100644 --- a/test/etc/test_etc.rb +++ b/test/etc/test_etc.rb @@ -37,9 +37,9 @@ class TestEtc < Test::Unit::TestCase end def test_getpwnam - passwd = [] - Etc.passwd {|s| passwd << s } - passwd.each do |s| + passwd = {} + Etc.passwd {|s| passwd[s.name] = s unless passwd[s.name] } + passwd.values.each do |s| assert_equal(s, Etc.getpwnam(s.name)) end end @@ -67,22 +67,26 @@ class TestEtc < Test::Unit::TestCase end def test_getgrgid - groups = [] + groups = {} Etc.group do |s| - groups << s + unless groups[s.gid] + groups[s.gid] = s + end end - groups.each do |s| + groups.values.each do |s| assert_equal(s, Etc.getgrgid(s.gid)) assert_equal(s, Etc.getgrgid) if Process.egid == s.gid end end def test_getgrnam - groups = [] + groups = {} Etc.group do |s| - groups << s + unless groups[s.name] + groups[s.name] = s + end end - groups.each do |s| + groups.values.each do |s| assert_equal(s, Etc.getgrnam(s.name)) end end |