def test_add():
    """
    Function to test the add function in Program class.
    Tests ALL THE INT between 1 and 200. Every possibility is tested.
    :attrib num_1, num_2 and num_3 has a for loop in range(1,201)
    The for loop will represent each number from 1 to 200 which will allow
    this test to test all the possibilites from 1 to 200.
    :attrib summation is the sum of num_1 + num_2 + num_3,
    and is considered the return value
    """
    for num_1 in range(1, 201):
        for num_2 in range(1, 201):
            for num_3 in range(1, 201):
                summation = num_1 + num_2 + num_3
                assert add(num_1, num_2, num_3) == summation
Пример #2
0
def test_add_nothing():
    assert add(',2') == 2
Пример #3
0
def test_add():
    assert add('2,2') == 4
Пример #4
0
def test_negatives():
    with pytest.raises(ValueError) as ve:
        add('5, 9, -2, 9, -32')
    assert 'Negative' in str(ve.value)
Пример #5
0
def test_multiple_delimeters():
    assert add("//[*][%]\n1*2%3") == 6
Пример #6
0
def test_add_greater_than_thousand():
    assert add('5, 3000 \n 5') == 10
Пример #7
0
 def test_add(self):
     assert add(1, 1) == 2
Пример #8
0
import program
import time
import sys

DIFFICULTY = 'eazy'

if __name__ == '__main__':
    if len(sys.argv) > 1:
        DIFFICULTY = sys.argv[1]
    fo = open(DIFFICULTY + '.txt', "r+")
    ans = open("ans_" + DIFFICULTY + '.txt', "w")
    data = fo.readlines()
    t1 = time.time()
    for line in data:
        words = line.split(' ')
        action = words[0]
        if action == 'Add':
            program.add(int(words[1]), int(words[2]))
        elif action == 'Sub':
            program.sub(int(words[1]), int(words[2]))
        elif action == 'Query':
            ans.write(str(program.query(int(words[1]), int(words[2]))) + '\n')

    t2 = time.time()
    print("耗时%fs" % (t2 - t1))

    fo.close()
    ans.close()