Add test that asks for more context than is available.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
f59c86e20d
commit
1c8279f96f
|
@ -88,8 +88,7 @@ SCENARIO("Searching EPUB files works")
|
||||||
GIVEN("Our test EPUB3 file")
|
GIVEN("Our test EPUB3 file")
|
||||||
{
|
{
|
||||||
fs::path epubfile{"test.epub3"};
|
fs::path epubfile{"test.epub3"};
|
||||||
std::setlocale(LC_CTYPE,
|
std::setlocale(LC_CTYPE, ""); // Needed for utf-8 support in libarchive.
|
||||||
""); // Needed for utf-8 support in libarchive.
|
|
||||||
bool exception{false};
|
bool exception{false};
|
||||||
|
|
||||||
REQUIRE(fs::exists(epubfile));
|
REQUIRE(fs::exists(epubfile));
|
||||||
|
@ -161,6 +160,32 @@ SCENARIO("Searching EPUB files works")
|
||||||
R"(media-type="application/xhtml+xml")");
|
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() == '.');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user