Skip to content

Instantly share code, notes, and snippets.

@headius
Created February 27, 2013 00:17
Show Gist options
  • Save headius/5043649 to your computer and use it in GitHub Desktop.
Save headius/5043649 to your computer and use it in GitHub Desktop.
require "test/unit"
require "etc"
require 'pp'
class TestEtc < Test::Unit::TestCase
def test_getpwnam
passwd = {}
Etc.passwd {|s| passwd[s.uid] ||= s }
assert_equal(passwd[55], Etc.getpwuid(55))
passwd = {}
Etc.passwd do |s|
passwd[s.name] ||= s unless /\A\+/ =~ s.name
end
passwd.each_value do |s|
assert_equal(s, Etc.getpwnam(s.name))
end
passwd = {}
Etc.passwd {|s| passwd[s.uid] ||= s }
assert_equal(passwd[55], Etc.getpwuid(55))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment