예제 #1
0
def root_9_001():
    """Ensures Newton is returning the specified value for 9.0 3.0 0.01"""
    check50_java.run("Newton 9.0 3.0 0.01").stdout("1\n3.0").exit()
예제 #2
0
def test8():
    """identifies 369421438430814 as INVALID"""
    check50_java.run("Credit").stdin("369421438430814").stdout(
        "INVALID\n").stdout(check50.EOF).exit(0)
예제 #3
0
def test10():
    """identifies 5673598276138003 as INVALID"""
    check50_java.run("Credit").stdin("5673598276138003").stdout(
        "INVALID\n").stdout(check50.EOF).exit(0)
예제 #4
0
def test4():
    """identifies 5105105105105100 as MASTERCARD"""
    check50_java.run("Credit").stdin("5105105105105100").stdout(
        "MASTERCARD\n").stdout(check50.EOF).exit(0)
예제 #5
0
def test6():
    """identifies 4012888888881881 as VISA"""
    check50_java.run("Credit").stdin("4012888888881881").stdout(
        "VISA\n").stdout(check50.EOF).exit(0)
예제 #6
0
def test_reject_empty():
    """rejects a non-numeric input of "" """
    check50_java.run("Credit").stdin("").reject()
예제 #7
0
def test2():
    """identifies 371449635398431 as AMEX"""
    check50_java.run("Credit").stdin("371449635398431").stdout(
        "AMEX\n").stdout(check50.EOF).exit(0)
예제 #8
0
def caesar_one_arg():
    """See if we get the right error message whe run with a single argument"""
    out = "Too few parameters!\nUsage: java Caesar n \"cipher text\"\s*"
    check50_java.run("Caesar 3").stdout(out, regex=True)
예제 #9
0
def caesar_first_example():
    """See if we get the right output for the first example and a shift of 3"""
    inp = "The ships hung in the sky in much the same way that bricks don't."
    out = r'Wkh vklsv kxqj lq wkh vnb lq pxfk wkh vdph zdb wkdw eulfnv grq\'w.\s*'
    check50_java.run("Caesar 3 \"" + inp + "\"").stdout(out, regex=True)
예제 #10
0
def check_brutus_first_example():
    """See if we get the right output for the first example"""
    inp = "Vg vf n zvfgnxr gb guvax lbh pna fbyir nal znwbe ceboyrzf whfg jvgu cbgngbrf."
    out = "It is a mistake to think you can solve any major problems just with potatoes.\s*"
    check50_java.run("Brutus \"" + inp + "\"").stdout(out, regex=True)
예제 #11
0
def caesar_many_args():
    """See if we get the right error message whe run with too many arguments"""
    out = "Too many parameters!\s*\n\s*Usage: java Caesar n \"cipher text\"\s*"
    check50_java.run(
        "Caesar 13 The ships hung in the sky in much the same way that bricks dont."
    ).stdout(out, regex=True)
예제 #12
0
def too_many_parameters():
    """Ensures Newton is returning the correct error message for 25 0 3 4"""
    expected = "Incorrect Number of Parameters\nUsage: java Newton number guess epsilon\n"
    actual = check50_java.run("Newton 25 0 3 4").stdout()
    if expected != actual:
        raise check50.Mismatch(expected, actual)
예제 #13
0
def root_inf_00001():
    """Ensures Newton is returning the correct (but incorrect) value for 25 0 0.00001"""
    check50_java.run("Newton 25 0 0.00001").stdout("3\nInfinity").exit()
예제 #14
0
def root_25_0001():
    """Ensures Newton is returning the specified value for 25 0.1 0.0001"""
    check50_java.run("Newton 25 0.1 0.0001").stdout("11\n5.0").exit()
예제 #15
0
def test8_400_54_9000():
    """Ensures Largest is returning the specified value for [8, 400, 54, 9000]"""
    check50_java.run("Largest").stdin("4").stdin("8").stdin("400").stdin(
        "54").stdin("9000").stdout("9000\n").exit()
예제 #16
0
def test523_6384_3929_12837_3():
    """Ensures Largest is returning the specified value for [523, 6384, 3929, 12837, 3]"""
    check50_java.run("Largest").stdin("5").stdin("523").stdin("6384").stdin(
        "3929").stdin("12837").stdin("3").stdout("12837\n").exit()
예제 #17
0
def test_reject_foo():
    """rejects a non-numeric input of "foo" """
    check50_java.run("Credit").stdin("foo").reject()
예제 #18
0
def CShantyPrintsThree():
    """Ensures CShanty is printing thrice"""
    check50_java.run("CShanty").stdin("3").stdout(
        "Soon may the compiler come,\nTo bring class files and exceptions\nSoon may the compiler come,\nTo bring class files and exceptions\nSoon may the compiler come,\nTo bring class files and exceptions\nHigh level languages earn my rum\nBut my first love is the C!\n"
    ).exit()
예제 #19
0
def test1():
    """identifies 378282246310005 as AMEX"""
    check50_java.run("Credit").stdin("378282246310005").stdout(
        "AMEX\n").stdout(check50.EOF).exit(0)
예제 #20
0
def factorialFour():
    """Ensures Factorial is printing 4!"""
    check50_java.run("Factorial").stdin("4").stdout("24\n").exit()
예제 #21
0
def test3():
    """identifies 5555555555554444 as MASTERCARD"""
    check50_java.run("Credit").stdin("5555555555554444").stdout(
        "MASTERCARD\n").stdout(check50.EOF).exit(0)
예제 #22
0
def factorialTen():
    """Ensures Factorial is printing 10!"""
    check50_java.run("Factorial").stdin("10").stdout("3628800\n").exit()
예제 #23
0
def test5():
    """identifies 4111111111111111 as VISA"""
    check50_java.run("Credit").stdin("4111111111111111").stdout(
        "VISA\n").stdout(check50.EOF).exit(0)
예제 #24
0
def factorialThirteen():
    """Ensures Factorial is printing 13!"""
    check50_java.run("Factorial").stdin("13").stdout("6227020800\n").exit()
예제 #25
0
def test7():
    """identifies 1234567890 as INVALID"""
    check50_java.run("Credit").stdin("1234567890").stdout("INVALID\n").stdout(
        check50.EOF).exit(0)
예제 #26
0
def factorialNineteen():
    """Ensures Factorial is printing 19!"""
    check50_java.run("Factorial").stdin("19").stdout(
        "121645100408832000\n").exit()
예제 #27
0
def test9():
    """identifies 4062901840 as INVALID"""
    check50_java.run("Credit").stdin("4062901840").stdout("INVALID\n").stdout(
        check50.EOF).exit(0)
예제 #28
0
def test315():
    """Ensures Largest is returning the specified value for [3, 1, 5]"""
    check50_java.run("Largest").stdin("3").stdin("3").stdin("2").stdin(
        "5").stdout("5\n").exit()
예제 #29
0
def test11():
    """identifies 4111111111111113 as INVALID"""
    check50_java.run("Credit").stdin("4111111111111113").stdout(
        "INVALID\n").stdout(check50.EOF).exit(0)
예제 #30
0
def root_2():
    """Ensures LeapYear is returning the specified value for 2.0 1.0"""
    check50_java.run("Newton 2.0 1.0").stdout("6\n1.414213562373095").exit()