This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #22236] File::Basename behavior is misleading
[perl5.git] / lib / User / grent.t
CommitLineData
6888c95f
JH
1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
6}
7
27e62af5 8use Test::More;
7b717bbd 9
6888c95f
JH
10BEGIN {
11 our $hasgr;
12 eval { my @n = getgrgid 0 };
13 $hasgr = 1 unless $@ && $@ =~ /unimplemented/;
7b717bbd 14 unless ($hasgr) { plan skip_all => "no getgrgid"; }
6888c95f
JH
15 use Config;
16 $hasgr = 0 unless $Config{'i_grp'} eq 'define';
7b717bbd 17 unless ($hasgr) { plan skip_all => "no grp.h"; }
6888c95f
JH
18}
19
20BEGIN {
21 our @grent = getgrgid 0; # This is the function getgrgid.
7b717bbd 22 unless (@grent) { plan skip_all => "no gid 0"; }
6888c95f
JH
23}
24
18234ead
JH
25BEGIN {
26 plan tests => 5;
27 use_ok('User::grent');
28}
6888c95f 29
7b717bbd 30can_ok(__PACKAGE__, 'getgrgid');
6888c95f 31
7b717bbd 32my $grent = getgrgid 0;
6888c95f 33
7b717bbd 34is( $grent->name, $grent[0], 'name matches core getgrgid' );
6888c95f 35
7b717bbd 36is( $grent->passwd, $grent[1], ' passwd' );
6888c95f 37
7b717bbd 38is( $grent->gid, $grent[2], ' gid' );
6888c95f 39
6888c95f
JH
40
41# Testing pretty much anything else is unportable.
42