Last active
December 16, 2015 00:10
-
-
Save cursork/5345847 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use Test::More; | |
use FindBin::libs; | |
use CompareXML qw/compare_xml/; | |
ok(compare_xml( | |
'<foo><bar baz="456">123</bar></foo>', | |
'<foo><bar baz="456">123</bar></foo>'), | |
'Identical XML matches'); | |
ok(!compare_xml( | |
'<foo><barr baz="456">123</barr></foo>', | |
'<foo><bar baz="456">123</bar></foo>'), | |
'Different node name fails'); | |
ok(!compare_xml( | |
'<foo><bar baz="456">first</bar></foo>', | |
'<foo><bar baz="456">second</bar></foo>'), | |
'Different text content fails'); | |
ok(!compare_xml( | |
'<foo><bar quux="456">123</bar></foo>', | |
'<foo><bar baz="456">123</bar></foo>'), | |
'Different attribute fails'); | |
ok(!compare_xml( | |
'<foo><bar baz="789">123</bar></foo>', | |
'<foo><bar baz="456">123</bar></foo>'), | |
'Different attribute content fails'); | |
ok(!compare_xml( | |
'<foo><bar baz="456" quux="789">123</bar></foo>', | |
'<foo><bar baz="456">123</bar></foo>'), | |
'Additional attribute fails'); | |
ok(compare_xml( | |
'<foo><bar baz="456" quux="789">123</bar></foo>', | |
'<foo><bar quux="789" baz="456">123</bar></foo>'), | |
'Differently ordered attributes match'); | |
ok(!compare_xml( | |
'<foo><bar>123</bar></foo>', | |
'<foo><bar baz="456">123</bar></foo>'), | |
'Missing attribute fails'); | |
ok(compare_xml( | |
'<foo><bar baz="456"><![CDATA[123]]></bar></foo>', | |
'<foo><bar baz="456">123</bar></foo>'), | |
'CDATA matches'); | |
ok(compare_xml( | |
'<?xml version="1.0" encoding="utf-8"?><foo><bar baz="456">123</bar></foo>', | |
'<foo><bar baz="456">123</bar></foo>'), | |
'With XML declaration matches no declaration'); | |
ok(compare_xml( | |
'<foo><bar baz="456">123</bar></foo>', <<'XML'), | |
<foo> | |
<bar baz='456'>123</bar> | |
</foo> | |
XML | |
'Pretty XML matches'); | |
done_testing; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment