From 59ceaa7cdcc68ca06b29de7210327cb7dd5565e6 Mon Sep 17 00:00:00 2001 From: tastytea Date: Sat, 29 May 2021 23:00:40 +0200 Subject: [PATCH] Add another test for search::headline(). --- tests/test_search_helpers.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/test_search_helpers.cpp b/tests/test_search_helpers.cpp index 2050826..0eb564a 100644 --- a/tests/test_search_helpers.cpp +++ b/tests/test_search_helpers.cpp @@ -128,6 +128,27 @@ SCENARIO("Searching helpers work as intended") REQUIRE(text == "The long road to nowhere"); } } + + WHEN("There are tags that start with h but are not headlines") + { + text = "
The long
road to nowhere
"; + try + { + epubgrep::search::cleanup_text(text); + text = epubgrep::search::headline(text); + } + catch (const std::exception &) + { + exception = true; + } + + THEN("No exception is thrown") + AND_THEN("No headline is extracted") + { + REQUIRE_FALSE(exception); + REQUIRE(text.empty()); + } + } } SECTION("page() does what it should do")