|
| 1 | +use strict; |
| 2 | + |
| 3 | +use Test::More qw/ tests 1 /; |
| 4 | + |
| 5 | +use XML::Generator; |
| 6 | + |
| 7 | +my $XML = XML::Generator->new(conformance => "strict"); |
| 8 | + |
| 9 | +my $result = $XML->record(join "\n", map { my ($k, $v) = @{$_}; $XML->$k($v); } |
| 10 | + ( |
| 11 | + [threat => 1], |
| 12 | + [desc => "godzilla"], |
| 13 | + [value => "http://y.ahoooooooooo.it/0weifjwef"], |
| 14 | + [detected => "2012-10-16 00:00:00"] |
| 15 | + )); |
| 16 | + |
| 17 | +my $expected_result = '<record><threat>1</threat> |
| 18 | +<desc>godzilla</desc> |
| 19 | +<value>http://y.ahoooooooooo.it/0weifjwef</value> |
| 20 | +<detected>2012-10-16 00:00:00</detected></record>'; |
| 21 | + |
| 22 | +ok($result eq $expected_result, 'Got expected results'); |
| 23 | +exit; |
| 24 | +$XML = XML::Generator->new(); |
| 25 | + |
| 26 | +$result = $XML->record( |
| 27 | + join "\n", map { my ($k, $v) = @{$_}; $XML->$k($v); } |
| 28 | + ( |
| 29 | + [threat => 1], |
| 30 | + [desc => "gozdilla"], |
| 31 | + [value => "http://y.ahoooooooooo.it/0weifjwef"], |
| 32 | + [detected => "2012-10-16 00:00:00"] |
| 33 | + )); |
| 34 | + |
| 35 | +$expected_result = '<record><threat>1</threat> |
| 36 | +<desc>gozdilla</desc> |
| 37 | +<value>http://y.ahoooooooooo.it/0weifjwef</value> |
| 38 | +<detected>2012-10-16 00:00:00</detected></record>'; |
| 39 | + |
| 40 | +ok($result eq $expected_result, 'Got expected results'); |
| 41 | + |
| 42 | +my $XML = XML::Generator->new(conformance => "strict", pretty => 1); |
| 43 | + |
| 44 | +$result = $XML->record( |
| 45 | + map { my ($k, $v) = @{$_}; $XML->$k($v); } |
| 46 | + ( |
| 47 | + [threat => 1], |
| 48 | + [desc => "godzilla"], |
| 49 | + [value => "http://y.ahoooooooooo.it/0weifjwef"], |
| 50 | + [detected => "2012-10-16 00:00:00"] |
| 51 | + )); |
| 52 | + |
| 53 | +$expected_result = '<record> |
| 54 | + <threat>1</threat> |
| 55 | + <desc>godzilla</desc> |
| 56 | + <value>http://y.ahoooooooooo.it/0weifjwef</value> |
| 57 | + <detected>2012-10-16 00:00:00</detected> |
| 58 | +</record>'; |
| 59 | + |
| 60 | +ok($result eq $expected_result, 'Got expected results'); |
| 61 | + |
| 62 | +$XML = XML::Generator->new(conformance => "strict", pretty => 1); |
| 63 | + |
| 64 | +$result = $XML->record( |
| 65 | + map { my ($k, $v) = @{$_}; $XML->$k($v); } |
| 66 | + ( |
| 67 | + [threat => 1], |
| 68 | + [desc => "godzilla"], |
| 69 | + [value => "http://y.ahoooooooooo.it/0weifjwef"], |
| 70 | + [detected => "2012-10-16 00:00:00"] |
| 71 | + )); |
| 72 | + |
| 73 | +$expected_result = '<record> |
| 74 | + <threat>1</threat> |
| 75 | + <desc>godzilla</desc> |
| 76 | + <value>http://y.ahoooooooooo.it/0weifjwef</value> |
| 77 | + <detected>2012-10-16 00:00:00</detected> |
| 78 | +</record>'; |
| 79 | + |
| 80 | +ok($result eq $expected_result, 'Got expected results'); |
0 commit comments