[Bps-public-commit] r14286 - in Data-Plist: .
kyoki at bestpractical.com
kyoki at bestpractical.com
Fri Jul 18 16:13:40 EDT 2008
Author: kyoki
Date: Fri Jul 18 16:13:35 2008
New Revision: 14286
Added:
Data-Plist/t/xml-write.t
Modified:
Data-Plist/ (props changed)
Log:
r29791 at nyx: kyoki | 2008-07-18 16:11:01 -0400
more tests, since I forgot to add this last time.
Added: Data-Plist/t/xml-write.t
==============================================================================
--- (empty file)
+++ Data-Plist/t/xml-write.t Fri Jul 18 16:13:35 2008
@@ -0,0 +1,115 @@
+use Test::More tests => 45;
+
+use strict;
+use warnings;
+
+use Data::Plist::XMLWriter;
+
+my $out;
+
+
+# Dict
+one_way( { "kitteh" => "Angleton" }, '<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+
+<plist version="1.0">
+ <dict>
+ <key>kitteh</key>
+ <string>Angleton</string>
+ </dict>
+</plist>
+' );
+
+# Array
+one_way( [ "Cthulhu", 42, "a" ], '<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+
+<plist version="1.0">
+ <array>
+ <string>Cthulhu</string>
+ <integer>42</integer>
+ <string>a</string>
+ </array>
+</plist>
+');
+
+# UID
+preserialize( [ UID => 1 ],'<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+
+<plist version="1.0">
+ <dict>
+ <key>CF$UID</key>
+ <integer>1</integer>
+ </dict>
+</plist>
+' );
+
+# Miscs
+preserialize( [ false => 0 ], '<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+
+<plist version="1.0">
+ <false />
+</plist>
+' );
+preserialize( [ true => 1 ], '<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+
+<plist version="1.0">
+ <true />
+</plist>
+' );
+preserialize( [ fill => 15 ], '<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+
+<plist version="1.0">
+ <fill />
+</plist>
+' );
+preserialize( [ null => 0 ], '<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+
+<plist version="1.0">
+ <null />
+</plist>
+' );
+
+# Data
+preserialize( [ data => "stu\x00ff" ], '<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+
+<plist version="1.0">
+ <data>c3R1AGZm
+</data>
+</plist>
+');
+
+# Not one of the prescribes structures
+preserialize( [ random => 17 ], '<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+
+<plist version="1.0">
+ <!-- random -->
+</plist>
+');
+
+sub one_way {
+ my $write = Data::Plist::XMLWriter->new( serialize => 1 );
+ test( $write, @_ );
+}
+
+sub preserialize {
+ my $write = Data::Plist::XMLWriter->new( serialize => 0 );
+ test( $write, @_ );
+}
+
+sub test {
+ my ($write, $input, $output) = @_;
+ ok( $write, "Created XML writer." );
+ isa_ok( $write, "Data::Plist::XMLWriter" );
+ $out = $write->write($input);
+ ok( $out, "Created xml." );
+ is( "$@", '' );
+ is ($out, $output, "XML output is correct.")
+}
More information about the Bps-public-commit
mailing list