|
| 1 | +#!/usr/bin/env perl |
| 2 | + |
| 3 | +use strict; |
| 4 | +use warnings; |
| 5 | +use Test::More; |
| 6 | +use DDG::Test::Goodie; |
| 7 | +use utf8; |
| 8 | + |
| 9 | +zci answer_type => 'chinesezodiac'; |
| 10 | +zci is_cached => 1; |
| 11 | + |
| 12 | +ddg_goodie_test( |
| 13 | + [qw( |
| 14 | + DDG::Goodie::ChineseZodiac |
| 15 | + )], |
| 16 | + |
| 17 | + #Primary example |
| 18 | + 'chinese zodiac for 1969' => test_zci('Rooster', html => qr/Rooster/), |
| 19 | + |
| 20 | + #Secondary examples |
| 21 | + '2004 chinese zodiac animal' => test_zci('Monkey', html => qr/Monkey/), |
| 22 | + 'what was the chinese zodiac animal in 1992' => test_zci('Monkey', html => qr/Monkey/), |
| 23 | + 'what will the chinese zodiac animal be for 2056' => test_zci('Rat', html => qr/Rat/), |
| 24 | + 'last year\'s chinese zodiac' => test_zci(qr/./, html => qr/./), |
| 25 | + |
| 26 | + #Primary example with different query formats |
| 27 | + '1969 chinese zodiac animal' => test_zci('Rooster', html => qr/Rooster/), |
| 28 | + 'what was the chinese zodiac animal for 1969' => test_zci('Rooster', html => qr/Rooster/), |
| 29 | + 'what will the chinese zodiac animal be for people born in the year 1969' => test_zci('Rooster', html => qr/Rooster/), |
| 30 | + 'chinese zodiac for a person born in 1969' => test_zci('Rooster', html => qr/Rooster/), |
| 31 | + 'chinese zodiac of 1969' => test_zci('Rooster', html => qr/Rooster/), |
| 32 | + |
| 33 | + #Alternative triggers |
| 34 | + '1969 shēngxiào' => test_zci('Rooster', html => qr/Rooster/), |
| 35 | + 'shengxiao animal 1969' => test_zci('Rooster', html => qr/Rooster/), |
| 36 | + 'shēng xiào for 1969' => test_zci('Rooster', html => qr/Rooster/), |
| 37 | + 'i was born in 1969 what is my sheng xiao' => test_zci('Rooster', html => qr/Rooster/), |
| 38 | + |
| 39 | + #Test some different years |
| 40 | + # Taken from http://www.chinesezodiac.com/calculator.php |
| 41 | + 'chinese zodiac animal for 1924' => test_zci('Rat', html => qr/Rat/), |
| 42 | + 'chinese zodiac animal for 1929' => test_zci('Snake', html => qr/Snake/), |
| 43 | + 'chinese zodiac animal for 1934' => test_zci('Dog', html => qr/Dog/), |
| 44 | + 'chinese zodiac animal for 1939' => test_zci('Rabbit', html => qr/Rabbit/), |
| 45 | + 'chinese zodiac animal for 1944' => test_zci('Monkey', html => qr/Monkey/), |
| 46 | + 'chinese zodiac animal for 1949' => test_zci('Ox', html => qr/Ox/), |
| 47 | + 'chinese zodiac animal for 1954' => test_zci('Horse', html => qr/Horse/), |
| 48 | + 'chinese zodiac animal for 1959' => test_zci('Pig', html => qr/Pig/), |
| 49 | + 'chinese zodiac animal for 1964' => test_zci('Dragon', html => qr/Dragon/), |
| 50 | + 'chinese zodiac animal for 1969' => test_zci('Rooster', html => qr/Rooster/), |
| 51 | + 'chinese zodiac animal for 1974' => test_zci('Tiger', html => qr/Tiger/), |
| 52 | + 'chinese zodiac animal for 2027' => test_zci('Goat', html => qr/Goat/), |
| 53 | + 'chinese zodiac animal for 2040' => test_zci('Monkey', html => qr/Monkey/), |
| 54 | + |
| 55 | + #Test for correct date ranges |
| 56 | + # Taken from http://www.chinesezodiac.com/calculator.php |
| 57 | + 'chinese zodiac animal for 1925' => test_zci('Ox', html => qr/Jan\s24,\s1925.Feb\s12,\s1926/), |
| 58 | + 'chinese zodiac animal for 1937' => test_zci('Ox', html => qr/Feb\s11,\s1937.Jan\s30,\s1938/), |
| 59 | + 'chinese zodiac animal for 1953' => test_zci('Snake', html => qr/Feb\s14,\s1953.Feb\s2,\s1954/), |
| 60 | + 'chinese zodiac animal for 1973' => test_zci('Ox', html => qr/Feb\s3,\s1973.Jan\s22,\s1974/), |
| 61 | + 'chinese zodiac animal for 1997' => test_zci('Ox', html => qr/Feb\s7,\s1997.Jan\s27,\s1998/), |
| 62 | + 'chinese zodiac animal for 2013' => test_zci('Snake', html => qr/Feb\s10,\s2013.Jan\s30,\s2014/), |
| 63 | + 'chinese zodiac animal for 2017' => test_zci('Rooster', html => qr/Jan\s28,\s2017.Feb\s15,\s2018/), |
| 64 | + 'chinese zodiac animal for 2041' => test_zci('Rooster', html => qr/Feb\s1,\s2041.Jan\s21,\s2042/), |
| 65 | + |
| 66 | + #Should not trigger |
| 67 | + 'wikipedia chinese zodiac' => undef, |
| 68 | + 'what is my zodiac sign' => undef, |
| 69 | + 'what is the chinese word for duck' => undef, |
| 70 | + 'buy an inflatable zodiac chinese online store' => undef, |
| 71 | + 'chinese zodiac 20 march 1997' => undef, |
| 72 | + 'chinese zodiac 1997-03-20' => undef, |
| 73 | + 'what was the chinese zodiac animal on the 3rd of april 1945' => undef, |
| 74 | + |
| 75 | + #No support currently for years outside 1900--2069 |
| 76 | + 'chinese zodiac 1899' => undef, |
| 77 | + 'chinese zodiac 1900' => test_zci('Rat', html => qr/Rat/), |
| 78 | + 'chinese zodiac 2069' => test_zci('Ox', html => qr/Ox/), |
| 79 | + 'chinese zodiac 2070' => undef, |
| 80 | + 'chinese zodiac 2000000000000' => undef, |
| 81 | + |
| 82 | +); |
| 83 | + |
| 84 | +done_testing; |
| 85 | + |
0 commit comments