xref: /openbsd-src/gnu/usr.bin/perl/cpan/libnet/t/nntp.t (revision f2da64fbbbf1b03f09f390ab01267c93dfd77c4c)
1#!./perl -w
2
3BEGIN {
4    unless (-d 'blib') {
5	chdir 't' if -d 't';
6	@INC = '../lib';
7    }
8    if (!eval "require Socket") {
9	print "1..0 # no Socket\n"; exit 0;
10    }
11    if (ord('A') == 193 && !eval "require Convert::EBCDIC") {
12        print "1..0 # EBCDIC but no Convert::EBCDIC\n"; exit 0;
13    }
14}
15
16use Net::Config;
17use Net::NNTP;
18use Net::Cmd qw(CMD_REJECT);
19
20unless(@{$NetConfig{nntp_hosts}} && $NetConfig{test_hosts}) {
21    print "1..0\n";
22    exit;
23}
24
25print "1..4\n";
26
27my $i = 1;
28
29$nntp = Net::NNTP->new(Debug => 0)
30	or (print("not ok 1\n"), exit);
31
32print "ok 1\n";
33
34my $grp;
35foreach $grp (qw(test alt.test control news.announce.newusers)) {
36    @grp = $nntp->group($grp);
37    last if @grp;
38}
39
40if($nntp->status == CMD_REJECT) {
41    # Command was rejected, probably because we need authinfo
42    map { print "ok ",$_,"\n" } 2,3,4;
43    exit;
44}
45
46print "not " unless @grp;
47print "ok 2\n";
48
49
50if(@grp && $grp[2] > $grp[1]) {
51    $nntp->head($grp[1]) or print "not ";
52}
53print "ok 3\n";
54
55if(@grp) {
56    $nntp->quit or print "not ";
57}
58print "ok 4\n";
59
60