4 class TestEtc < Test::Unit::TestCase
7 assert(s.is_a?(String) || s == nil, "getlogin must return a String or nil")
12 assert_instance_of(String, s.name)
13 assert_instance_of(String, s.passwd) if s.respond_to?(:passwd)
14 assert_kind_of(Integer, s.uid)
15 assert_kind_of(Integer, s.gid)
16 assert_instance_of(String, s.gecos) if s.respond_to?(:gecos)
17 assert_instance_of(String, s.dir)
18 assert_instance_of(String, s.shell)
19 assert_kind_of(Integer, s.change) if s.respond_to?(:change)
20 assert_kind_of(Integer, s.quota) if s.respond_to?(:quota)
21 assert(s.age.is_a?(Integer) || s.age.is_a?(String)) if s.respond_to?(:age)
22 assert_instance_of(String, s.uclass) if s.respond_to?(:uclass)
23 assert_instance_of(String, s.comment) if s.respond_to?(:comment)
24 assert_kind_of(Integer, s.expire) if s.respond_to?(:expire)
27 assert_raise(RuntimeError) { Etc.passwd { Etc.passwd { } } }
32 Etc.passwd {|s| passwd[s.uid] = s unless passwd[s.uid] }
33 passwd.values.each do |s|
34 assert_equal(s, Etc.getpwuid(s.uid))
35 assert_equal(s, Etc.getpwuid) if Etc.getlogin == s.name
41 Etc.passwd {|s| passwd << s }
43 assert_equal(s, Etc.getpwnam(s.name))
51 Etc.setpwent if a.size == 3
53 assert_equal(a[0, 3], a[3, 3]) if a.size >= 6
58 Etc.passwd {|s| a << s }
73 Etc.endpwent if a.size == 3
75 assert_equal(a[0, 3], a[3, 3]) if a.size >= 6
80 assert_instance_of(String, s.name)
81 assert_instance_of(String, s.passwd) if s.respond_to?(:passwd)
82 assert_kind_of(Integer, s.gid)
85 assert_raise(RuntimeError) { Etc.group { Etc.group { } } }
94 assert_equal(s, Etc.getgrgid(s.gid))
95 assert_equal(s, Etc.getgrgid) if Etc.getlogin == s.name
105 assert_equal(s, Etc.getgrnam(s.name))
113 Etc.setgrent if a.size == 3
115 assert_equal(a[0, 3], a[3, 3]) if a.size >= 6
120 Etc.group {|s| a << s }
135 Etc.endgrent if a.size == 3
137 assert_equal(a[0, 3], a[3, 3]) if a.size >= 6