Commits

ph...@9ae0c189-cd1f-4510-a509-f4891f5cf20d  committed 1c61ba3

Modified Files:
t/08findnodes.t
+ tests provided by petr pajas

  • Participants
  • Parent commits d063313

Comments (0)

Files changed (1)

File t/08findnodes.t

 use Test;
-BEGIN { plan tests=>18 }
+BEGIN { plan tests=>36}
 END {ok(0) unless $loaded;}
 use XML::LibXML;
 $loaded = 1;
 
 # to test if findnodes works.
 # i added findnodes to the node class, so a query can be started
-# everywhere. Since I use only the 
+# everywhere.
 
 my $file    = "example/dromeds.xml";
 $itervar    = undef;
 ok(@doc);
 # warn($doc[0]->toString);
 
-eval { my $literal = $root->findvalue( "/-" ); };
-ok( $@ );
-
-eval { my @nodes = $root->findnodes( "/-" ); };
-ok( $@ );
-
 # this query should result an empty array!
 my @nodes = $root->findnodes( "/humpty/dumpty" );
 ok( scalar(@nodes), 0 );
 my @ns = $root->findnodes('namespace::*');
 ok(scalar(@ns), 2 );
 
+print "#bad xpaths\n";
 
+my @badxpath = (
+    'abc:::def',
+    'foo///bar',
+    '...',
+    '/-',
+               );
+
+foreach my $xp ( @badxpath ) {
+    eval { $res = $root->findnodes( $xp ); };
+    ok($@);
+    eval { $res = $root->find( $xp ); };
+    ok($@);
+    eval { $res = $root->findvalue( $xp ); };
+    ok($@);
+    eval { $res = $root->findnodes( encodeToUTF8( "iso-8859-1", $xp ) ); };
+    ok($@);
+    eval { $res = $root->find( encodeToUTF8( "iso-8859-1", $xp ) );};
+    ok($@);
+}
 
 sub finddoc {
     my $doc = shift;