Add TestCaseBase.run() to replace the template
The template was not necessary and this now allows for use of custom constructors in the test cases.
This commit is contained in:
parent
ff454776fa
commit
73446b2d83
|
@ -31,6 +31,13 @@ class TestCaseBase
|
||||||
Part2TestContext part2TestContext{ getInputPaths() };
|
Part2TestContext part2TestContext{ getInputPaths() };
|
||||||
Part1TestContext part1ExampleTestContext{ getExampleInputPaths() };
|
Part1TestContext part1ExampleTestContext{ getExampleInputPaths() };
|
||||||
Part2TestContext part2ExampleTestContext{ getExampleInputPaths() };
|
Part2TestContext part2ExampleTestContext{ getExampleInputPaths() };
|
||||||
|
void run(std::unique_ptr<Solver>&& solver, const long long int expected, const TestContext& context)
|
||||||
|
{
|
||||||
|
SolverEngine solverEngine{ context.getInputPaths() };
|
||||||
|
solverEngine.run(*solver);
|
||||||
|
|
||||||
|
REQUIRE(expected == context.getResult(*solver));
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
std::vector<std::string> getInputPaths() const
|
std::vector<std::string> getInputPaths() const
|
||||||
{
|
{
|
||||||
|
@ -43,33 +50,23 @@ class TestCaseBase
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
|
||||||
void runTest(const long long int expected, const TestContext& context)
|
|
||||||
{
|
|
||||||
auto solver = std::make_unique<T>();
|
|
||||||
SolverEngine solverEngine{ context.getInputPaths() };
|
|
||||||
solverEngine.run(*solver);
|
|
||||||
|
|
||||||
REQUIRE(expected == context.getResult(*solver));
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE("[HistorianHysteriaTests]")
|
TEST_CASE("[HistorianHysteriaTests]")
|
||||||
{
|
{
|
||||||
TestCaseBase test;
|
TestCaseBase test;
|
||||||
SECTION("FullData1")
|
SECTION("FullData1")
|
||||||
{
|
{
|
||||||
runTest<HistorianHysteria>(2176849, test.part1TestContext);
|
test.run(std::make_unique<HistorianHysteria>(), 2176849, test.part1TestContext);
|
||||||
}
|
}
|
||||||
SECTION("FullData2")
|
SECTION("FullData2")
|
||||||
{
|
{
|
||||||
runTest<HistorianHysteria>(23384288, test.part2TestContext);
|
test.run(std::make_unique<HistorianHysteria>(), 23384288, test.part2TestContext);
|
||||||
}
|
}
|
||||||
SECTION("ExampleData1")
|
SECTION("ExampleData1")
|
||||||
{
|
{
|
||||||
runTest<HistorianHysteria>(11, test.part1ExampleTestContext);
|
test.run(std::make_unique<HistorianHysteria>(), 11, test.part1ExampleTestContext);
|
||||||
}
|
}
|
||||||
SECTION("ExampleData2")
|
SECTION("ExampleData2")
|
||||||
{
|
{
|
||||||
runTest<HistorianHysteria>(31, test.part2ExampleTestContext);
|
test.run(std::make_unique<HistorianHysteria>(), 31, test.part2ExampleTestContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue