#include "rss/parser.h" #include "3rd-party/catch.hpp" #include "rss/exception.h" #include "test-helpers/exceptionwithmsg.h" TEST_CASE("Throws exception if file doesn't exist", "[rsspp::Parser]") { using TestHelpers::ExceptionWithMsg; rsspp::Parser p; REQUIRE_THROWS_MATCHES(p.parse_file("data/non-existent.xml"), rsspp::Exception, ExceptionWithMsg("could not parse file")); } TEST_CASE("Throws exception if file can't be parsed", "[rsspp::Parser]") { using TestHelpers::ExceptionWithMsg; rsspp::Parser p; REQUIRE_THROWS_MATCHES(p.parse_file("data/empty.xml"), rsspp::Exception, ExceptionWithMsg("could not parse file")); } TEST_CASE("Extracts data from RSS 0.91", "[rsspp::Parser]") { rsspp::Parser p; rsspp::Feed f; REQUIRE_NOTHROW(f = p.parse_file("data/rss091_1.xml")); REQUIRE(f.rss_version == rsspp::Feed::RSS_0_91); REQUIRE(f.title == "Example Channel"); REQUIRE(f.description == "an example feed"); REQUIRE(f.link == "http://example.com/"); REQUIRE(f.language == "en"); REQUIRE(f.items.size() == 1u); REQUIRE(f.items[0].title == "1 < 2"); REQUIRE(f.items[0].link == "http://example.com/1_less_than_2.html"); REQUIRE(f.items[0].description == "1 < 2, 3 < 4.\nIn HTML, starts a bold phrase\nand you " "start a link with