Exemple #1
0
def test_partial_matches():
    e = Engine()
    e._Engine__code = [1, 2, 3, 4]
    test_validate("Testing partial matches with 1 match", 1, e._Engine__get_partial_matches([1, 4, 3, 3]))
    test_validate("Testing partial matches with 2 matches", 2, e._Engine__get_partial_matches([1, 4, 3, 2]))
    test_validate("Testing partial matches with 3 matches", 3, e._Engine__get_partial_matches([3, 4, 0, 2]))
    test_validate("Testing partial matches with 4 matches", 4, e._Engine__get_partial_matches([3, 4, 1, 2]))
Exemple #2
0
def test_game_iterate_lose():
    e = Engine()
    e._Engine__code = [1, 2, 3, 4]
    e._Engine__rows = 4
    res = e._Engine__game_iterate([4, 3, 2, 1])
    test_validate("Testing full matches at 1st lose iteration", 0, res["full_matches"])
    test_validate("Testing partial matches at 1st lose iteration", 4, res["partial_matches"])
    test_validate("Testing game over at 1st lose iteration", False, e._Engine__game_over)
    test_validate("Testing win at 1st lose iteration", False, e._Engine__win)
    test_validate("Testing game row at 1st lose iteration", 1, e._Engine__crt_row)
    res = e._Engine__game_iterate([0, 3, 1, 2])
    test_validate("Testing full matches at 2nd lose iteration", 0, res["full_matches"])
    test_validate("Testing partial matches at 2nd lose iteration", 3, res["partial_matches"])
    test_validate("Testing game over at 2nd lose iteration", False, e._Engine__game_over)
    test_validate("Testing win at 2nd lose iteration", False, e._Engine__win)
    test_validate("Testing game row at 2nd lose iteration", 2, e._Engine__crt_row)
    res = e._Engine__game_iterate([1, 2, 2, 3])
    test_validate("Testing full matches at 3rd lose iteration", 2, res["full_matches"])
    test_validate("Testing partial matches at 3rd lose iteration", 1, res["partial_matches"])
    test_validate("Testing game over at 3rd lose iteration", False, e._Engine__game_over)
    test_validate("Testing win at 3rd lose iteration", False, e._Engine__win)
    test_validate("Testing game row at 3rd lose iteration", 3, e._Engine__crt_row)
    res = e._Engine__game_iterate([1, 2, 3, 0])
    test_validate("Testing full matches at 4th lose iteration", 3, res["full_matches"])
    test_validate("Testing partial matches at 4th lose iteration", 0, res["partial_matches"])
    test_validate("Testing game over at 4th lose iteration", True, e._Engine__game_over)
    test_validate("Testing win at 4th lose iteration", False, e._Engine__win)
    test_validate("Testing game row at 4th lose iteration", 4, e._Engine__crt_row)
Exemple #3
0
def test_full_matches():
    e = Engine()
    e._Engine__code = [1, 2, 3, 4]
    test_validate("Testing full matches with 1 match", 1, e._Engine__get_full_matches([1, 3, 2, 5]))
    test_validate("Testing full matches with 2 matches", 2, e._Engine__get_full_matches([1, 3, 3, 5]))
    test_validate("Testing full matches with 3 matches", 3, e._Engine__get_full_matches([1, 3, 3, 4]))
    test_validate("Testing full matches with 4 matches", 4, e._Engine__get_full_matches([1, 2, 3, 4]))
Exemple #4
0
def test_valid_pegs():
    e = Engine()
    e._Engine__variations = 50
    e._Engine__code = [0, 1, 2, 3]
    test_validate("Testing validate pegs with an array too short", True, e._Engine__validate_and_return_pegs("0 1 2") is None)
    test_validate("Testing validate pegs with an array too long", True, e._Engine__validate_and_return_pegs("0 1 2 3 4") is None)
    test_validate("Testing validate pegs with an invalid char", True, e._Engine__validate_and_return_pegs("0 1 2 a") is None)
    test_validate("Testing validate pegs with a negative number", True, e._Engine__validate_and_return_pegs("0 1 2 -1") is None)
    test_validate("Testing validate pegs with a number too large", True, e._Engine__validate_and_return_pegs("0 1 2 50") is None)
    test_validate("Testing validate pegs with a valid input", True, e._Engine__validate_and_return_pegs("0 1 2 49") is not None)