File: has_xml_attribute.t

package info (click to toggle)
libhtml-formfu-perl 0.09007-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,184 kB
  • sloc: perl: 13,186; makefile: 9; sql: 5
file content (69 lines) | stat: -rw-r--r-- 1,513 bytes parent folder | download | duplicates (6)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use strict;
use warnings;

use Test::More tests => 17;

use HTML::FormFu::Util qw(
    literal
    has_xml_attribute
    xml_escape
);

{

    # has literal in literal
    my %attr = ( key => literal("<foo <bar <baz") );

    ok( has_xml_attribute( \%attr, "key", literal "<foo" ) );

    ok( has_xml_attribute( \%attr, "key", literal "<bar" ) );

    ok( has_xml_attribute( \%attr, "key", literal "<baz" ) );

    ok( !has_xml_attribute( \%attr, "key", literal "blank" ) );
}

{

    # has string in literal
    my %attr = ( key => literal("&lt;foo &lt;bar &lt;baz") );

    ok( has_xml_attribute( \%attr, "key", "<foo" ) );

    ok( has_xml_attribute( \%attr, "key", "<bar" ) );

    ok( has_xml_attribute( \%attr, "key", "<baz" ) );

    ok( !has_xml_attribute( \%attr, "key", "blank" ) );
}

{

    # has string in string
    my %attr = ( key => "<foo <bar <baz" );

    ok( has_xml_attribute( \%attr, "key", "<foo" ) );

    ok( has_xml_attribute( \%attr, "key", "<bar" ) );

    ok( has_xml_attribute( \%attr, "key", "<baz" ) );

    ok( !has_xml_attribute( \%attr, "key", "blank" ) );
}

{

    # has literal in string
    my %attr = ( key => "<foo <bar <baz" );

    ok( has_xml_attribute( \%attr, "key", literal "&lt;foo" ) );

    ok( has_xml_attribute( \%attr, "key", literal "&lt;bar" ) );

    ok( has_xml_attribute( \%attr, "key", literal "&lt;baz" ) );

    ok( !has_xml_attribute( \%attr, "key", literal "blank" ) );

    # ... has a string
    ok( has_xml_attribute( \%attr, "key", '<bar' ) );
}