Exemple #1
0
def test_seven_card_deck_twentyfive_optim_notoptim():
    print("\nRUNNING TEST: test_seven_card_deck_twentyfive_optim_notoptim")
    seven_card_deck = ['A', 'B', 'C', 'D', 'E', 'F', 'G']
    # Ensure optimization is off
    xshuffle.set_optimized_shuffling(False)
    shuffled_deck_notoptim = xshuffle.shuffle(seven_card_deck, 25)
    comparable_deck_notoptim = '-'.join(shuffled_deck_notoptim)
    # Turn optimization on
    xshuffle.set_optimized_shuffling(True)
    shuffled_deck_optim = xshuffle.shuffle(seven_card_deck, 25)
    comparable_deck_optim = '-'.join(shuffled_deck_optim)

    assert comparable_deck_optim == comparable_deck_notoptim, \
        'seven_card_deck_twentyfive_optim_notoptim test failed. ' \
            'non-optimized vs. optimized operation should have ' \
            'returned identical decks, but they were different.'

    # Ensure optimization is off
    xshuffle.set_optimized_shuffling(False)
    print("\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ")
Exemple #2
0
def demo_five_card_deck_asciiart_twenty():
    print("\nRUNNING DEMO: demo_five_card_deck_asciiart_twenty")
    deck_of_five_ascii_art_cards = ['####', '-###', '--##', '---#', '----']

    # Demo tests like this set the xshuffle module verbosity on temporarily
    xshuffle.set_verbose(True)
    shuffled_deck = xshuffle.shuffle(deck_of_five_ascii_art_cards, 20)
    if not VERBOSE:  # Restore the VERBOSITY setting of the test file
        xshuffle.set_verbose(False)

    print("\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ")
Exemple #3
0
def test_seven_card_deck_twentyfive_optim_notoptim():
    print("\nRUNNING TEST: test_seven_card_deck_twentyfive_optim_notoptim")
    seven_card_deck = ['A', 'B', 'C', 'D', 'E', 'F', 'G']
    # Ensure optimization is off
    xshuffle.set_optimized_shuffling(False)
    shuffled_deck_notoptim = xshuffle.shuffle(seven_card_deck, 25)
    comparable_deck_notoptim = '-'.join(shuffled_deck_notoptim)
    # Turn optimization on
    xshuffle.set_optimized_shuffling(True)
    shuffled_deck_optim = xshuffle.shuffle(seven_card_deck, 25)
    comparable_deck_optim = '-'.join(shuffled_deck_optim)

    assert comparable_deck_optim == comparable_deck_notoptim, \
        'seven_card_deck_twentyfive_optim_notoptim test failed. ' \
            'non-optimized vs. optimized operation should have ' \
            'returned identical decks, but they were different.'

    # Ensure optimization is off
    xshuffle.set_optimized_shuffling(False)
    print("\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ")
Exemple #4
0
def demo_three_card_deck_asciiart_twenty():
    print("\nRUNNING DEMO: demo_three_card_deck_asciiart_twenty")
    deck_of_three_ascii_art_cards = [
        '##',
        '-#',
        '--'
    ]

    # Demo tests like this set the xshuffle module verbosity on temporarily
    xshuffle.set_verbose(True)
    shuffled_deck = xshuffle.shuffle(deck_of_three_ascii_art_cards, 20)
    if not VERBOSE:  # Restore the VERBOSITY setting of the test file
        xshuffle.set_verbose(False)

    print("\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ")
Exemple #5
0
def test_fifty_two_card_deck_numerical_once():
    print("\nRUNNING TEST: test_fifty_two_card_deck_numerical_once")
    fifty_two_card_deck_numerical = [
        1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
        21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
        39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52
    ]

    # This test only supports 1 round of shuffling.
    shuffled_deck = xshuffle.shuffle(fifty_two_card_deck_numerical, 1)

    known_correct_result_string = '40-8-24-48-32-16-52-44-36-28-' \
        '20-12-4-50-46-42-38-34-30-26-' \
        '22-18-14-10-6-2-51-49-47-45-' \
        '43-41-39-37-35-33-31-29-27-25-' \
        '23-21-19-17-15-13-11-9-7-5-3-1'

    assert ('-'.join(str(item) for item in shuffled_deck)
        == known_correct_result_string), \
        'fifty-two card deck numerical test failed ' \
            '(rounds used: 1)'  # This test only supports 1 round

    print("\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ")
Exemple #6
0
def test_fifty_two_card_deck_numerical_once():
    print("\nRUNNING TEST: test_fifty_two_card_deck_numerical_once")
    fifty_two_card_deck_numerical = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
        11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
        21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
        31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
        41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52]
        
    # This test only supports 1 round of shuffling.
    shuffled_deck = xshuffle.shuffle(fifty_two_card_deck_numerical, 1)

    known_correct_result_string = '40-8-24-48-32-16-52-44-36-28-' \
        '20-12-4-50-46-42-38-34-30-26-' \
        '22-18-14-10-6-2-51-49-47-45-' \
        '43-41-39-37-35-33-31-29-27-25-' \
        '23-21-19-17-15-13-11-9-7-5-3-1'

    assert ('-'.join(str(item) for item in shuffled_deck)
        == known_correct_result_string), \
        'fifty-two card deck numerical test failed ' \
            '(rounds used: 1)'  # This test only supports 1 round

    print("\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ")