HTMLEntitiesDecode: Adding build_test to wrap the test_zci calls
parent
26ffa0d976
commit
07ecf6867a
|
@ -26,36 +26,41 @@ sub build_structured_answer {
|
|||
};
|
||||
}
|
||||
|
||||
sub build_test {
|
||||
my($text, $title, $subtitle) = @_;
|
||||
return test_zci($text, structured_answer => build_structured_answer($title, $subtitle));
|
||||
}
|
||||
|
||||
ddg_goodie_test(
|
||||
[qw(DDG::Goodie::HTMLEntitiesDecode)],
|
||||
|
||||
# Simple decimal test
|
||||
'html decode !' => test_zci("Decoded HTML Entity: !", structured_answer => build_structured_answer("!", "HTML Entity Decode: !")),
|
||||
'html decode !' => build_test("Decoded HTML Entity: !", "!", "HTML Entity Decode: !"),
|
||||
# Simple text test
|
||||
'html entity &' => test_zci("Decoded HTML Entity: &", structured_answer => build_structured_answer("&","HTML Entity Decode: &")),
|
||||
'html entity &' => build_test("Decoded HTML Entity: &", "&","HTML Entity Decode: &"),
|
||||
# Another simple text test
|
||||
'decode html for >' => test_zci("Decoded HTML Entity: >", structured_answer => build_structured_answer(">","HTML Entity Decode: >")),
|
||||
'decode html for >' => build_test("Decoded HTML Entity: >", ">","HTML Entity Decode: >"),
|
||||
# Simple hex test
|
||||
'! htmlentity' => test_zci("Decoded HTML Entity: !", structured_answer => build_structured_answer("!","HTML Entity Decode: &#x21")),
|
||||
'! htmlentity' => build_test("Decoded HTML Entity: !", "!","HTML Entity Decode: &#x21"),
|
||||
|
||||
# No "&" and ";" in decimal input
|
||||
'#36 html decode' => test_zci('Decoded HTML Entity: $', structured_answer => build_structured_answer('$',"HTML Entity Decode: #36")),
|
||||
'#36 html decode' => build_test('Decoded HTML Entity: $', '$',"HTML Entity Decode: #36"),
|
||||
# Variety in hex queries
|
||||
'" decodehtml' => test_zci('Decoded HTML Entity: "', structured_answer => build_structured_answer('"',"HTML Entity Decode: &#X22")),
|
||||
'" decodehtml' => build_test('Decoded HTML Entity: "', '"',"HTML Entity Decode: &#X22"),
|
||||
# More variety in hex queries
|
||||
'htmlentity for #x3c' => test_zci("Decoded HTML Entity: <", structured_answer => build_structured_answer("<","HTML Entity Decode: #x3c")),
|
||||
'htmlentity for #x3c' => build_test("Decoded HTML Entity: <", "<","HTML Entity Decode: #x3c"),
|
||||
|
||||
# "¢" succeeds
|
||||
'html decode ¢' => test_zci(qr/.*/, structured_answer => build_structured_answer("¢","HTML Entity Decode: &cent;")),
|
||||
'html decode ¢' => build_test(qr/.*/, "¢","HTML Entity Decode: &cent;"),
|
||||
# "¢" also succeeds (missing back ";" is OK)
|
||||
'html decode ¢' => test_zci(qr/.*/, structured_answer => build_structured_answer("¢","HTML Entity Decode: &cent")),
|
||||
'html decode ¢' => build_test(qr/.*/, "¢","HTML Entity Decode: &cent"),
|
||||
# "cent" fails during the regex match because of the missing front "&" (stricter for text to eliminate false positive encoding hits)
|
||||
'html decode cent' => undef,
|
||||
# "cent;" fails during the regex match for the same reasons as above
|
||||
'html decode cent;' => undef,
|
||||
|
||||
# "" has no visual representation
|
||||
'html entity of ' => test_zci("Decoded HTML Entity: Unicode control character (no visual representation)", structured_answer => build_structured_answer("Unicode control character (no visual representation)","HTML Entity Decode: &#20;")),
|
||||
'html entity of ' => build_test("Decoded HTML Entity: Unicode control character (no visual representation)", "Unicode control character (no visual representation)","HTML Entity Decode: &#20;"),
|
||||
|
||||
# Querying for "&bunnyrabbit;" should fail
|
||||
'html decode &bunnyrabbit;' => undef,
|
||||
|
@ -65,12 +70,12 @@ ddg_goodie_test(
|
|||
'html decode apostrophe' => undef,
|
||||
|
||||
# natural querying
|
||||
'What is the decoded html entity for π?' => test_zci("Decoded HTML Entity: π", structured_answer => build_structured_answer("π","HTML Entity Decode: &#960;")),
|
||||
'What is the decoded html entity for π?' => build_test("Decoded HTML Entity: π", "π","HTML Entity Decode: &#960;"),
|
||||
|
||||
# natural querying
|
||||
'what is decoded html entity for #960 ?' => test_zci("Decoded HTML Entity: π", structured_answer => build_structured_answer("π","HTML Entity Decode: #960")),
|
||||
'what is decoded html entity for #960 ?' => build_test("Decoded HTML Entity: π", "π","HTML Entity Decode: #960"),
|
||||
# no "html" in query
|
||||
'the decoded entity for ō is?' => test_zci("Decoded HTML Entity: ō", structured_answer => build_structured_answer("ō","HTML Entity Decode: &#333;")),
|
||||
'the decoded entity for ō is?' => build_test("Decoded HTML Entity: ō", "ō","HTML Entity Decode: &#333;"),
|
||||
);
|
||||
|
||||
done_testing;
|
||||
|
|
Loading…
Reference in New Issue