"""
Tests for ludology.lattice.
"""

import pytest

from ludology import Game
from ludology.closet import zero, one, star, up, upstar
from ludology.lattice import all_games, companion, is_lonely


def test_all_games_gen_1():
    """
    Test that the games generated by day 1 are correct.
    """
    gen1a = {zero, one, -one, star}
    gen1b = all_games(1)
    assert gen1a == gen1b


def test_all_games_gen_2():
    """
    Test that the correct number of games are crated by day 2.
    """
    gen2 = all_games(2)
    assert len(gen2) == 22


@pytest.mark.parametrize(['g1', 'g2'], [
    (zero, star),
    (one, one),
    (up, -upstar),
    (Game({-1}, {-3}), Game({-1}, {-3})),
])
def test_companion(g1, g2):
    """
    Test companionship.
    """
    assert companion(g1) == g2


@pytest.mark.parametrize('g', [
    one,
    Game({-1}, {-3}),
])
def test_is_lonely(g):
    """
    Test that certain Games are lonely.
    """
    assert is_lonely(g)
