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:
31
tests/test_board.cpp
Normal file
31
tests/test_board.cpp
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user