File: 70-listandhash.t

package info (click to toggle)
libstring-escape-perl 2010.002-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 164 kB
  • sloc: perl: 362; makefile: 2
file content (23 lines) | stat: -rw-r--r-- 626 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
#!/usr/bin/perl

use strict;
use Test;
BEGIN { plan tests => 5 }

use String::Escape qw( list2string string2list hash2string string2hash );

###

ok( list2string('hello', 'I move next march') eq 'hello "I move next march"' );

ok( ( string2list('one "second item" 3 "four\nlines\nof\ntext"') )[1] eq 'second item' );

###

ok( hash2string( 'foo' => 'Animal Cities', 'bar' => 'Cheap' ) eq 'foo="Animal Cities" bar=Cheap' );

my %hash = string2hash('key=value "undefined key" words="the cat in the hat"');

ok( $hash{'words'} eq 'the cat in the hat' );

ok( exists $hash{'undefined key'} and ! defined $hash{'undefined key'} );