Author: jasons
Date: Mon Aug 28 04:17:21 2006
New Revision: 437663
URL: http://svn.apache.org/viewvc?rev=437663&view=rev
Log:
added writeToURI() tests
Modified:
xerces/c/trunk/swig/perl/t/DOMWriter.t
Modified: xerces/c/trunk/swig/perl/t/DOMWriter.t
URL:
http://svn.apache.org/viewvc/xerces/c/trunk/swig/perl/t/DOMWriter.t?rev=437663&r1=437662&r2=437663&view=diff
==============================================================================
--- xerces/c/trunk/swig/perl/t/DOMWriter.t (original)
+++ xerces/c/trunk/swig/perl/t/DOMWriter.t Mon Aug 28 04:17:21 2006
@@ -4,25 +4,25 @@
######################### We start with some black magic to print on failure.
-END {ok(0) unless $loaded;}
+END {fail() unless $loaded;}
use Carp;
# use blib;
use XML::Xerces;
-use Test::More tests => 3;
+use Test::More tests => 6;
use Config;
use vars qw($loaded);
use strict;
$loaded = 1;
-ok($loaded, "module loaded");
+pass("module loaded");
######################### End of black magic.
# Create a couple of identical test documents
-my $document = q[<?xml version="1.0" encoding="UTF-16" standalone="no"
?><contributors>
+my $document = q[<?xml version="1.0" encoding="UTF-8" standalone="no"
?><contributors>
<person Role="manager">
<name>Mike Pogue</name>
<email>[EMAIL PROTECTED]</email>
@@ -46,11 +46,37 @@
my $doc = $dom->getDocument();
my $impl = XML::Xerces::DOMImplementationRegistry::getDOMImplementation('LS');
my $writer = $impl->createLSSerializer();
-# $writer->setNewLine(0);
-# $writer->setEncoding("UTF-8");
+
my $output = $writer->writeToString($doc);
+# change the encoding string
+$output =~ s/UTF-16/UTF-8/;
+
ok($output, "output written");
-is($output, $document, "got expected document");
+is($output, $document, "got expected document")
+ or diag("Found: $output");
+
+my $file = 'foo.xml';
+my $rc = eval {$writer->writeToURI($doc, $file)};
+XML::Xerces::error($@) if $@;
+
+ok($rc,
+ 'writeToURI');
+
+SKIP: {
+ skip "Couldn't open $file for reading", 2, unless open(TEST, $file);
+
+# slurp the whole file in
+ local $/;
+ $output = <TEST>;
+
+ # change the encoding string
+ $output =~ s/UTF-16/UTF-8/;
+
+ ok($output, "output written");
+ is($output, $document, "got expected document")
+ or diag("Found: $output");
+ unlink($file);
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]