/
test_calc.py
90 lines (68 loc) · 1.29 KB
/
test_calc.py
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
from calc import Calc
def test_input():
c = Calc()
c.update( '1' )
c.update( '2' )
c.update( '3' )
s = str( c.result() )
assert s == '123.0'
def test_input2():
c = Calc()
c.update( '1' )
c.update( '2' )
c.update( '3' )
c.update( '*' )
c.update( '3' )
c.update( '2' )
c.update( '1' )
s = str( c.result() )
assert s == str( 321.0 )
def test_input3():
c = Calc()
c.update( '1' )
c.update( '2' )
c.update( '3' )
c.update( '*' )
c.update( '3' )
c.update( '2' )
c.update( '1' )
c.update( '=' )
c.update( 'C' )
s = str( c.result() )
assert s == str( 0.0 )
def test_mul():
c = Calc()
c.update( '1' )
c.update( '2' )
c.update( '3' )
c.update( '*' )
c.update( '3' )
c.update( '2' )
c.update( '1' )
c.update( '=' )
s = str( c.result() )
assert s == str( 123 * 321.0 )
def test_status1():
c = Calc()
c.reset( 144 )
c.update( '1' )
c.update( '2' )
c.update( '*' )
res = c.status()
s = str( res[0] )
episode_stat = res[1]
total_reward = res[2]
print( s )
assert s == str( 12.0 )
assert episode_stat == False
assert total_reward == 0.0
c.update( '1' )
c.update( '2' )
c.update( '=' )
res = c.status()
s = str( res[0] )
episode_stat = res[1]
total_reward = res[2]
assert s == str( 144.0 )
assert episode_stat == True
assert total_reward == 1.0