import copy
import pickle

import tcod


def test_tcod_random() -> None:
    rand = tcod.random.Random(tcod.random.COMPLEMENTARY_MULTIPLY_WITH_CARRY)
    assert 0 <= rand.randint(0, 100) <= 100
    assert 0 <= rand.uniform(0, 100) <= 100
    rand.guass(0, 1)
    rand.inverse_guass(0, 1)


def test_tcod_random_copy() -> None:
    rand = tcod.random.Random(tcod.random.MERSENNE_TWISTER)
    rand2 = copy.copy(rand)
    assert rand.uniform(0, 1) == rand2.uniform(0, 1)
    assert rand.uniform(0, 1) == rand2.uniform(0, 1)
    assert rand.uniform(0, 1) == rand2.uniform(0, 1)


def test_tcod_random_pickle() -> None:
    rand = tcod.random.Random(tcod.random.MERSENNE_TWISTER)
    rand2 = pickle.loads(pickle.dumps(rand))
    assert rand.uniform(0, 1) == rand2.uniform(0, 1)
    assert rand.uniform(0, 1) == rand2.uniform(0, 1)
    assert rand.uniform(0, 1) == rand2.uniform(0, 1)

[((8, 11, 8, 76), 'tcod.random.Random', 'tcod.random.Random', ({(8, 30, 8, 75): 'tcod.random.COMPLEMENTARY_MULTIPLY_WITH_CARRY'}, {}), '(tcod.random.COMPLEMENTARY_MULTIPLY_WITH_CARRY)', False, 'import tcod\n'), ((16, 11, 16, 59), 'tcod.random.Random', 'tcod.random.Random', ({(16, 30, 16, 58): 'tcod.random.MERSENNE_TWISTER'}, {}), '(tcod.random.MERSENNE_TWISTER)', False, 'import tcod\n'), ((17, 12, 17, 27), 'copy.copy', 'copy.copy', ({(17, 22, 17, 26): 'rand'}, {}), '(rand)', False, 'import copy\n'), ((24, 11, 24, 59), 'tcod.random.Random', 'tcod.random.Random', ({(24, 30, 24, 58): 'tcod.random.MERSENNE_TWISTER'}, {}), '(tcod.random.MERSENNE_TWISTER)', False, 'import tcod\n'), ((25, 25, 25, 43), 'pickle.dumps', 'pickle.dumps', ({(25, 38, 25, 42): 'rand'}, {}), '(rand)', False, 'import pickle\n')]