PageRenderTime 24ms CodeModel.GetById 12ms app.highlight 8ms RepoModel.GetById 2ms app.codeStats 0ms

/XML-FeedPP/t/19_invalid_w3cdtf.t

http://xml-treepp.googlecode.com/
Unknown | 41 lines | 41 code | 0 blank | 0 comment | 0 complexity | 8f6d65f8a058c530e90596a94031c87f MD5 | raw file
 1# ----------------------------------------------------------------
 2    use strict;
 3    use Test::More tests => 11;
 4    BEGIN { use_ok('XML::FeedPP') };
 5# ----------------------------------------------------------------
 6    my $map = {
 7        # valid - http://www.w3.org/TR/NOTE-datetime
 8        "2001-02-03"                    =>  "2001-02-03T00:00:00Z",
 9        "2002-03-04T05:06Z"             =>  "2002-03-04T05:06:00Z",
10        "2003-04-05T06:07+08:30"        =>  "2003-04-05T06:07:00+08:30",
11        "2004-05-06T07:08:09Z"          =>  "2004-05-06T07:08:09Z",
12        "2005-06-07T08:09:10-11:30"     =>  "2005-06-07T08:09:10-11:30",
13        "2006-07-08T09:10:11.12Z"       =>  "2006-07-08T09:10:11Z",
14        "2007-08-09T10:11:12.13+14:30"  =>  "2007-08-09T10:11:12+14:30",
15        # invalid - http://portal.nifty.com/rss/headline.rdf
16        "2000-01-02T03:04:05:+09:00"    =>  "2000-01-02T03:04:05+09:00",
17	# invalid - http://www.cnc.co.jp/news/xml/rss.xml
18	"2008-03-24T16:54:33 +0900"     =>  "2008-03-24T16:54:33+09:00",
19    };
20# ----------------------------------------------------------------
21    my $rss = XML::FeedPP::RSS->new();
22    foreach my $try ( sort keys %$map ) {
23        my $url = "http://www.kawa.net/?date=$try";
24        my $item3 = $rss->add_item( $url );
25        $item3->pubDate( $try );
26    }
27    my $xml = $rss->to_string();
28    my $rdf = XML::FeedPP::RDF->new();
29    $rdf->merge( $xml );
30    my $check = {};
31    foreach my $item4 ( $rdf->get_item() ) {
32        my $url = $item4->link();
33        my $try = (split( /=/, $url ))[1];
34        next unless defined $map->{$try};
35        $check->{$try} ++;
36        is( $item4->pubDate(), $map->{$try}, "RSS to RDF: $try" );
37    }
38    is( (scalar keys %$check), (scalar keys %$map), "RSS to RDF: checked" );
39# ----------------------------------------------------------------
40;1;
41# ----------------------------------------------------------------