Skip to content

Commit

Permalink
Test media:<...> parsing for RSS 2.0 feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisschagt committed Oct 10, 2020
1 parent 0713a19 commit f6807da
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/data/rss20_2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<title>my weblog</title>
<link>http://example.com/blog/</link>
<description>my description</description>

<item>
<comments>http://example.com/blog/this_is_an_item.html#comments</comments>
<author>blog@synflood.at (Andreas Krennmair)</author>
<pubDate>Fri, 12 Dec 2008 02:36:10 +0100</pubDate>
<guid isPermaLink="false">http://example.com/blog/this_is_an_item.html</guid>

<media:description type="html">media html content</media:description>
<media:title>using multiple media tags</media:title>
<media:player url="http://example.com/player.html"/>
</item>

<item>
<comments>http://example.com/blog/this_is_an_item.html#comments</comments>
<author>blog@synflood.at (Andreas Krennmair)</author>
<pubDate>Fri, 12 Dec 2008 02:36:10 +0100</pubDate>
<guid isPermaLink="false">http://example.com/blog/this_is_an_item.html</guid>

<media:group>
<media:content>
<media:description type="html">nested media html content</media:description>
<media:title>using multiple media tags nested in group/content</media:title>
<media:player url="http://example.com/player.html"/>
</media:content>
</media:group>
</item>
</channel>
</rss>
26 changes: 26 additions & 0 deletions test/rsspp_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,29 @@ TEST_CASE("Extracts data from media:... tags in atom feed", "[rsspp::Parser]")
REQUIRE(f.items[4].link == "http://example.com/regular-link");
}
}

TEST_CASE("Extracts data from media:... tags in RSS 2.0 feeds",
"[rsspp::Parser]")
{
rsspp::Parser p;
rsspp::Feed f;

REQUIRE_NOTHROW(f = p.parse_file("data/rss20_2.xml"));

REQUIRE(f.title == "my weblog");
REQUIRE(f.link == "http://example.com/blog/");
REQUIRE(f.description == "my description");

REQUIRE(f.items.size() == 2u);

REQUIRE(f.items[0].title == "using multiple media tags");
REQUIRE(f.items[0].description == "media html content");
REQUIRE(f.items[0].description_type == "html");
REQUIRE(f.items[0].link == "http://example.com/player.html");

REQUIRE(f.items[1].title ==
"using multiple media tags nested in group/content");
REQUIRE(f.items[1].description == "nested media html content");
REQUIRE(f.items[1].description_type == "html");
REQUIRE(f.items[1].link == "http://example.com/player.html");
}

0 comments on commit f6807da

Please sign in to comment.