/
Mihaham
/
Table-Time
Обзор
Документация
Войти
/
Mihaham
/
Table-Time
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
services/api/tests/test_shared_grid.py
57 строк
1 KB
MihahamYT
feat: full game catalog — 46 plugins, docs nav, web UI kit
14 июн 2026, 12:43
14 июн 2026, 12:43
2cd5f50
Код
Авторство
О чём код?
"""Tests for shared grid module.""" from app.plugins.shared.grid import ( check_line_win, count_tokens, empty_grid, in_bounds, neighbors4, ) def test_empty_grid(): g = empty_grid(3, 4, None) assert len(g) == 3 assert len(g[0]) == 4 assert all(cell is None for row in g for cell in row) def test_in_bounds(): assert in_bounds(0, 0, 3, 3) assert not in_bounds(-1, 0, 3, 3) assert not in_bounds(3, 0, 3, 3) def test_neighbors4(): n = neighbors4(1, 1, 3, 3) assert set(n) == {(0, 1), (2, 1), (1, 0), (1, 2)} def test_neighbors4_corner(): n = neighbors4(0, 0, 3, 3) assert set(n) == {(0, 1), (1, 0)} def test_check_line_win_horizontal(): board = [["p1", "p1", "p1"], [None, None, None], [None, None, None]] assert check_line_win(board, "p1", 3) def test_check_line_win_diagonal(): board = [["p1", None, None], [None, "p1", None], [None, None, "p1"]] assert check_line_win(board, "p1", 3) def test_check_line_win_no_win(): board = [["p1", "p2", "p1"], [None, None, None], [None, None, None]] assert not check_line_win(board, "p1", 3) def test_check_line_win_empty(): assert not check_line_win([], "p1") def test_count_tokens(): board = [["p1", "p2"], ["p1", None]] assert count_tokens(board, "p1") == 2 assert count_tokens(board, "p2") == 1