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