summaryrefslogtreecommitdiff
path: root/t/cdata.t
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2007-11-20 14:28:05 +0000
committer <>2013-08-08 17:01:04 +0000
commitc97631728ce7d6d3f4692a56c3cda7476b42a968 (patch)
tree8c00053771ccae41a737eecd072dbb3cd8b06fdd /t/cdata.t
downloadperl-xml-parser-master.tar.gz
Imported from /home/lorry/working-area/delta_perl-xml-parser/XML-Parser-2.36.tar.gz.HEADXML-Parser-2.36master
Diffstat (limited to 't/cdata.t')
-rw-r--r--t/cdata.t40
1 files changed, 40 insertions, 0 deletions
diff --git a/t/cdata.t b/t/cdata.t
new file mode 100644
index 0000000..5e1190b
--- /dev/null
+++ b/t/cdata.t
@@ -0,0 +1,40 @@
+BEGIN {print "1..2\n";}
+END {print "not ok 1\n" unless $loaded;}
+use XML::Parser;
+$loaded = 1;
+print "ok 1\n";
+
+my $count = 0;
+
+my $cdata_part = "<<< & > '' << &&&>&&&&;<";
+
+my $doc = "<foo> hello <![CDATA[$cdata_part]]> there</foo>";
+
+my $acc = '';
+
+sub ch {
+ my ($xp, $data) = @_;
+
+ $acc .= $data;
+}
+
+sub stcd {
+ my $xp = shift;
+ $xp->setHandlers(Char => \&ch);
+}
+
+sub ecd {
+ my $xp = shift;
+ $xp->setHandlers(Char => 0);
+}
+
+$parser = new XML::Parser(ErrorContext => 2,
+ Handlers => {CdataStart => \&stcd,
+ CdataEnd => \&ecd});
+
+$parser->parse($doc);
+
+print "not "
+ unless ($acc eq $cdata_part);
+print "ok 2\n";
+