Scaffold the pure game model

- Added a pure, SDL-free Board model implementing grid access and clearFullLines().
- Added a small standalone test at test_board.cpp (simple assert-based; not yet wired into CMake).
This commit is contained in:
2025-12-25 10:15:23 +01:00
parent 5fd3febd8e
commit b1f2033880
3 changed files with 122 additions and 0 deletions

31
tests/test_board.cpp Normal file
View File

@ -0,0 +1,31 @@
#include "../src/logic/Board.h"
#include <cassert>
#include <iostream>
int main()
{
using logic::Board;
Board b;
// board starts empty
for (int y = 0; y < Board::Height; ++y)
for (int x = 0; x < Board::Width; ++x)
assert(b.at(x,y) == Board::Cell::Empty);
// fill a single full row at bottom
int y = Board::Height - 1;
for (int x = 0; x < Board::Width; ++x) b.set(x, y, Board::Cell::Filled);
int cleared = b.clearFullLines();
assert(cleared == 1);
// bottom row should be empty after clear
for (int x = 0; x < Board::Width; ++x) assert(b.at(x, Board::Height - 1) == Board::Cell::Empty);
// fill two non-adjacent rows and verify both clear
int y1 = Board::Height - 1;
int y2 = Board::Height - 3;
for (int x = 0; x < Board::Width; ++x) { b.set(x, y1, Board::Cell::Filled); b.set(x, y2, Board::Cell::Filled); }
cleared = b.clearFullLines();
assert(cleared == 2);
std::cout << "tests/test_board: all assertions passed\n";
return 0;
}