From cab1cf5a07cea16c09f9f9b86917db177a9168ec Mon Sep 17 00:00:00 2001 From: Thraix Date: Wed, 3 Dec 2025 21:25:52 +0100 Subject: [PATCH] Add general fixes - Fix compile warnings in old solutions - Fix makegen not generating Release mode with optimization - Fix makegen generating executables in different directories for Release and Debug - Add time elapsed for single day tests --- makegen.xml | 5 +++-- src/2023/Day10.cpp | 2 ++ src/2023/Day13.cpp | 3 ++- src/common/aoc.h | 8 ++++++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/makegen.xml b/makegen.xml index 0edd2bb..12308ec 100644 --- a/makegen.xml +++ b/makegen.xml @@ -2,7 +2,8 @@ false src/ - bin/ + -O3 + bin/Release adventofcode.out executable AdventOfCode @@ -12,7 +13,7 @@ false src/ -g - bin/ + bin/Debug/ adventofcode.out executable AdventOfCode diff --git a/src/2023/Day10.cpp b/src/2023/Day10.cpp index f1f0438..1aeae71 100644 --- a/src/2023/Day10.cpp +++ b/src/2023/Day10.cpp @@ -35,6 +35,8 @@ namespace y2023::day10 case Direction::West: return Index2D{position.x - 1, position.y}; } + std::cerr << "Reached unreachable code" << std::endl; + abort(); } Direction GetNextDirection(const Array2D& map, Index2D position, Direction prevDirection) diff --git a/src/2023/Day13.cpp b/src/2023/Day13.cpp index 59a431d..9eeb81c 100644 --- a/src/2023/Day13.cpp +++ b/src/2023/Day13.cpp @@ -107,7 +107,8 @@ namespace y2023::day13 map.Set(x, y, c); } } - std::cout << "here" << std::endl; + std::cerr << "Reached unreachable code" << std::endl; + abort(); } // Too low: 35441 diff --git a/src/common/aoc.h b/src/common/aoc.h index 65ec78e..5594164 100644 --- a/src/common/aoc.h +++ b/src/common/aoc.h @@ -127,12 +127,14 @@ namespace aoc std::cout << TERM_RED << "Could not find input file: " << test->GetInputFile() << TERM_CLEAR << std::endl; return false; } + Timer timer{}; std::string testName = name + ".P" + std::to_string(test->GetPart()) + "." + test->GetName(); std::cout << TERM_GREEN << "[ RUN ] " << TERM_CLEAR << testName << std::endl; InputType input = ReadInput(inputStream); OutputType output = test->GetPart() == 1 ? Output1(input) : Output2(input); + timer.Stop(); - if (!Check(test->GetExpectedOutput(), output, testName)) + if (!Check(test->GetExpectedOutput(), output, testName, timer.Elapsed())) { return false; }; @@ -150,10 +152,12 @@ namespace aoc virtual OutputType Output2(const InputType& input) = 0; private: - bool Check(const OutputType& expected, const OutputType& actual, const std::string& name) const + bool Check(const OutputType& expected, const OutputType& actual, const std::string& name, double elapsedTime) const { if (expected == actual) { + std::cout << TERM_GREEN << "[ ] " << TERM_CLEAR << " Took: " << elapsedTime << " seconds" + << std::endl; std::cout << TERM_GREEN << "[ OK ] " << TERM_CLEAR << " Result: " << actual << std::endl; return true; }