Update 09.cpp

This commit is contained in:
Eric Mertens 2022-11-15 18:20:41 -08:00
parent bb6d1eeb90
commit a79696c947

View File

@ -1,6 +1,8 @@
#include <iostream> #include <iostream>
#include <utility> #include <utility>
#include <doctest.h>
#include <aocpp/Startup.hpp> #include <aocpp/Startup.hpp>
#include <intcode/intcode.hpp> #include <intcode/intcode.hpp>
using namespace intcode; using namespace intcode;
@ -17,6 +19,16 @@ auto Compute(Machine machine, ValueType d) -> ValueType {
} // namespace } // namespace
TEST_SUITE("documented examples") {
TEST_CASE("part 1") {
std::vector<ValueType> pgm {109,1,204,-1,1001,100,1,100,1008,100,16,101,1006,101,0,99};
std::vector<ValueType> output;
Machine machine {pgm};
Run(machine, []() -> ValueType{ REQUIRE(false); return 0; }, [&](ValueType o){ output.push_back(o);});
REQUIRE(pgm == output);
}
}
auto main(int argc, char** argv) -> int { auto main(int argc, char** argv) -> int {
auto machine = Machine{ParseStream(aocpp::Startup(argc, argv))}; auto machine = Machine{ParseStream(aocpp::Startup(argc, argv))};
std::cout << "Part 1: " << Compute(machine, 1) << std::endl; std::cout << "Part 1: " << Compute(machine, 1) << std::endl;