|
|
|
@ -1,5 +1,8 @@ |
|
|
|
|
#include <catch2/catch_test_macros.hpp> |
|
|
|
|
#include "../game_engine.hpp" |
|
|
|
|
#include <fmt/core.h> |
|
|
|
|
|
|
|
|
|
using namespace fmt; |
|
|
|
|
|
|
|
|
|
TEST_CASE("basic brainfuck test", "[brainfuck]") { |
|
|
|
|
Brainfucker bf; |
|
|
|
@ -26,11 +29,16 @@ TEST_CASE("basic brainfuck test", "[brainfuck]") { |
|
|
|
|
|
|
|
|
|
TEST_CASE("brainfuck loop test", "[brainfuck]") { |
|
|
|
|
Brainfucker bf; |
|
|
|
|
const string expected{"Hello World!\n"}; |
|
|
|
|
// this is a hello world program from wikipedia
|
|
|
|
|
// but at the end I rewind dp so I can analyze it
|
|
|
|
|
string code{"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++."}; |
|
|
|
|
|
|
|
|
|
bf.set_code(code); |
|
|
|
|
bf.run(code.size()); |
|
|
|
|
|
|
|
|
|
string output = bf.out.str(); |
|
|
|
|
REQUIRE(output == expected); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_CASE("game engine can start and take hit", "[brainfuck]") { |
|
|
|
|