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 | c07b4ef145993f89d4a9baf36781fcb08112a3ac (patch) | |
tree | c3f8996c1d67dd6c1b827dd10bb0d0639db798f4 /test/etc | |
parent | ee3c53a7a9bf1d9d58c4c3054cee604459324d17 (diff) | |
download | ruby-c07b4ef145993f89d4a9baf36781fcb08112a3ac.tar.gz |
* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@22021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/etc')
-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 add7d63652..4e44eda19a 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 |