File: data_dpath_path_unescape.t

package info (click to toggle)
libdata-dpath-perl 0.60-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,328 kB
  • sloc: perl: 3,737; makefile: 2
file content (41 lines) | stat: -rw-r--r-- 838 bytes parent folder | download | duplicates (3)
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
#! /usr/bin/env perl

use strict;
use warnings FATAL => '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'});
}