Skip to content

Commit

Permalink
Make methods static in the AlgorithmTest class
Browse files Browse the repository at this point in the history
  • Loading branch information
vs9h authored and polyntsov committed Nov 24, 2023
1 parent c6ae612 commit 7b5f86b
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/tests/testing_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,24 @@

template <typename T>
class AlgorithmTest : public ::testing::Test {
config::InputTable MakeCsvParser(std::string const& path, char separator, bool has_header) {
static config::InputTable MakeCsvParser(std::string const& path, char separator,
bool has_header) {
return std::make_shared<CSVParser>(path, separator, has_header);
}

protected:
std::unique_ptr<algos::FDAlgorithm> CreateAndConfToLoad(std::string const& path,
char separator = ',',
bool has_header = true) {
static std::unique_ptr<algos::FDAlgorithm> CreateAndConfToLoad(std::string const& path,
char separator = ',',
bool has_header = true) {
using config::InputTable, algos::ConfigureFromMap, algos::StdParamsMap;
std::unique_ptr<algos::FDAlgorithm> algorithm = std::make_unique<T>();
auto parser = MakeCsvParser(path, separator, has_header);
ConfigureFromMap(*algorithm, StdParamsMap{{config::names::kTable, parser}});
return algorithm;
}

algos::StdParamsMap GetParamMap(const std::filesystem::path& path, char separator = ',',
bool has_header = true) {
static algos::StdParamsMap GetParamMap(const std::filesystem::path& path, char separator = ',',
bool has_header = true) {
using namespace config::names;
return {
{kTable, MakeCsvParser(path, separator, has_header)},
Expand All @@ -37,9 +38,9 @@ class AlgorithmTest : public ::testing::Test {
};
}

std::unique_ptr<algos::FDAlgorithm> CreateAlgorithmInstance(const std::string& filename,
char separator = ',',
bool has_header = true) {
static std::unique_ptr<algos::FDAlgorithm> CreateAlgorithmInstance(const std::string& filename,
char separator = ',',
bool has_header = true) {
return algos::CreateAndLoadAlgorithm<T>(
GetParamMap(test_data_dir / filename, separator, has_header));
}
Expand Down

0 comments on commit 7b5f86b

Please sign in to comment.