1
/* test driver for rsspp */
3
#define BOOST_AUTO_TEST_MAIN
4
#define BOOST_TEST_DYN_LINK
5
#include <boost/test/auto_unit_test.hpp>
8
#include <rsspp_internal.h>
11
BOOST_AUTO_TEST_CASE(TestParseSimpleRSS_0_91) {
14
rsspp::feed f = p.parse_file("data/rss091_1.xml");
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");
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, "");
30
BOOST_AUTO_TEST_CASE(TestParseSimpleRSS_0_92) {
33
rsspp::feed f = p.parse_file("data/rss092_1.xml");
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");
41
BOOST_CHECK_EQUAL(f.items.size(), 2u);
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, "");
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, "");
56
BOOST_AUTO_TEST_CASE(TestParseSimpleRSS_2_0) {
59
rsspp::feed f = p.parse_file("data/rss20_1.xml");
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");
65
BOOST_CHECK_EQUAL(f.items.size(), 1u);
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);
77
BOOST_AUTO_TEST_CASE(TestParseSimpleRSS_1_0) {
80
rsspp::feed f = p.parse_file("data/rss10_1.xml");
81
BOOST_CHECK_EQUAL(f.rss_version, rsspp::RSS_1_0);
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");
87
BOOST_CHECK_EQUAL(f.items.size(), 1u);
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");
96
BOOST_AUTO_TEST_CASE(TestParseSimpleAtom_1_0) {
99
rsspp::feed f = p.parse_file("data/atom10_1.xml");
100
BOOST_CHECK_EQUAL(f.rss_version, rsspp::ATOM_1_0);
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/");
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");
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");
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");
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");