A simple brainfuck interpreter for the game's idea.

This commit is contained in:
Zed A. Shaw 2024-08-10 03:21:11 -04:00
parent 984031bf33
commit 1fb99618bf
3 changed files with 132 additions and 1 deletions

View file

@ -1,6 +1,28 @@
#include <doctest.h>
#include "../game_engine.hpp"
TEST_CASE("brainfuck test") {
Brainfucker bf;
string code{"+.>+.>+.>"};
bf.set_code(code);
// this is actually ticks, not code length
bf.run(code.size());
CHECK(bf.data[0] == 1);
CHECK(bf.data[1] == 1);
CHECK(bf.data[2] == 1);
bf.reset();
CHECK(bf.data[0] == 0);
CHECK(bf.data[1] == 0);
CHECK(bf.data[2] == 0);
CHECK(bf.code.empty());
}
TEST_CASE("game engine can start and take hit") {
// test fails on purpose right now
GameEngine game{4};