#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Test::Deep;
use DDG::Test::Goodie;
zci answer_type => 'root';
zci is_cached => 1;
sub build_structured_answer {
my ($exp, $base, $text, $html) = @_;
return $text,
structured_answer => {
data => {
title => $html,
subtitle => "Calculate $exp-root of $base",
},
templates => {
group => 'text',
options => {
title_content => 'DDH.calc_roots.title',
},
},
};
}
sub build_test { test_zci(build_structured_answer(@_)) }
ddg_goodie_test(
[qw( DDG::Goodie::CalcRoots )],
'square root of negative 9' => build_test('2', '-9', 'The 2-root of -9 is 3 i', '2√-9 = 3i'),
'negative square root of negative 25' => build_test('-2', '-25', 'The -2-root of -25 is -5 i', '-2√-25 = -5i'),
'2nd root of 100' => build_test('2', '100', 'The 2-root of 100 is 10.',
qq|2√100 = 10|),
'cube root of 33' => build_test('3', '33', 'The 3-root of 33 is 3.20753432999583.',
qq|3√33 = 3.20753432999583|),
'2nd root of 9999999999' => undef
);
done_testing;