#include #include #include #include #include #include #include #define DOCTEST_CONFIG_IMPLEMENT #include namespace aocpp { auto Startup(int argc, char ** argv) -> std::unique_ptr { if (std::getenv("DOCTEST")) { exit(doctest::Context{argc, argv}.run()); } bool should_delete; std::istream* result_ptr; switch (argc) { case 2: should_delete = true; result_ptr = new std::ifstream{argv[1]}; break; case 1: should_delete = false; result_ptr = &std::cin; break; default: std::cerr << "bad arguments\n"; exit(EXIT_FAILURE); } return {result_ptr, should_delete}; } }