Add test that asks for more context than is available.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
tastytea 2021-06-07 00:05:33 +02:00
parent f59c86e20d
commit 1c8279f96f
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 27 additions and 2 deletions

View File

@ -88,8 +88,7 @@ SCENARIO("Searching EPUB files works")
GIVEN("Our test EPUB3 file")
{
fs::path epubfile{"test.epub3"};
std::setlocale(LC_CTYPE,
""); // Needed for utf-8 support in libarchive.
std::setlocale(LC_CTYPE, ""); // Needed for utf-8 support in libarchive.
bool exception{false};
REQUIRE(fs::exists(epubfile));
@ -161,6 +160,32 @@ SCENARIO("Searching EPUB files works")
R"(media-type="application/xhtml+xml")");
}
}
WHEN("We search for for a phrase at the beginning of the file "
"and specify a very high context")
{
try
{
opts.context = 69069;
matches = epubgrep::search::search(epubfile, "Test for",
opts);
}
catch (const std::exception &)
{
exception = true;
}
THEN("No exception is thrown")
AND_THEN("It returns the match correctly")
{
REQUIRE_FALSE(exception);
REQUIRE(matches.at(0).filepath_inside == "start.xhtml");
REQUIRE(matches.at(0).text == "Test for");
REQUIRE(matches.at(0).headline.empty());
REQUIRE(matches.at(0).context.first.empty());
REQUIRE(*matches.at(0).context.second.rbegin() == '.');
}
}
}
}
}