Skip to content

Commit

Permalink
skip tests if euc-jp is not supported on the system
Browse files Browse the repository at this point in the history
  • Loading branch information
miyagawa committed Nov 25, 2006
1 parent 101937f commit e0243fb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
9 changes: 8 additions & 1 deletion t/11-entry.t
Expand Up @@ -2,11 +2,18 @@

use strict;

use Test::More tests => 71;
use t::TestLib;
use Test::More;
use XML::Atom;
use XML::Atom::Entry;
use XML::Atom::Person;

unless ( xmllib_support_encoding('euc-jp') ){
plan skip_all => 'euc-jp is not supported on your XML library';
}

plan tests => 71;

my $entry;

$entry = XML::Atom::Entry->new;
Expand Down
21 changes: 21 additions & 0 deletions t/TestLib.pm
@@ -0,0 +1,21 @@
package t::TestLib;
use strict;
use base qw( Exporter );

our @EXPORT = qw( xmllib_support_encoding );
use XML::Atom;

sub xmllib_support_encoding {
my $enc = shift;

my $xml = qq(<?xml version="1.0" encoding="$enc"?>\n<foo />);
if (LIBXML) {
eval { XML::LibXML->new->parse_string($xml) };
return $@ ? 0 : 1;
} else {
eval { XML::XPath->new(xml => $xml) };
return $@ ? 0 : 1;
}
}

1;

0 comments on commit e0243fb

Please sign in to comment.