File: backslash.t

package info (click to toggle)
libstring-escape-perl 2002.001-8
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 76 kB
  • ctags: 23
  • sloc: perl: 187; makefile: 45
file content (28 lines) | stat: -rwxr-xr-x 718 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/perl

use strict;
use Test;
BEGIN { plan tests => 3, todo => [] }

use String::Escape qw( printable unprintable );

my ( $original, $printable, $comparison );

# Backslash escapes for newline and tab characters

$original = "\tNow is the time\nfor all good folk\nto party.\n";
$printable = printable( $original );
$comparison = '\\tNow is the time\\nfor all good folk\\nto party.\\n';

ok( $printable eq $comparison);

$comparison = unprintable( $printable );
ok( $comparison eq $original );

# Should work for high-bit characters as well

$original = " this\nis a test. \\quote\\ endquote.";
$printable = printable( $original );
$comparison = unprintable( $printable );

ok( $comparison eq $original );