コード例 #1
0
ファイル: a1test.py プロジェクト: peteroh23/Python_CS1110
def testD():
    "test procedure for part D"

    # Test is_currency
    cornell.assert_equals(True, a1.iscurrency('USD'))
    cornell.assert_equals(True, a1.iscurrency('SAR'))
    cornell.assert_equals(False, a1.iscurrency('   '))
    cornell.assert_equals(False, a1.iscurrency('sar'))

    #Test Exchange
    cornell.assert_floats_equal(112.518, a1.exchange('USD', 'SAR', 30))
def test_asserts():
    """
    This is a simple test procedure to help you understand how assert works
    """
    print('Testing the cornell asserts')
    cornell.assert_equals('b c', 'ab cd'[1:4])
    #cornell.assert_equals('b c', 'ab cd'[1:3])     # UNCOMMENT ONLY WHEN DIRECTED
    
    cornell.assert_true(3 < 4)
    cornell.assert_equals(3, 1+2)
    
    cornell.assert_equals(3.0, 1.0+2.0)
    cornell.assert_floats_equal(6.3, 3.1+3.2)
コード例 #3
0
def testD():
    """Test procedure for functions iscurrency and exchange"""
    #Test case for valid iscurrency
    result24 = a1.iscurrency('USD')
    cornell.assert_equals = (True, result24)
    
    #test case for invalid iscurrency
    result25 = a1.iscurrency('AAA')
    cornell.assert_equals = (False, result25)
    
    #Test case for invalid iscurrency
    result26 = a1.iscurrency('usd')
    cornell.assert_equals = (False, result26)

    #Test case for valid exchange
    result27 = a1.exchange('USD','HKD',1.0)
    cornell.assert_floats_equal(7.82541, result27)
コード例 #4
0
def testD():
    """Test procedure for Part A"""
    result = a1.iscurrency('USD')
    cornell.assert_true(True)
    result = a1.iscurrency('')
    cornell.assert_equals(False, result)
    result = a1.iscurrency('E')
    cornell.assert_equals(False, result)
    result = a1.iscurrency('zxcvbn')
    cornell.assert_equals(False, result)

    result = a1.exchange('USD', 'EUR', 2.5)
    cornell.assert_floats_equal(2.0952375, result)
    result = a1.exchange('SVC', 'GEL', 3.5254023347401)
    cornell.assert_floats_equal(1, result)
    result = a1.exchange('USD', 'EUR', 3)
    cornell.assert_floats_equal(2.514285, result)