From c1613a8f52bfa19cae72a6a6ae91ed3396124a86 Mon Sep 17 00:00:00 2001 From: tastytea Date: Sat, 29 May 2021 23:01:00 +0200 Subject: [PATCH] Add test for zip::urldecode(). --- tests/test_zip.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/test_zip.cpp b/tests/test_zip.cpp index ad9ede4..dd067ed 100644 --- a/tests/test_zip.cpp +++ b/tests/test_zip.cpp @@ -70,3 +70,33 @@ SCENARIO("Zip file handling works") } } } + +SCENARIO("Helper functions in epubgrep::zip work") +{ + SECTION("urldecode() doesn't fail and returns the decoded string") + { + bool exception{false}; + + GIVEN("The string test%20folder/%2Afile%5Btest%5D%2A") + { + std::string encoded_text{"test%20folder/%2Afile%5Btest%5D%2A"}; + std::string decoded_text{}; + + try + { + decoded_text = epubgrep::zip::urldecode(encoded_text); + } + catch (const std::exception &) + { + exception = true; + } + + THEN("No exception is thrown") + AND_THEN("It returns the TOC correctly") + { + REQUIRE_FALSE(exception); + REQUIRE(decoded_text == "test folder/*file[test]*"); + } + } + } +}