From f4119f7fbfcc55fdb8553c6fcbe1efaffb4e4752 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Mon, 16 May 2016 13:18:14 +0100 Subject: [PATCH] LeetSpeak: Updating tests for text template --- t/LeetSpeak.t | 59 +++++++++++++++++---------------------------------- 1 file changed, 19 insertions(+), 40 deletions(-) diff --git a/t/LeetSpeak.t b/t/LeetSpeak.t index 322e140e1..94b379d86 100644 --- a/t/LeetSpeak.t +++ b/t/LeetSpeak.t @@ -11,48 +11,27 @@ use utf8; zci answer_type => 'leet_speak'; zci is_cached => 1; +sub build_test +{ + my ($text, $title, $input) = @_; + return test_zci($text, structured_answer => { + data => { + title => $title, + subtitle => "Leet speak: $input", + }, + templates => { + group => 'text' + } + }); +} + ddg_goodie_test( ['DDG::Goodie::LeetSpeak'], - 'leetspeak hello world !' => test_zci( - 'Leet Speak: |-|3|_|_0 \^/0|2|_|) !', - structured_answer => { - input => ['hello world !'], - operation => 'Leet speak', - result => '|-|3|_|_0 \^/0|2|_|) !' - } - ), - 'l33tsp34k hElLo WORlD !' => test_zci( - 'Leet Speak: |-|3|_|_0 \^/0|2|_|) !', - structured_answer => { - input => ['hElLo WORlD !'], - operation => 'Leet speak', - result => '|-|3|_|_0 \^/0|2|_|) !' - } - ), - 'what is l33t' => test_zci( - q~Leet Speak: \^/|-|/-\'][' 15~, - structured_answer => { - input => ['what is'], - operation => 'Leet speak', - result => q~\^/|-|/-\'][' 15~, - } - ), - 'leet speak leetspeak' => test_zci( - q~Leet Speak: |_33']['5|D3/-\|<~, - structured_answer => { - input => ['leetspeak'], - operation => 'Leet speak', - result => q~|_33']['5|D3/-\|<~, - } - ), - 'l33t sp34k /!§ ;€' => test_zci( - q~Leet Speak: /!§ ;€~, - structured_answer => { - input => ['/!§ ;€'], - operation => 'Leet speak', - result => q~/!§ ;€~, - } - ), + 'leetspeak hello world !' => build_test('Leet Speak: |-|3|_|_0 \^/0|2|_|) !', '|-|3|_|_0 \^/0|2|_|) !', 'hello world !'), + 'l33tsp34k hElLo WORlD !' => build_test('Leet Speak: |-|3|_|_0 \^/0|2|_|) !', '|-|3|_|_0 \^/0|2|_|) !', 'hElLo WORlD !'), + 'what is l33t' => build_test(q~Leet Speak: \^/|-|/-\'][' 15~, q~\^/|-|/-\'][' 15~, 'what is'), + 'leet speak leetspeak' => build_test(q~Leet Speak: |_33']['5|D3/-\|<~, q~|_33']['5|D3/-\|<~, 'leetspeak'), + 'l33t sp34k /!§ ;€' => build_test(q~Leet Speak: /!§ ;€~, q~/!§ ;€~, '/!§ ;€'), 'l33tsp34k' => undef, );