- removed dead code and added comment

This commit is contained in:
Karsten Laux 2021-12-17 20:43:15 +01:00
parent 670ce5b0b3
commit c34fc7fefe
2 changed files with 3 additions and 8 deletions

View File

@ -3,6 +3,7 @@
#include <chrono> #include <chrono>
// function template executing given function with one argument, measuring execution time
template <typename Func, typename Arg1> template <typename Func, typename Arg1>
double TestRunner(Func func, Arg1& arg1) double TestRunner(Func func, Arg1& arg1)
{ {

View File

@ -41,8 +41,7 @@ bool check_result(const WordList& haystack, const std::string& pattern, const Pa
// check number of matches // check number of matches
const unsigned TESTPATTERN_LENGTH = 4; const unsigned TESTPATTERN_LENGTH = 4;
unsigned expected_count = static_cast<unsigned>(pow(26.0, double(TESTPATTERN_LENGTH - pattern.size()))); unsigned expected_count = static_cast<unsigned>(pow(26.0, double(TESTPATTERN_LENGTH - pattern.size())));
if (result.size() != expected_count) if (result.size() != expected_count)
{ {
std::cout << "wrong number of matches: expected " << expected_count << " but got " << result.size() << std::endl; std::cout << "wrong number of matches: expected " << expected_count << " but got " << result.size() << std::endl;
@ -50,14 +49,9 @@ bool check_result(const WordList& haystack, const std::string& pattern, const Pa
} }
// verify matches contain the search-pattern // verify matches contain the search-pattern
unsigned valid_count = 0;
for (WordList::const_iterator itr : result) for (WordList::const_iterator itr : result)
{ {
if (itr->substr(0, pattern.size()) == pattern) if (itr->substr(0, pattern.size()) != pattern)
{
valid_count++;
}
else
{ {
std::cout << "found unexpected entry in result: " << *itr << std::endl; std::cout << "found unexpected entry in result: " << *itr << std::endl;
result_valid = false; result_valid = false;