PageRenderTime 38ms CodeModel.GetById 15ms app.highlight 18ms RepoModel.GetById 1ms app.codeStats 0ms

/XML-TreePP/t/45_attr_space.t

http://xml-treepp.googlecode.com/
Unknown | 32 lines | 31 code | 1 blank | 0 comment | 0 complexity | 6021d591e46f2ff4a934f60adb64a0bd MD5 | raw file
 1# ----------------------------------------------------------------
 2    use strict;
 3    use Test::More tests => 49;
 4    BEGIN { use_ok('XML::TreePP') };
 5# ----------------------------------------------------------------
 6    my $tpp = XML::TreePP->new();
 7    my $list = [
 8        '<root aaa="AAA" bbb ="BBB" zzz ccc= "CCC" ddd = "DDD" >XXX</root>',
 9        "<root aaa='AAA' bbb ='BBB' zzz ccc= 'CCC' ddd = 'DDD' >XXX</root>",
10        '<root aaa="AAA" bbb ="BBB" zzz ccc= "CCC" ddd = "DDD">XXX</root>',
11        "<root aaa='AAA' bbb ='BBB' zzz ccc= 'CCC' ddd = 'DDD'>XXX</root>",
12        '<root aaa="AAA" bbb ="BBB" zzz ccc= "CCC" ddd = "DDD" ></root>',
13        "<root aaa='AAA' bbb ='BBB' zzz ccc= 'CCC' ddd = 'DDD' ></root>",
14        '<root aaa="AAA" bbb ="BBB" zzz ccc= "CCC" ddd = "DDD"></root>',
15        "<root aaa='AAA' bbb ='BBB' zzz ccc= 'CCC' ddd = 'DDD'></root>",
16        '<root aaa="AAA" bbb ="BBB" zzz ccc= "CCC" ddd = "DDD" />',
17        "<root aaa='AAA' bbb ='BBB' zzz ccc= 'CCC' ddd = 'DDD' />",
18        '<root aaa="AAA" bbb ="BBB" zzz ccc= "CCC" ddd = "DDD"/>',
19        "<root aaa='AAA' bbb ='BBB' zzz ccc= 'CCC' ddd = 'DDD'/>",
20    ];
21
22    foreach my $source ( @$list ) {
23        my $tree = $tpp->parse( $source );
24        my $sep = ( $source =~ /(['"])/ )[0];
25        is( $tree->{root}->{"-aaa"}, "AAA", "key=".$sep."val".$sep." (no space)" );
26        is( $tree->{root}->{"-bbb"}, "BBB", "key =".$sep."val".$sep." (left space)" );
27        is( $tree->{root}->{"-ccc"}, "CCC", "key= ".$sep."val".$sep." (right space)" );
28        is( $tree->{root}->{"-ddd"}, "DDD", "key = ".$sep."val".$sep." (both space)" );
29    }
30# ----------------------------------------------------------------
31;1;
32# ----------------------------------------------------------------