1 # Copyright (C) 2015 all contributors <meta@public-inbox.org>
2 # License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
8 use_ok 'PublicInbox::NNTP';
12 my (undef, $s) = split(/ = /, Dumper($_[0]), 2);
20 PublicInbox::NNTP::wildmat2re($_[0]);
21 my $new = quote_str($_[0]);
27 my ($orig, $new) = wm_prepare($wm);
28 like($str, $wm, "$orig matches '$str' using $new");
32 my ($str, $wm, $check_ex) = @_;
36 like($str, $re, "normal re with $wm matches, but ...");
38 my ($orig, $new) = wm_prepare($wm);
39 unlike($str, $wm, "$orig does not match '$str' using $new");
42 wildmat_like('[foo]', '[\[foo\]]');
43 wildmat_like('any', '*');
44 wildmat_unlike('bar.foo.bar', 'foo.*');
47 wildmat_unlike('HI', '(?{"HI"})', 1);
48 wildmat_unlike('HI', '[(?{"HI"})]', 1);
55 PublicInbox::NNTP::ngpat2re($pat);
56 like($str, $pat, "'$orig' matches '$str' using $pat");
59 ngpat_like('any', '*');
60 ngpat_like('a.s.r', 'a.t,a.s.r');
61 ngpat_like('a.s.r', 'a.t,a.s.*');
65 use POSIX qw(strftime);
67 my ($date, $time, $gmt) = @_;
68 my $m = join(' ', @_);
69 my $ts = PublicInbox::NNTP::parse_time(@_);
72 if (length($date) == 8) {
73 ($d, $t) = split(' ', strftime('%Y%m%d %H%M%S', @t));
75 ($d, $t) = split(' ', strftime('%g%m%d %H%M%S', @t));
77 is_deeply([$d, $t], [$date, $time], "roundtripped: $m");
80 my $x1 = time_roundtrip(qw(20141109 060606 GMT));
81 my $x2 = time_roundtrip(qw(141109 060606 GMT));
82 my $x3 = time_roundtrip(qw(930724 060606 GMT));
85 skip('YYMMDD test needs updating', 2) if (time > 0x7fffffff);
86 # our world probably ends in 2038, but if not we'll try to
87 # remember to update the test then
88 is($x1, $x2, 'YYYYMMDD and YYMMDD parse identically');
89 is(strftime('%Y', gmtime($x3)), '1993', '930724 was in 1993');