diff --git a/lib/Data/DPath/Path.pm b/lib/Data/DPath/Path.pm index 10abac6..ab25fa1 100644 --- a/lib/Data/DPath/Path.pm +++ b/lib/Data/DPath/Path.pm @@ -39,8 +39,8 @@ sub unescape { my ($str) = @_; return unless defined $str; - $str =~ s/(? 'all'; +use utf8; + +use Test::More tests => 6; + +use_ok('Data::DPath::Path'); + +my $FIXTURES = [ + { + name => 'double quote', + string => '\\"', + result => '"', + }, + { + name => 'backslash', + string => '\\\\', + result => '\\', + }, + { + name => 'backslash with double quote', + string => '\\\\\\"', + result => '\\"', + }, + { + name => 'two backslash with double quote', + string => '\\\\\\\\\\"', + result => '\\\\"', + }, + { + name => 'example from documentations', + string => '\"EE\E5\\\\\\"', + result => '"EE\E5\"', + }, +]; + +foreach my $test (@$FIXTURES) { + is(Data::DPath::Path::unescape($test->{'string'}), $test->{'result'}, $test->{'name'}); +} diff --git a/t/path.t b/t/path.t index d8e0127..8956d16 100644 --- a/t/path.t +++ b/t/path.t @@ -86,7 +86,7 @@ is_deeply(\@parts, [ '"EE E2"', '"EE E3"[1]', '"EE E4"', - '"EE\E5\\\\"', + '"EE\E5\\"', '"FFF"', 'GGG[foo == bar]', '*', @@ -181,7 +181,7 @@ is_deeply(\@parts, [ '"EE E2"', '"EE E3"[1]', '"EE E4"', - '"EE\E5\\\\"', + '"EE\E5\\"', '"FFF"', 'GGG[foo == bar]', '*',