File: 1.0-to-2.0.t

package info (click to toggle)
libxml-rss-perl 1.49-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 768 kB
  • sloc: perl: 6,894; xml: 378; makefile: 8
file content (84 lines) | stat: -rw-r--r-- 2,159 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/perl

use strict;
use warnings;

use File::Spec;

use Test::More tests => 7;

use XML::RSS;

{
    my $rss = XML::RSS->new;
    $rss->parsefile(File::Spec->catfile(File::Spec->curdir(), "t", "data", "merlyn1.rss"));

    $rss->{output} = "2.0";
    my $string = $rss->as_string;

    # TEST
    ok (index($string, q{<lastBuildDate>Sat, 14 Oct 2006 21:15:36 -0000</lastBuildDate>}) >= 0,
        "Correct date was found",
    );

    # TEST
    ok (index($string, q{<pubDate>Sat, 14 Oct 2006 21:15:36 -0000</pubDate>}) >= 0,
        "Correct pubDate was found",
    );    
}

{
    my $rss = XML::RSS->new;
    $rss->parsefile(File::Spec->catfile(File::Spec->curdir(), "t", "data", "merlyn1.rss"));

    $rss->{output} = "0.91";
    my $string = $rss->as_string;

    my $index = index($string, qq{<pubDate>Sat, 14 Oct 2006 21:15:36 -0000</pubDate>\n<lastBuildDate>Sat, 14 Oct 2006 21:15:36 -0000</lastBuildDate>\n});
    # TEST
    ok ($index >= 0,
        "Correct date was found in 1.0 -> 0.91 conversion",
    );
}

{
    my $rss = XML::RSS->new;
    $rss->parsefile(File::Spec->catfile(File::Spec->curdir(), "t", "data", "2.0","sf-hs-with-pubDate.rss"));

    $rss->{output} = "1.0";
    my $string = $rss->as_string;

    my $index = index($string, qq{<dc:date>2006-09-24T10:12:49Z</dc:date>\n});
    # TEST
    ok ($index >= 0,
        "Correct date was found in 1.0 -> 0.91 conversion",
    );

    my $item_index = index($string, "<item");

    # TEST
    ok ($index < $item_index,
        "Correct date comes before the first item (hence not contained within)."
    );
}

{
    my $rss = XML::RSS->new;
    $rss->parsefile(File::Spec->catfile(File::Spec->curdir(), "t", "data", "2.0","sf-hs-with-lastBuildDate.rss"));

    $rss->{output} = "1.0";
    my $string = $rss->as_string;

    my $index = index($string, qq{<dc:date>2006-09-24T10:12:49Z</dc:date>\n});
    # TEST
    ok ($index >= 0,
        "Correct date was found in 1.0 -> 0.91 conversion",
    );

    my $item_index = index($string, "<item");

    # TEST
    ok ($index < $item_index,
        "Correct date comes before the first item (hence not contained within)."
    );
}