File: CommaSeparated.t

package info (click to toggle)
dh-make-perl 0.70-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 984 kB
  • ctags: 203
  • sloc: perl: 4,318; makefile: 88
file content (44 lines) | stat: -rw-r--r-- 901 bytes parent folder | download | duplicates (10)
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
42
43
44
#!/usr/bin/perl -w

use strict;
use warnings;

use Test::More tests => 7;
use Test::Exception;
use Test::Differences;

use Debian::Control::Stanza::CommaSeparated;

my $s = Debian::Control::Stanza::CommaSeparated->new('foo bar, "one, two", three');

is_deeply(
    [@$s],
    [ 'foo bar', '"one, two"', 'three' ],
    'constructor parses ok'
);

$s->add("three");

is( scalar(@$s), 3, 'ignores duplicates' );

$s->add('"smith, agent" <asmith@hasyou.yes>, five');

is( scalar(@$s), 5, 'add splits correctly' );

is( $s->[3], '"smith, agent" <asmith@hasyou.yes>', 'add honours quotes' );
is( $s->[4], 'five', 'fifth is five' );

$s->sort;

is_deeply(
    [@$s],
    [   '"one, two"', '"smith, agent" <asmith@hasyou.yes>',
        'five', 'foo bar', 'three',
    ],
    'sort works'
);

is( "$s",
    '"one, two", "smith, agent" <asmith@hasyou.yes>, five, foo bar, three',
    "stringification works"
);