Change Solver into template class to allow for non-integer results
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// Solutions to the Advent Of Code 2024.
|
||||
// Copyright (C) 2024 Stefan Müller
|
||||
// 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
|
||||
@@ -24,11 +24,13 @@
|
||||
class TestContext
|
||||
{
|
||||
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<long long, long long>>&& solver, const long long expected1,
|
||||
const long long expected2, const std::vector<std::string>& inputPaths);
|
||||
void run(const std::unique_ptr<Solver<long long, std::string>>&& solver, const long long expected1,
|
||||
const std::string expected2, const std::vector<std::string>& inputPaths);
|
||||
void runPart1(const std::unique_ptr<Solver<long long, long long>>&& solver, const long long expected,
|
||||
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<long long, long long>>&& solver, const long long expected,
|
||||
const std::vector<std::string>& inputPaths);
|
||||
std::vector<std::string> getInputPaths() const;
|
||||
std::vector<std::string> getExampleInputPaths() const;
|
||||
|
||||
@@ -275,10 +275,10 @@ TEST_CASE("[LanPartyTests]")
|
||||
TestContext test;
|
||||
SECTION("FullData")
|
||||
{
|
||||
test.run(std::make_unique<LanParty>(), 1230, 0, test.getInputPaths());
|
||||
test.run(std::make_unique<LanParty>(), 1230, "", test.getInputPaths());
|
||||
}
|
||||
SECTION("ExampleData")
|
||||
{
|
||||
test.run(std::make_unique<LanParty>(), 7, 0, test.getExampleInputPaths());
|
||||
test.run(std::make_unique<LanParty>(), 7, "", test.getExampleInputPaths());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Solutions to the Advent Of Code 2024.
|
||||
// Copyright (C) 2024 Stefan Müller
|
||||
// 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
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
#include <aoc/framework/SolverEngine.hpp>
|
||||
|
||||
void TestContext::run(const std::unique_ptr<Solver>&& solver, const long long int expected1,
|
||||
const long long int expected2, const std::vector<std::string>& inputPaths)
|
||||
void TestContext::run(const std::unique_ptr<Solver<long long, long long>>&& solver, const long long expected1,
|
||||
const long long expected2, const std::vector<std::string>& inputPaths)
|
||||
{
|
||||
SolverEngine solverEngine{ inputPaths };
|
||||
solverEngine.run(*solver);
|
||||
@@ -29,7 +29,17 @@ void TestContext::run(const std::unique_ptr<Solver>&& solver, const long long in
|
||||
REQUIRE(expected2 == solver->getResultPart2());
|
||||
}
|
||||
|
||||
void TestContext::runPart1(const std::unique_ptr<Solver>&& solver, const long long int expected,
|
||||
void TestContext::run(const std::unique_ptr<Solver<long long, std::string>>&& solver, const long long expected1,
|
||||
const std::string expected2, const std::vector<std::string>& inputPaths)
|
||||
{
|
||||
SolverEngine solverEngine{ inputPaths };
|
||||
solverEngine.run(*solver);
|
||||
|
||||
REQUIRE(expected1 == solver->getResultPart1());
|
||||
REQUIRE(expected2 == solver->getResultPart2());
|
||||
}
|
||||
|
||||
void TestContext::runPart1(const std::unique_ptr<Solver<long long, long long>>&& solver, const long long expected,
|
||||
const std::vector<std::string>& inputPaths)
|
||||
{
|
||||
SolverEngine solverEngine{ inputPaths };
|
||||
@@ -38,7 +48,7 @@ void TestContext::runPart1(const std::unique_ptr<Solver>&& solver, const long lo
|
||||
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<long long, long long>>&& solver, const long long expected,
|
||||
const std::vector<std::string>& inputPaths)
|
||||
{
|
||||
SolverEngine solverEngine{ inputPaths };
|
||||
|
||||
Reference in New Issue
Block a user