Add TestContext::runPart1() for tests that are only valid for part 1 of a puzzle

This commit is contained in:
Stefan Müller 2025-03-09 16:00:19 +01:00
parent 047abf9772
commit 8e67c19f98
2 changed files with 11 additions and 0 deletions

View File

@ -26,6 +26,8 @@ class TestContext
public: public:
void run(const std::unique_ptr<Solver>&& solver, const long long int expected1, const long long int expected2, void run(const std::unique_ptr<Solver>&& solver, const long long int expected1, const long long int expected2,
const std::vector<std::string>& inputPaths); const std::vector<std::string>& inputPaths);
void runPart1(const std::unique_ptr<Solver>&& solver, const long long int expected,
const std::vector<std::string>& inputPaths);
void runPart2(const std::unique_ptr<Solver>&& solver, const long long int expected, void runPart2(const std::unique_ptr<Solver>&& solver, const long long int expected,
const std::vector<std::string>& inputPaths); const std::vector<std::string>& inputPaths);
std::vector<std::string> getInputPaths() const; std::vector<std::string> getInputPaths() const;

View File

@ -29,6 +29,15 @@ void TestContext::run(const std::unique_ptr<Solver>&& solver, const long long in
REQUIRE(expected2 == solver->getResultPart2()); REQUIRE(expected2 == solver->getResultPart2());
} }
void TestContext::runPart1(const std::unique_ptr<Solver>&& solver, const long long int expected,
const std::vector<std::string>& inputPaths)
{
SolverEngine solverEngine{ inputPaths };
solverEngine.run(*solver);
REQUIRE(expected == solver->getResultPart1());
}
void TestContext::runPart2(const std::unique_ptr<Solver>&& solver, const long long int expected, void TestContext::runPart2(const std::unique_ptr<Solver>&& solver, const long long int expected,
const std::vector<std::string>& inputPaths) const std::vector<std::string>& inputPaths)
{ {