diff --git a/tests/include/aocTests/TestContext.hpp b/tests/include/aocTests/TestContext.hpp index a391f06..0f5c01c 100644 --- a/tests/include/aocTests/TestContext.hpp +++ b/tests/include/aocTests/TestContext.hpp @@ -27,20 +27,18 @@ class TestContext { public: - void run(std::unique_ptr>&& solver, const int64_t expected1, const int64_t expected2, - const std::vector& inputPaths); - void run(std::unique_ptr>&& solver, const int64_t expected1, - const std::string& expected2, const std::vector& inputPaths); - void run(std::unique_ptr>&& solver, const std::string& expected1, - const int64_t expected2, const std::vector& inputPaths); - void runPart1(std::unique_ptr>&& solver, const int64_t 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 int64_t expected, - const std::vector& inputPaths); - std::vector getInputPaths() const; - std::vector getExampleInputPaths() const; + void runFull(std::unique_ptr>&& solver, const int64_t expected1, const int64_t expected2); + void runFull(std::unique_ptr>&& solver, const int64_t expected1, + const std::string& expected2); + void runFull(std::unique_ptr>&& solver, const std::string& expected1, + const int64_t expected2); + void runExample(std::unique_ptr>&& solver, const int64_t expected1, + const int64_t expected2); + void runExample(std::unique_ptr>&& solver, const int64_t expected1, + const std::string& expected2); + void runExamplePart1(std::unique_ptr>&& solver, const int64_t expected); + void runExamplePart1(std::unique_ptr>&& solver, const std::string& expected); + void runExamplePart2(std::unique_ptr>&& solver, const int64_t expected); private: template void runGeneric(const std::unique_ptr>&& solver, const T1& expected1, const T2& expected2, @@ -72,4 +70,8 @@ class TestContext REQUIRE(expected == solver->getResultPart2()); } + + static const inline std::vector inputPaths_{ "data", "../../../data", "../../../../data" }; + static const inline std::vector exampleInputPaths_{ "data/examples", "../../../data/examples", + "../../../../data/examples" }; }; diff --git a/tests/src/TestCases.cpp b/tests/src/TestCases.cpp index 7aa07ec..4ac4211 100644 --- a/tests/src/TestCases.cpp +++ b/tests/src/TestCases.cpp @@ -46,11 +46,11 @@ TEST_CASE("[HistorianHysteriaTests]") TestContext test; SECTION("FullData") { - test.run(std::make_unique(), 2176849, 23384288, test.getInputPaths()); + test.runFull(std::make_unique(), 2176849, 23384288); } SECTION("ExampleData") { - test.run(std::make_unique(), 11, 31, test.getExampleInputPaths()); + test.runExample(std::make_unique(), 11, 31); } } @@ -59,11 +59,11 @@ TEST_CASE("[RedNosedReportsTests]") TestContext test; SECTION("FullData") { - test.run(std::make_unique(), 472, 520, test.getInputPaths()); + test.runFull(std::make_unique(), 472, 520); } SECTION("ExampleData") { - test.run(std::make_unique(), 2, 4, test.getExampleInputPaths()); + test.runExample(std::make_unique(), 2, 4); } } @@ -72,11 +72,11 @@ TEST_CASE("[MullItOverTests]") TestContext test; SECTION("FullData") { - test.run(std::make_unique(), 187833789, 94455185, test.getInputPaths()); + test.runFull(std::make_unique(), 187833789, 94455185); } SECTION("ExampleData") { - test.run(std::make_unique(), 161, 48, test.getExampleInputPaths()); + test.runExample(std::make_unique(), 161, 48); } } @@ -85,11 +85,11 @@ TEST_CASE("[CeresSearchTests]") TestContext test; SECTION("FullData") { - test.run(std::make_unique(), 2462, 1877, test.getInputPaths()); + test.runFull(std::make_unique(), 2462, 1877); } SECTION("ExampleData") { - test.run(std::make_unique(), 18, 9, test.getExampleInputPaths()); + test.runExample(std::make_unique(), 18, 9); } } @@ -98,11 +98,11 @@ TEST_CASE("[PrintQueueTests]") TestContext test; SECTION("FullData") { - test.run(std::make_unique(), 5087, 4971, test.getInputPaths()); + test.runFull(std::make_unique(), 5087, 4971); } SECTION("ExampleData") { - test.run(std::make_unique(), 143, 123, test.getExampleInputPaths()); + test.runExample(std::make_unique(), 143, 123); } } @@ -111,11 +111,11 @@ TEST_CASE("[GuardGallivantTests]") TestContext test; SECTION("FullData") { - test.run(std::make_unique(), 4665, 1688, test.getInputPaths()); + test.runFull(std::make_unique(), 4665, 1688); } SECTION("ExampleData") { - test.run(std::make_unique(), 41, 6, test.getExampleInputPaths()); + test.runExample(std::make_unique(), 41, 6); } } @@ -124,11 +124,11 @@ TEST_CASE("[BridgeRepairTests]") TestContext test; SECTION("FullData") { - test.run(std::make_unique(), 12839601725877, 149956401519484, test.getInputPaths()); + test.runFull(std::make_unique(), 12839601725877, 149956401519484); } SECTION("ExampleData") { - test.run(std::make_unique(), 3749, 11387, test.getExampleInputPaths()); + test.runExample(std::make_unique(), 3749, 11387); } } @@ -137,11 +137,11 @@ TEST_CASE("[ResonantCollinearityTests]") TestContext test; SECTION("FullData") { - test.run(std::make_unique(), 426, 1359, test.getInputPaths()); + test.runFull(std::make_unique(), 426, 1359); } SECTION("ExampleData") { - test.run(std::make_unique(), 14, 34, test.getExampleInputPaths()); + test.runExample(std::make_unique(), 14, 34); } } @@ -150,11 +150,11 @@ TEST_CASE("[DiskFragmenterTests]") TestContext test; SECTION("FullData") { - test.run(std::make_unique(), 6401092019345, 6431472344710, test.getInputPaths()); + test.runFull(std::make_unique(), 6401092019345, 6431472344710); } SECTION("ExampleData") { - test.run(std::make_unique(), 1928, 2858, test.getExampleInputPaths()); + test.runExample(std::make_unique(), 1928, 2858); } } @@ -163,11 +163,11 @@ TEST_CASE("[HoofItTests]") TestContext test; SECTION("FullData") { - test.run(std::make_unique(), 611, 1380, test.getInputPaths()); + test.runFull(std::make_unique(), 611, 1380); } SECTION("ExampleData") { - test.run(std::make_unique(), 36, 81, test.getExampleInputPaths()); + test.runExample(std::make_unique(), 36, 81); } } @@ -176,11 +176,11 @@ TEST_CASE("[PlutonianPebblesTests]") TestContext test; SECTION("FullData") { - test.run(std::make_unique(), 220999, 261936432123724, test.getInputPaths()); + test.runFull(std::make_unique(), 220999, 261936432123724); } SECTION("ExampleData") { - test.run(std::make_unique(), 55312, 65601038650482, test.getExampleInputPaths()); + test.runExample(std::make_unique(), 55312, 65601038650482); } } @@ -189,27 +189,27 @@ TEST_CASE("[GardenGroupsTests]") TestContext test; SECTION("FullData") { - test.run(std::make_unique(), 1477762, 923480, test.getInputPaths()); + test.runFull(std::make_unique(), 1477762, 923480); } SECTION("ExampleData") { - test.run(std::make_unique(), 1930, 1206, test.getExampleInputPaths()); + test.runExample(std::make_unique(), 1930, 1206); } SECTION("ExampleData2") { - test.run(std::make_unique(2), 140, 80, test.getExampleInputPaths()); + test.runExample(std::make_unique(2), 140, 80); } SECTION("ExampleData3") { - test.run(std::make_unique(3), 772, 436, test.getExampleInputPaths()); + test.runExample(std::make_unique(3), 772, 436); } SECTION("ExampleData4") { - test.runPart2(std::make_unique(4), 236, test.getExampleInputPaths()); + test.runExamplePart2(std::make_unique(4), 236); } SECTION("ExampleData5") { - test.runPart2(std::make_unique(5), 368, test.getExampleInputPaths()); + test.runExamplePart2(std::make_unique(5), 368); } } @@ -218,11 +218,11 @@ TEST_CASE("[ClawContraptionTests]") TestContext test; SECTION("FullData") { - test.run(std::make_unique(), 36571, 85527711500010, test.getInputPaths()); + test.runFull(std::make_unique(), 36571, 85527711500010); } SECTION("ExampleData") { - test.run(std::make_unique(), 480, 875318608908, test.getExampleInputPaths()); + test.runExample(std::make_unique(), 480, 875318608908); } } @@ -231,11 +231,11 @@ TEST_CASE("[RestroomRedoubtTests]") TestContext test; SECTION("FullData") { - test.run(std::make_unique(), 224969976, 7892, test.getInputPaths()); + test.runFull(std::make_unique(), 224969976, 7892); } SECTION("ExampleData") { - test.run(std::make_unique(11, 7, false), 12, 0, test.getExampleInputPaths()); + test.runExample(std::make_unique(11, 7, false), 12, 0); } } @@ -244,15 +244,15 @@ TEST_CASE("[WarehouseWoesTests]") TestContext test; SECTION("FullData") { - test.run(std::make_unique(), 1515788, 1516544, test.getInputPaths()); + test.runFull(std::make_unique(), 1515788, 1516544); } SECTION("ExampleData") { - test.run(std::make_unique(), 10092, 9021, test.getExampleInputPaths()); + test.runExample(std::make_unique(), 10092, 9021); } SECTION("ExampleData2") { - test.runPart1(std::make_unique(2), 2028, test.getExampleInputPaths()); + test.runExamplePart1(std::make_unique(2), 2028); } } @@ -261,15 +261,15 @@ TEST_CASE("[ReindeerMazeTests]") TestContext test; SECTION("FullData") { - test.run(std::make_unique(), 72400, 435, test.getInputPaths()); + test.runFull(std::make_unique(), 72400, 435); } SECTION("ExampleData") { - test.run(std::make_unique(), 7036, 45, test.getExampleInputPaths()); + test.runExample(std::make_unique(), 7036, 45); } SECTION("ExampleData2") { - test.run(std::make_unique(2), 11048, 64, test.getExampleInputPaths()); + test.runExample(std::make_unique(2), 11048, 64); } } @@ -278,11 +278,11 @@ TEST_CASE("[ChronospatialComputerTests]") TestContext test; SECTION("FullData") { - test.run(std::make_unique(), "5,0,3,5,7,6,1,5,4", 164516454365621, test.getInputPaths()); + test.runFull(std::make_unique(), "5,0,3,5,7,6,1,5,4", 164516454365621); } SECTION("ExampleData") { - test.runPart1(std::make_unique(), "4,6,3,5,6,3,5,2,1,0", test.getExampleInputPaths()); + test.runExamplePart1(std::make_unique(), "4,6,3,5,6,3,5,2,1,0"); } SECTION("ExampleInstruction1") { @@ -333,11 +333,11 @@ TEST_CASE("[RamRunTests]") TestContext test; SECTION("FullData") { - test.run(std::make_unique(), 248, "32,55", test.getInputPaths()); + test.runFull(std::make_unique(), 248, "32,55"); } SECTION("ExampleData") { - test.run(std::make_unique(7, 12), 22, "6,1", test.getExampleInputPaths()); + test.runExample(std::make_unique(7, 12), 22, "6,1"); } } @@ -346,11 +346,11 @@ TEST_CASE("[LinenLayoutTests]") TestContext test; SECTION("FullData") { - test.run(std::make_unique(), 272, 1041529704688380, test.getInputPaths()); + test.runFull(std::make_unique(), 272, 1041529704688380); } SECTION("ExampleData") { - test.run(std::make_unique(), 6, 16, test.getExampleInputPaths()); + test.runExample(std::make_unique(), 6, 16); } } @@ -359,10 +359,10 @@ TEST_CASE("[LanPartyTests]") TestContext test; SECTION("FullData") { - test.run(std::make_unique(), 1230, "", test.getInputPaths()); + test.runFull(std::make_unique(), 1230, ""); } SECTION("ExampleData") { - test.run(std::make_unique(), 7, "", test.getExampleInputPaths()); + test.runExample(std::make_unique(), 7, ""); } } diff --git a/tests/src/TestContext.cpp b/tests/src/TestContext.cpp index b4e45f1..316ffb2 100644 --- a/tests/src/TestContext.cpp +++ b/tests/src/TestContext.cpp @@ -15,48 +15,47 @@ #include -void TestContext::run(std::unique_ptr>&& solver, const int64_t expected1, - const int64_t expected2, const std::vector& inputPaths) +void TestContext::runFull(std::unique_ptr>&& solver, const int64_t expected1, + const int64_t expected2) { - runGeneric(std::move(solver), expected1, expected2, inputPaths); + runGeneric(std::move(solver), expected1, expected2, inputPaths_); } -void TestContext::run(std::unique_ptr>&& solver, const int64_t expected1, - const std::string& expected2, const std::vector& inputPaths) +void TestContext::runFull(std::unique_ptr>&& solver, const int64_t expected1, + const std::string& expected2) { - runGeneric(std::move(solver), expected1, expected2, inputPaths); + runGeneric(std::move(solver), expected1, expected2, inputPaths_); } -void TestContext::run(std::unique_ptr>&& solver, const std::string& expected1, - const int64_t expected2, const std::vector& inputPaths) +void TestContext::runFull(std::unique_ptr>&& solver, const std::string& expected1, + const int64_t expected2) { - runGeneric(std::move(solver), expected1, expected2, inputPaths); + runGeneric(std::move(solver), expected1, expected2, inputPaths_); } -void TestContext::runPart1(std::unique_ptr>&& solver, const int64_t expected, - const std::vector& inputPaths) +void TestContext::runExample(std::unique_ptr>&& solver, const int64_t expected1, + const int64_t expected2) { - runPart1Generic(std::move(solver), expected, inputPaths); + runGeneric(std::move(solver), expected1, expected2, exampleInputPaths_); } -void TestContext::runPart1(std::unique_ptr>&& solver, const std::string& expected, - const std::vector& inputPaths) +void TestContext::runExample(std::unique_ptr>&& solver, const int64_t expected1, + const std::string& expected2) { - runPart1Generic(std::move(solver), expected, inputPaths); + runGeneric(std::move(solver), expected1, expected2, exampleInputPaths_); } -void TestContext::runPart2(std::unique_ptr>&& solver, const int64_t expected, - const std::vector& inputPaths) +void TestContext::runExamplePart1(std::unique_ptr>&& solver, const int64_t expected) { - runPart2Generic(std::move(solver), expected, inputPaths); + runPart1Generic(std::move(solver), expected, exampleInputPaths_); } -std::vector TestContext::getInputPaths() const +void TestContext::runExamplePart1(std::unique_ptr>&& solver, const std::string& expected) { - return std::vector{ "data", "../../../data", "../../../../data" }; + runPart1Generic(std::move(solver), expected, exampleInputPaths_); } -std::vector TestContext::getExampleInputPaths() const +void TestContext::runExamplePart2(std::unique_ptr>&& solver, const int64_t expected) { - return std::vector{ "data/examples", "../../../data/examples", "../../../../data/examples" }; + runPart2Generic(std::move(solver), expected, exampleInputPaths_); }