zeroclickinfo-goodies/t/NoteFrequency.t

42 lines
1.1 KiB
Perl
Raw Normal View History

2015-11-06 09:13:37 -08:00
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Test::Deep;
2015-11-06 09:13:37 -08:00
use DDG::Test::Goodie;
zci answer_type => "note_frequency";
zci is_cached => 1;
sub build_structured_answer {
my ($input, $frequency) = @_;
return $frequency,
structured_answer => {
data => {
title => $frequency." Hz",
subtitle => "Note Frequency: " . $input,
},
templates => {
group => 'text',
},
},
}
sub build_test { test_zci(build_structured_answer(@_)) }
2015-11-06 09:13:37 -08:00
ddg_goodie_test(
[qw( DDG::Goodie::NoteFrequency )],
"notefreq a4" => build_test("A4 in A440 tuning", "440"),
"notefreq gb5" => build_test("Gb5 in A440 tuning", "739.99"),
"notefreq c3 432" => build_test("C3 in A432 tuning", "128.43"),
"notefreq c3 432Hz" => build_test("C3 in A432 tuning", "128.43"),
"notefreq c3 432 Hz" => undef,
"notefreq a4 100000" => undef,
"notefreq b#8" => undef,
"notefreq cb0" => undef,
"notefreq c9" => undef,
2015-11-06 09:13:37 -08:00
);
2016-05-16 06:18:04 -07:00
done_testing;