zeroclickinfo-goodies/t/Pi.t

43 lines
923 B
Perl
Raw Normal View History

2014-12-16 12:20:29 -08:00
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Test::Deep;
2014-12-16 12:20:29 -08:00
use DDG::Test::Goodie;
2015-06-21 07:02:48 -07:00
use utf8;
2014-12-16 12:20:29 -08:00
zci answer_type => "pi";
zci is_cached => 1;
2016-05-22 13:56:46 -07:00
sub build_test {
my ($answer, $input) = @_;
return test_zci($answer, structured_answer => {
data => {
title => $answer,
subtitle=> "First $input digits of Pi"
},
templates => {
group => 'text'
}
})
2016-05-22 13:56:46 -07:00
}
2014-12-16 12:20:29 -08:00
ddg_goodie_test(
[qw( DDG::Goodie::Pi )],
2015-02-10 14:23:29 -08:00
'pi 23' => build_test("3.14159265358979323846264",23),
'π 8' => build_test("3.14159265", 8),
'12 digits of pi' => build_test("3.141592653589", 12),
2016-05-22 13:56:46 -07:00
'12 digits of π' => build_test("3.141592653589", 12),
'pi to 6 digits' => build_test("3.141592", 6),
'π to 6 digits' => build_test("3.141592", 6),
2015-02-11 06:39:52 -08:00
'pi ff' => undef,
'pi 3f2' => undef,
'pi 1001' => undef,
'pi 1002' => undef,
2014-12-16 12:20:29 -08:00
);
2016-05-16 06:18:04 -07:00
done_testing;