forked from duckduckgo/zeroclickinfo-goodies
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBase64.t
49 lines (40 loc) · 1.35 KB
/
Base64.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Test::Deep;
use DDG::Test::Goodie;
zci answer_type => 'base64_conversion';
zci is_cached => 1;
sub build_structured_answer {
my ($input, $operation, $output) = @_;
return "$operation d: $output",
structured_answer => {
data => {
title => $output,
subtitle => "$operation: $input"
},
templates => {
group => 'text'
}
};
}
sub build_test { test_zci(build_structured_answer(@_)) }
ddg_goodie_test(
[qw( DDG::Goodie::Base64)],
# It encodes
'base64 encode foo' => build_test('foo', 'Base64 encode', 'Zm9v'),
'base64 ENCoDE foo' => build_test('foo', 'Base64 encode', 'Zm9v'),
'base64 foo' => build_test('foo', 'Base64 encode', 'Zm9v'),
"base64 encode this text" => build_test('this text', 'Base64 encode', 'dGhpcyB0ZXh0'),
# It decodes
"base64 decode dGhpcyB0ZXh0" => build_test('dGhpcyB0ZXh0', 'Base64 decode', 'this text'),
"base64 dECoDE dGhpcyB0ZXh0" => build_test('dGhpcyB0ZXh0', 'Base64 decode', 'this text'),
# It ignores 'base64' at end of query
"python base64" => undef,
# It ignores incomplete requests to process
"base64" => undef,
"base64 encode" => undef,
"base64 decode" => undef,
);
done_testing;