~ubuntu-branches/ubuntu/maverick/newsbeuter/maverick

« back to all changes in this revision

Viewing changes to test/test-rss.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Nico Golde
  • Date: 2009-04-21 14:06:18 UTC
  • mfrom: (4.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20090421140618-osnjk19bgkebyg9h
Tags: 2.0-1
* New upstream release.
  - Remove dependeny on mrss and nxml and add libxml2, newsbeuter
    now comes with its own parser.
  - Remove debian/patches and quilt dependency.
* Bump to policy 3.8.1, no changes needed.
* debian/copyright: adjust years.
* Remove dh_clean -k call as it is deprecated -> dh_prep.
* Change newsbeuter homepage, it now has an official one.
* Fix watch file url, new upstream code location.
* Add bookmark-scuttle.sh to installed contrib files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* test driver for rsspp */
 
2
 
 
3
#define BOOST_AUTO_TEST_MAIN
 
4
#define BOOST_TEST_DYN_LINK
 
5
#include <boost/test/auto_unit_test.hpp>
 
6
 
 
7
#include <rsspp.h>
 
8
#include <rsspp_internal.h>
 
9
 
 
10
 
 
11
BOOST_AUTO_TEST_CASE(TestParseSimpleRSS_0_91) {
 
12
        rsspp::parser p;
 
13
 
 
14
        rsspp::feed f = p.parse_file("data/rss091_1.xml");
 
15
 
 
16
        BOOST_CHECK_EQUAL(f.rss_version, rsspp::RSS_0_91);
 
17
        BOOST_CHECK_EQUAL(f.title, "Example Channel");
 
18
        BOOST_CHECK_EQUAL(f.description, "an example feed");
 
19
        BOOST_CHECK_EQUAL(f.link, "http://example.com/");
 
20
        BOOST_CHECK_EQUAL(f.language, "en");
 
21
 
 
22
        BOOST_CHECK_EQUAL(f.items.size(), 1u);
 
23
        BOOST_CHECK_EQUAL(f.items[0].title, "1 < 2");
 
24
        BOOST_CHECK_EQUAL(f.items[0].link, "http://example.com/1_less_than_2.html");
 
25
        BOOST_CHECK_EQUAL(f.items[0].description, "1 < 2, 3 < 4.\nIn HTML, <b> starts a bold phrase\nand you start a link with <a href=\n");
 
26
        BOOST_CHECK_EQUAL(f.items[0].author, "");
 
27
        BOOST_CHECK_EQUAL(f.items[0].guid, "");
 
28
}
 
29
 
 
30
BOOST_AUTO_TEST_CASE(TestParseSimpleRSS_0_92) {
 
31
        rsspp::parser p;
 
32
 
 
33
        rsspp::feed f = p.parse_file("data/rss092_1.xml");
 
34
 
 
35
        BOOST_CHECK_EQUAL(f.rss_version, rsspp::RSS_0_92);
 
36
        BOOST_CHECK_EQUAL(f.title, "Example Channel");
 
37
        BOOST_CHECK_EQUAL(f.description, "an example feed");
 
38
        BOOST_CHECK_EQUAL(f.link, "http://example.com/");
 
39
        BOOST_CHECK_EQUAL(f.language, "en");
 
40
 
 
41
        BOOST_CHECK_EQUAL(f.items.size(), 2u);
 
42
 
 
43
        BOOST_CHECK_EQUAL(f.items[0].title, "1 < 2");
 
44
        BOOST_CHECK_EQUAL(f.items[0].link, "http://example.com/1_less_than_2.html");
 
45
        BOOST_CHECK_EQUAL(f.items[0].description, "1 < 2, 3 < 4.\nIn HTML, <b> starts a bold phrase\nand you start a link with <a href=\n");
 
46
        BOOST_CHECK_EQUAL(f.items[0].author, "");
 
47
        BOOST_CHECK_EQUAL(f.items[0].guid, "");
 
48
 
 
49
        BOOST_CHECK_EQUAL(f.items[1].title, "A second item");
 
50
        BOOST_CHECK_EQUAL(f.items[1].link, "http://example.com/a_second_item.html");
 
51
        BOOST_CHECK_EQUAL(f.items[1].description, "no description");
 
52
        BOOST_CHECK_EQUAL(f.items[1].author, "");
 
53
        BOOST_CHECK_EQUAL(f.items[1].guid, "");
 
54
}
 
55
 
 
56
BOOST_AUTO_TEST_CASE(TestParseSimpleRSS_2_0) {
 
57
        rsspp::parser p;
 
58
 
 
59
        rsspp::feed f = p.parse_file("data/rss20_1.xml");
 
60
 
 
61
        BOOST_CHECK_EQUAL(f.title, "my weblog");
 
62
        BOOST_CHECK_EQUAL(f.link, "http://example.com/blog/");
 
63
        BOOST_CHECK_EQUAL(f.description, "my description");
 
64
 
 
65
        BOOST_CHECK_EQUAL(f.items.size(), 1u);
 
66
 
 
67
        BOOST_CHECK_EQUAL(f.items[0].title, "this is an item");
 
68
        BOOST_CHECK_EQUAL(f.items[0].link, "http://example.com/blog/this_is_an_item.html");
 
69
        BOOST_CHECK_EQUAL(f.items[0].author, "Andreas Krennmair");
 
70
        BOOST_CHECK_EQUAL(f.items[0].author_email, "blog@synflood.at");
 
71
        BOOST_CHECK_EQUAL(f.items[0].content_encoded, "oh well, this is the content.");
 
72
        BOOST_CHECK_EQUAL(f.items[0].pubDate, "Fri, 12 Dec 2008 02:36:10 +0100");
 
73
        BOOST_CHECK_EQUAL(f.items[0].guid, "http://example.com/blog/this_is_an_item.html");
 
74
        BOOST_CHECK_EQUAL(f.items[0].guid_isPermaLink, false);
 
75
}
 
76
 
 
77
BOOST_AUTO_TEST_CASE(TestParseSimpleRSS_1_0) {
 
78
        rsspp::parser p;
 
79
 
 
80
        rsspp::feed f = p.parse_file("data/rss10_1.xml");
 
81
        BOOST_CHECK_EQUAL(f.rss_version, rsspp::RSS_1_0);
 
82
 
 
83
        BOOST_CHECK_EQUAL(f.title, "Example Dot Org");
 
84
        BOOST_CHECK_EQUAL(f.link, "http://www.example.org");
 
85
        BOOST_CHECK_EQUAL(f.description, "the Example Organization web site");
 
86
 
 
87
        BOOST_CHECK_EQUAL(f.items.size(), 1u);
 
88
 
 
89
        BOOST_CHECK_EQUAL(f.items[0].title, "New Status Updates");
 
90
        BOOST_CHECK_EQUAL(f.items[0].link, "http://www.example.org/status/foo");
 
91
        BOOST_CHECK_EQUAL(f.items[0].guid, "http://www.example.org/status/");
 
92
        BOOST_CHECK_EQUAL(f.items[0].description, "News about the Example project");
 
93
        BOOST_CHECK_EQUAL(f.items[0].pubDate, "Tue, 30 Dec 2008 07:20:00 +0000");
 
94
}
 
95
 
 
96
BOOST_AUTO_TEST_CASE(TestParseSimpleAtom_1_0) {
 
97
        rsspp::parser p;
 
98
 
 
99
        rsspp::feed f = p.parse_file("data/atom10_1.xml");
 
100
        BOOST_CHECK_EQUAL(f.rss_version, rsspp::ATOM_1_0);
 
101
 
 
102
        BOOST_CHECK_EQUAL(f.title, "test atom");
 
103
        BOOST_CHECK_EQUAL(f.title_type, "text");
 
104
        BOOST_CHECK_EQUAL(f.description, "atom description!");
 
105
        BOOST_CHECK_EQUAL(f.pubDate, "Tue, 30 Dec 2008 18:26:15 +0000");
 
106
        BOOST_CHECK_EQUAL(f.link, "http://example.com/");
 
107
 
 
108
        BOOST_CHECK_EQUAL(f.items.size(), 3u);
 
109
        BOOST_CHECK_EQUAL(f.items[0].title, "A gentle introduction to Atom testing");
 
110
        BOOST_CHECK_EQUAL(f.items[0].title_type, "html");
 
111
        BOOST_CHECK_EQUAL(f.items[0].link, "http://example.com/atom_testing.html");
 
112
        BOOST_CHECK_EQUAL(f.items[0].guid, "tag:example.com,2008-12-30:/atom_testing");
 
113
        BOOST_CHECK_EQUAL(f.items[0].description, "some content");
 
114
 
 
115
        BOOST_CHECK_EQUAL(f.items[1].title, "A missing rel attribute");
 
116
        BOOST_CHECK_EQUAL(f.items[1].title_type, "html");
 
117
        BOOST_CHECK_EQUAL(f.items[1].link, "http://example.com/atom_testing.html");
 
118
        BOOST_CHECK_EQUAL(f.items[1].guid, "tag:example.com,2008-12-30:/atom_testing1");
 
119
        BOOST_CHECK_EQUAL(f.items[1].description, "some content");
 
120
 
 
121
        BOOST_CHECK_EQUAL(f.items[2].title, "alternate link isn't first");
 
122
        BOOST_CHECK_EQUAL(f.items[2].title_type, "html");
 
123
        BOOST_CHECK_EQUAL(f.items[2].link, "http://example.com/atom_testing.html");
 
124
        BOOST_CHECK_EQUAL(f.items[2].guid, "tag:example.com,2008-12-30:/atom_testing2");
 
125
        BOOST_CHECK_EQUAL(f.items[2].description, "some content");
 
126
}
 
127
 
 
128
BOOST_AUTO_TEST_CASE(TestW3CDTFParser) {
 
129
        BOOST_CHECK_EQUAL(rsspp::rss_parser::__w3cdtf_to_rfc822("2008"), "Tue, 01 Jan 2008 00:00:00 +0000");
 
130
        BOOST_CHECK_EQUAL(rsspp::rss_parser::__w3cdtf_to_rfc822("2008-12"), "Mon, 01 Dec 2008 00:00:00 +0000");
 
131
        BOOST_CHECK_EQUAL(rsspp::rss_parser::__w3cdtf_to_rfc822("2008-12-30"), "Tue, 30 Dec 2008 00:00:00 +0000");
 
132
        BOOST_CHECK_EQUAL(rsspp::rss_parser::__w3cdtf_to_rfc822("2008-12-30T13:03:15Z"), "Tue, 30 Dec 2008 13:03:15 +0000");
 
133
        BOOST_CHECK_EQUAL(rsspp::rss_parser::__w3cdtf_to_rfc822("2008-12-30T10:03:15-08:00"), "Tue, 30 Dec 2008 18:03:15 +0000");
 
134
}