Looks like the brainfuck is working. It can do a hello world program.

This commit is contained in:
Zed A. Shaw 2024-08-11 12:34:37 -04:00
parent 5b18849ddc
commit 38104f60f3
3 changed files with 78 additions and 4 deletions

View file

@ -1,7 +1,7 @@
#include <catch2/catch_test_macros.hpp>
#include "../game_engine.hpp"
TEST_CASE("brainfuck test", "[brainfuck]") {
TEST_CASE("basic brainfuck test", "[brainfuck]") {
Brainfucker bf;
string code{"+.>+.>+.>"};
@ -23,6 +23,16 @@ TEST_CASE("brainfuck test", "[brainfuck]") {
REQUIRE(bf.code.empty());
}
TEST_CASE("brainfuck loop test", "[brainfuck]") {
Brainfucker bf;
// this is a hello world program from wikipedia
string code{"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++."};
bf.set_code(code);
bf.run(code.size());
}
TEST_CASE("game engine can start and take hit", "[brainfuck]") {
// test fails on purpose right now
GameEngine game{4};