Beispiel #1
0
###########################################################

# Check a variety of comparison (with spaces, Capital letters, punctuation)
if len(argv) > 1:
    if argv[1] == 'run_tests':  # argv[1] = first argument after the program name, e.g. py filename.py run_tests

        # source: https://www.getcreditcardnumbers.com/credit-card-generator
        test_data = [
            (1, "4556737586899855", True),   # Lab 20 example
            (2, "4556737586899856", False),  # Lab 20 with check_digit+1
            (3, "378282246310005", True),    # American Express
            (4, "371449635398431", False),   # American Express
            (5, "378734493671000", True),    # American Express Corporate
            (6, "5610591081018250", True),   # Australian BankCard
            (7, "30569309025904", False),    # Diners Club
            (8, "38520000023237", False),   # Diners Club
            (9, "6011111111111117", False), # Discover
            (10, "6011000990139424", False), # Discover
            (11, "3530111333300000", True),  # JCB
            (12, "3566002020360505", True),  # JCB
            (13, "5555555555554444", False), # MasterCard
            (14, "5105105105105100", True),  # MasterCard
            (15, "5392799316110230", True),  # MasterCard
            (16, "4111111111111111", False), # Visa
            (17, "4012888888881881", False), # Visa
        ]

        from lab_functions import unit_tester_1

        print(unit_tester_1(test_data, validate_credit_card))
Beispiel #2
0
    cards = [first_card, second_card, third_card]

    # Print out the current total point value and the advice.

    print(f"\n{play_blackjack(cards)}\n")

###########################################################
### UNIT TESTS ###
###########################################################

# Check a variety of comparison (with spaces, Capital letters, punctuation)
if len(argv) > 1:
    if argv[1] == 'run_tests':  # argv[1] = first argument after the program name, e.g. py filename.py run_tests

        test_data = [
            (1, ['2', '4', '8'], '14 Hit'),  # 14
            (2, ['A', 'A',
                 'A'], '13 Hit'),  # 13, three As (11+1+1) - lines 40-44
            (3, ['A', 'A', '4'], '16 Hit'),  # 16, two As (11+1) - lines 35-39
            (4, ['K', '3', '5'], '18 Stay'),  # 18
            (5, ['J', 'Q',
                 'A'], '21 Blackjack!'),  # 21, one A (1) - lines 30-34
            (6, ['A', '8',
                 '2'], '21 Blackjack!'),  # 21, one A (11) - lines 30-34
            (7, ['9', '7', '6'], '22 Already busted!')  # 22
        ]

        from lab_functions import unit_tester_1

        print(unit_tester_1(test_data, play_blackjack))
Beispiel #3
0
###########################################################

# Check a variety of comparison (with spaces, Capital letters, punctuation)
if len(argv) > 1:
    if argv[1] == 'run_tests':  # argv[1] = first argument after the program name, e.g. py filename.py run_tests

        # Source: https://www.grammarly.com/blog/16-surprisingly-funny-palindromes/
        test_data = [
            (1, 'racecar', True), (2, 'Race car', True),
            (3, 'Race car!', True), (4, 'Taco cat', True),
            (5, 'Yo, banana boy!', True),
            (6, 'Ed, I saw Harpo Marx ram Oprah W. aside.', True),
            (7, 'Do geese see God?', True),
            (8, 'A man, a plan, a canal: Panama.', True),
            (9, 'Straw? No, too stupid a fad; I put soot on warts', True),
            (10, 'A nut for a jar of tuna.', True),
            (11, 'Al lets Della call Ed "Stella."', True),
            (12, 'Al lets Della call Ed “Stella.”', True),
            (13,
             'Are we not pure? "No, sir!" Panama\'s moody Noriega brags. "It is garbage!" Irony dooms a man—a prisoner up to new era.',
             True),
            (14,
             'Are we not pure? “No, sir!” Panama’s moody Noriega brags. “It is garbage!” Irony dooms a man—a prisoner up to new era.',
             True), (15, 'tacacot', False), (16, 'afghha', False),
            (17, 'racecars', False)
        ]

        from lab_functions import unit_tester_1

        print(unit_tester_1(test_data, check_palindrome))