zeroclickinfo-goodies/t/DaysBetween.t

153 lines
5.0 KiB
Perl
Executable File

#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use DDG::Test::Goodie;
use Test::MockTime qw( :all );
zci answer_type => 'days_between';
zci is_cached => 1;
ddg_goodie_test(
[qw( DDG::Goodie::DaysBetween)],
'days between 01/01/2000 01/01/2001' => test_zci(
'There are 366 days between 01 Jan 2000 and 01 Jan 2001.',
structured_answer => {
input => ['01 Jan 2000', '01 Jan 2001'],
operation => 'Days between',
result => 366
},
),
'days between 1/1/2000 and 1/1/2001 inclusive' => test_zci(
'There are 367 days between 01 Jan 2000 and 01 Jan 2001, inclusive.',
structured_answer => {
input => ['01 Jan 2000', '01 Jan 2001'],
operation => 'Days between, inclusive',
result => 367
},
),
'daysbetween 03/4/2005 and 11/8/2020' => test_zci(
'There are 5728 days between 04 Mar 2005 and 08 Nov 2020.',
structured_answer => {
input => ['04 Mar 2005', '08 Nov 2020'],
operation => 'Days between',
result => 5728
},
),
'days_between 3/14/2005 and 1/2/2003' => test_zci(
'There are 802 days between 02 Jan 2003 and 14 Mar 2005.',
structured_answer => {
input => ['02 Jan 2003', '14 Mar 2005'],
operation => 'Days between',
result => 802
},
),
'days between 01/31/2000 01/31/2001' => test_zci(
'There are 366 days between 31 Jan 2000 and 31 Jan 2001.',
structured_answer => {
input => ['31 Jan 2000', '31 Jan 2001'],
operation => 'Days between',
result => 366
},
),
'days between 01/31/2000 01/31/2001 inclusive' => test_zci(
'There are 367 days between 31 Jan 2000 and 31 Jan 2001, inclusive.',
structured_answer => {
input => ['31 Jan 2000', '31 Jan 2001'],
operation => 'Days between, inclusive',
result => 367
},
),
'days between January 31st, 2000 and 31-Jan-2001 inclusive' => test_zci(
'There are 367 days between 31 Jan 2000 and 31 Jan 2001, inclusive.',
structured_answer => {
input => ['31 Jan 2000', '31 Jan 2001'],
operation => 'Days between, inclusive',
result => 367
},
),
'days between jan 1 2012 and jan 1 1234' => test_zci(
"There are 284158 days between 01 Jan 1234 and 01 Jan 2012.",
structured_answer => {
input => ['01 Jan 1234', '01 Jan 2012'],
operation => 'Days between',
result => 284158
},
),
'days between jan 1 and jan 15 inclusive' => test_zci(
qr/^There are 15 days between.+inclusive\.$/,
structured_answer => {
input => '-ANY-',
operation => 'Days between, inclusive',
result => 15
},
),
'days between jan 1 and 15th feb' => test_zci(
qr/^There are 45 days between.+and 15 Feb [0-9]{4}\.$/,
structured_answer => {
input => '-ANY-',
operation => 'Days between',
result => 45
},
),
'number of days between jan 1 and 15th feb' => test_zci(
qr/^There are 45 days between.+and 15 Feb [0-9]{4}\.$/,
structured_answer => {
input => '-ANY-',
operation => 'Days between',
result => 45
},
),
'number of days from jan 1 and 15th feb' => test_zci(
qr/^There are 45 days between.+and 15 Feb [0-9]{4}\.$/,
structured_answer => {
input => '-ANY-',
operation => 'Days between',
result => 45
},
),
'days from jan 1 and 15th feb' => test_zci(
qr/^There are 45 days between.+and 15 Feb [0-9]{4}\.$/,
structured_answer => {
input => '-ANY-',
operation => 'Days between',
result => 45
},
),
'days between today and tomorrow' => test_zci(
qr/^There are 1 days between.+ and.+\.$/,
structured_answer => {
input => '-ANY-',
operation => 'Days between',
result => 1
},
),
'how many days between feb 2 and feb 17' => test_zci(
qr/^There are 15 days between.+ and.+\.$/,
structured_answer => {
input => '-ANY-',
operation => 'Days between',
result => 15
},
),
'days between jan 1 2012 and jan 1 123456' => undef,
);
set_fixed_time('2015-07-14T22:36:00');
ddg_goodie_test(
[qw( DDG::Goodie::DaysBetween)],
'days between 22nd may and today' => test_zci(
'There are 53 days between 22 May 2015 and 14 Jul 2015.',
structured_answer => {
input => ['22 May 2015', '14 Jul 2015'],
operation => 'Days between',
result => 53
},
),
);
restore_time();
done_testing;