You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
671 B
32 lines
671 B
#include <catch2/catch_test_macros.hpp>
|
|
#include "../game_engine.hpp"
|
|
|
|
TEST_CASE("brainfuck test", "[brainfuck]") {
|
|
Brainfucker bf;
|
|
string code{"+.>+.>+.>"};
|
|
|
|
bf.set_code(code);
|
|
|
|
// this is actually ticks, not code length
|
|
bf.run(code.size());
|
|
|
|
REQUIRE(bf.data[0] == 1);
|
|
REQUIRE(bf.data[1] == 1);
|
|
REQUIRE(bf.data[2] == 1);
|
|
|
|
bf.reset();
|
|
|
|
REQUIRE(bf.data[0] == 0);
|
|
REQUIRE(bf.data[1] == 0);
|
|
REQUIRE(bf.data[2] == 0);
|
|
|
|
REQUIRE(bf.code.empty());
|
|
}
|
|
|
|
TEST_CASE("game engine can start and take hit", "[brainfuck]") {
|
|
// test fails on purpose right now
|
|
GameEngine game{4};
|
|
string err{"error"};
|
|
game.hit(err);
|
|
REQUIRE(game.is_dead() == true);
|
|
}
|
|
|