zeroclickinfo-goodies/t/FrequencySpectrum.t

107 lines
2.5 KiB
Perl
Raw Normal View History

#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use DDG::Test::Goodie;
zci answer_type => 'frequency_spectrum';
ddg_goodie_test(
['DDG::Goodie::FrequencySpectrum'],
2014-07-05 01:05:03 -07:00
#Primary example
'50 hz' => test_zci(
2014-07-05 01:05:03 -07:00
qr/radio.+SLF.+audible.+double-bass.+piano.+tuba/,
html => qr/radio/
),
2014-07-05 01:05:03 -07:00
#Secondary example
'400 thz' => test_zci(
2014-07-05 01:05:03 -07:00
qr/visible.+red/,
html => qr/visible.+red/
),
2014-07-05 01:05:03 -07:00
#Misc
2014-01-23 11:35:32 -08:00
'1,000 hz' => test_zci(
2014-07-05 01:05:03 -07:00
qr/radio.+audible.+human.+voice.+viola.+violin.+guitar.+mandolin.+banjo.+piano.+saxophone.+flute.+clarinet.+oboe/,
html => qr/radio.+/
2014-01-23 11:35:32 -08:00
),
'1000000.99 hz' => test_zci(
2014-07-05 01:05:03 -07:00
qr/radio.+MF/,
html => qr/radio.+MF/
2014-01-23 11:35:32 -08:00
),
#No whitespace between number and unit
'50hz' => test_zci(
qr/radio.+SLF.+audible.+double-bass.+piano.+tuba/,
html => qr/radio/
),
'400terahertz' => test_zci(
qr/visible.+red/,
html => qr/visible.+red/
),
2014-07-21 18:08:45 -07:00
#Mixed case
'400 THz' => test_zci(
qr/visible.+red/,
html => qr/visible.+red/
),
'1000 HZ' => test_zci(
qr/radio.+audible.+human.+voice.+viola.+violin.+guitar.+mandolin.+banjo.+piano.+saxophone.+flute.+clarinet.+oboe/,
html => qr/radio.+/
),
#Commas in number
'1,000,000.99 hz' => test_zci(
qr/radio.+MF/,
html => qr/radio.+MF/
),
#Can you test with all the colours of the wind?
'650 nm' => test_zci(
qr/visible.+red/,
html => qr/visible.+red/
),
'610 nanometers' => test_zci(
qr/visible.+orange/,
html => qr/visible.+orange/
),
'580 nanometres' => test_zci(
qr/visible.+yellow/,
html => qr/visible.+yellow/
),
'536 nanometer' => test_zci(
qr/visible.+green/,
html => qr/visible.+green/
),
'478.1 nm' => test_zci(
qr/visible.+blue/,
html => qr/visible.+blue/
),
'380.000000000 nanometres' => test_zci(
qr/visible.+violet/,
html => qr/visible.+violet/
),
#Only visible light wavelengths should trigger
'0.1 nm' => undef,
'100 nm' => undef,
'800 nm' => undef,
'100000 nm' => undef,
#Malformed frequencies/wavelengths should not trigger
2014-01-23 11:35:32 -08:00
'1000.000..99 hz' => undef,
2014-07-05 01:05:03 -07:00
'4 thz' => undef,
2014-07-18 00:06:17 -07:00
'15 kilo hertz' => undef,
'100,123 jiggahz' => undef,
'hertz' => undef,
'terahz' => undef,
'10000 nm' => undef,
'600 nmeters' => undef,
);
2014-01-22 10:12:02 -08:00
done_testing;