2016-06-25 07:52:39 -07:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
|
|
|
use utf8;
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use Test::More;
|
|
|
|
use Test::Deep;
|
|
|
|
use DDG::Test::Goodie;
|
|
|
|
|
|
|
|
zci answer_type => "chinese_to_pinyin";
|
|
|
|
zci is_cached => 1;
|
|
|
|
|
|
|
|
ddg_goodie_test(
|
|
|
|
[qw( DDG::Goodie::ChineseToPinyin )],
|
|
|
|
# At a minimum, be sure to include tests for all:
|
|
|
|
# - primary_example_queries
|
|
|
|
# - secondary_example_queries
|
|
|
|
'pinyin 你好' => test_zci(
|
|
|
|
"Pinyin of 你好 is \"nǐ hǎo\"",
|
|
|
|
structured_answer => {
|
|
|
|
data => {
|
|
|
|
title => "nǐ hǎo",
|
|
|
|
subtitle => "Pinyin of 你好",
|
|
|
|
},
|
|
|
|
templates => {
|
|
|
|
group => "text",
|
2016-07-04 22:29:09 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
|
|
|
'pinyin 女生' => test_zci(
|
|
|
|
"Pinyin of 女生 is \"nǚ shēng\"",
|
|
|
|
structured_answer => {
|
|
|
|
data => {
|
|
|
|
title => "nǚ shēng",
|
|
|
|
subtitle => "Pinyin of 女生",
|
|
|
|
},
|
|
|
|
templates => {
|
|
|
|
group => "text",
|
2016-06-25 07:52:39 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
2016-07-04 22:07:38 -07:00
|
|
|
'pinyin lai2 zi4 zhong1 guo2' => test_zci(
|
|
|
|
"Pinyin of lai2 zi4 zhong1 guo2 is \"lái zì zhōng guó\"",
|
2016-06-25 07:52:39 -07:00
|
|
|
structured_answer => {
|
|
|
|
data => {
|
|
|
|
title => "lái zì zhōng guó",
|
2016-07-04 22:07:38 -07:00
|
|
|
subtitle => "Pinyin of lai2 zi4 zhong1 guo2",
|
2016-06-25 07:52:39 -07:00
|
|
|
},
|
|
|
|
templates => {
|
|
|
|
group => "text",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
2016-07-04 22:07:38 -07:00
|
|
|
'PINYIN PENG2 YOU3' => test_zci(
|
|
|
|
"Pinyin of peng2 you3 is \"péng yǒu\"",
|
2016-07-04 21:27:02 -07:00
|
|
|
structured_answer => {
|
|
|
|
data => {
|
|
|
|
title => "péng yǒu",
|
2016-07-04 22:07:38 -07:00
|
|
|
subtitle => "Pinyin of peng2 you3",
|
2016-07-04 21:27:02 -07:00
|
|
|
},
|
|
|
|
templates => {
|
|
|
|
group => "text",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
),
|
2016-06-25 07:52:39 -07:00
|
|
|
# Try to include some examples of queries on which it might
|
|
|
|
# appear that your answer will trigger, but does not.
|
|
|
|
'pinyin ' => undef,
|
2016-07-04 22:20:30 -07:00
|
|
|
'pinyin yes3' => undef,
|
2016-07-04 22:14:11 -07:00
|
|
|
'pinyin how are you?' => undef,
|
2016-07-04 03:43:39 -07:00
|
|
|
'pinyin zhōng guó' => undef,
|
2016-06-25 07:52:39 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
done_testing;
|