// Solutions to the Advent Of Code 2024. // Copyright (C) 2024-2025 Stefan Müller // // This program is free software: you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free Software // Foundation, either version 3 of the License, or (at your option) any later // version. // // This program is distributed in the hope that it will be useful, but WITHOUT // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along with // this program. If not, see . #pragma once #include #include #include #include #include #include class TestContext { public: void run(std::unique_ptr>&& solver, const long long& expected1, const long long& expected2, const std::vector& inputPaths); void run(std::unique_ptr>&& solver, const long long& expected1, const std::string& expected2, const std::vector& inputPaths); void run(std::unique_ptr>&& solver, const std::string& expected1, const long long& expected2, const std::vector& inputPaths); void runPart1(std::unique_ptr>&& solver, const long long& expected, const std::vector& inputPaths); void runPart1(std::unique_ptr>&& solver, const std::string& expected, const std::vector& inputPaths); void runPart2(std::unique_ptr>&& solver, const long long& expected, const std::vector& inputPaths); std::vector getInputPaths() const; std::vector getExampleInputPaths() const; private: template void runGeneric(const std::unique_ptr>&& solver, const T1& expected1, const T2& expected2, const std::vector& inputPaths) { SolverEngine solverEngine{ inputPaths }; solverEngine.run(*solver); REQUIRE(expected1 == solver->getResultPart1()); REQUIRE(expected2 == solver->getResultPart2()); } template void runPart1Generic(const std::unique_ptr>&& solver, const T1& expected, const std::vector& inputPaths) { SolverEngine solverEngine{ inputPaths }; solverEngine.run(*solver); REQUIRE(expected == solver->getResultPart1()); } template void runPart2Generic(const std::unique_ptr>&& solver, const T2& expected, const std::vector& inputPaths) { SolverEngine solverEngine{ inputPaths }; solverEngine.run(*solver); REQUIRE(expected == solver->getResultPart2()); } };