#include "../src/logic/Board.h"
#include <gtest/gtest.h>

using logic::Board;

TEST(BoardTests, InitiallyEmpty)
{
    Board b;
    for (int y = 0; y < Board::Height; ++y)
        for (int x = 0; x < Board::Width; ++x)
            EXPECT_EQ(b.at(x, y), Board::Cell::Empty);
}

TEST(BoardTests, ClearSingleFullLine)
{
    Board b;
    int y = Board::Height - 1;
    for (int x = 0; x < Board::Width; ++x) b.set(x, y, Board::Cell::Filled);
    int cleared = b.clearFullLines();
    EXPECT_EQ(cleared, 1);
    for (int x = 0; x < Board::Width; ++x) EXPECT_EQ(b.at(x, Board::Height - 1), Board::Cell::Empty);
}

TEST(BoardTests, ClearTwoNonAdjacentLines)
{
    Board b;
    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); }
    int cleared = b.clearFullLines();
    EXPECT_EQ(cleared, 2);
}

int main(int argc, char** argv)
{
    ::testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}
