Subject: | Tests for "replace_unicode" |
Many thanks for your speedy response to the previous report.
I've been investigating the module a little today and realised that
there are currently no tests for the "replace_unicode" option.
I'm sure that you can improve on my attached offering but I was hoping
that it would be a reasonable starting point.
As per my comments in the test-file, I pasted in some smart-quoted text
from the Microsoft website to use as my test data.
Subject: | 3demoronize.unicode.t |
use Test::More tests => 4;
use strict;
use warnings;
use utf8;
use Test::MockObject::Extends;
use Test::MockObject;
use_ok('Catalyst::Plugin::Params::Demoronize');
my $c = new Test::MockObject::Extends 'Catalyst::Plugin::Params::Demoronize';
my $req = new Test::MockObject;
my $params = {};
$c->set_always(req => $req);
$c->set_always(config => { demoronize => {replace_unicode => 1} });
$req->set_always(params => $params);
# pasted smart quotes from:
# http://office.microsoft.com/en-gb/word/HA101732421033.aspx
$params->{string} = q{pasted âsmart quotesâ string};
$c->prepare_parameters;
is_deeply($params, { string => q{pasted "smart quotes" string} }, 'pasted smart quotes');
# unicode smart quotes from:
# http://office.microsoft.com/en-gb/word/HA101732421033.aspx
$params->{string} = qq<unicoded \x{201c}smart quotes\x{201d} string>;
$c->prepare_parameters;
is_deeply($params, { string => q{unicoded "smart quotes" string} }, 'unicoded smart quotes');
# pasted phrase from
# http://office.microsoft.com/en-gb/word/HA101732421033.aspx
$params->{string} = qq<Click the AutoFormat As You Type tab, and under Replace as you type, select or clear the "Straight quotes" with âsmart quotesâ check box.>;
$c->prepare_parameters;
is_deeply($params, { string => q{Click the AutoFormat As You Type tab, and under Replace as you type, select or clear the "Straight quotes" with "smart quotes" check box.} }, 'pasted phrase from Microsoft site');
__DATA__
You see, Âstate of the art Microsoft Office applications sport a nifty
feature called Âsmart quotesÂ. (Rule of thumb  every time Microsoft
use the word ÂsmartÂ, be on the lookout for something dumb). This feature
is on by default in both Word and PowerPoint and can be disabled only by finding
the little box buried among the dozens of bewildering option panels these
products contain. If enabled, and you type the string ÂÂHalt, he
cried, Âthis is the police!ÂÂ, Âsmart quotes transforms the
ASCII quote characters automatically into the incompatible Microsoft opening and
closing quotes.