from game2048.grid_2048 import *
from pytest import *

def test_create_grid():
    assert create_grid(4)==[[' ',' ',' ',' '],[' ',' ',' ',' '],[' ',' ',' ',' '],[' ',' ',' ',' ']]
    assert create_grid(5)==[[' ',' ',' ',' ',' '],[' ',' ',' ',' ',' '],[' ',' ',' ',' ',' '],[' ',' ',' ',' ',' '],[' ',' ',' ',' ',' ']]
    assert create_grid(1)==[[' ']]
    assert create_grid(2)==[[' ',' '],[' ',' ']]

def test_add_new_tile_at_position():
    game_grid=create_grid(4)
    assert add_new_tile_at_position(game_grid,1,1,2)==[[' ',' ',' ', ' '],[' ', 2 ,' ', ' '],[' ',' ',' ', ' '],[' ',' ',' ', ' ']]
    game_grid=create_grid(4)
    assert add_new_tile_at_position(game_grid,2,1,4)==[[' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], [' ', 4, ' ', ' '], [' ', ' ', ' ', ' ']]
    game_grid=create_grid(4)
    assert add_new_tile_at_position(game_grid,3,0,2)==[[' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], [' ',' ', ' ', ' '], [2, ' ', ' ', ' ']]
    game_grid=create_grid(4)
    value=choose_value_new_tile()
    game_grid=add_new_tile_at_position(game_grid,1,1,value)
    tiles=get_all_tiles(game_grid)
    assert 2 or 4 in tiles