-
Notifications
You must be signed in to change notification settings - Fork 0
/
pick_one.py
32 lines (24 loc) · 978 Bytes
/
pick_one.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
from UnitaryTest.test_tools import TestTools
# Takes three inputs: a Boolean and two other values.
# If the first input is True, it should return the second input.
# If the first input is False, it should return the third input.
#
# For example, pick_one(True, 37, 'hello') will return 37, and
# pick_one(False, 37, 'hello') will return 'hello'.
def pick_one(boolean, second_value, third_value):
if boolean:
return second_value
return third_value
def main():
t = TestTools()
t.new_test(func=pick_one)
t.evaluate_result(pick_one(True, 37, 'hello'), expected=37)
t.new_test(func=pick_one)
t.evaluate_result(pick_one(False, 37, 'hello'), expected='hello')
t.new_test(func=pick_one)
t.evaluate_result(pick_one(True, 'red pill', 'blue pill'), expected='red pill')
t.new_test(func=pick_one)
t.evaluate_result(pick_one(False, 'sunny', 'rainy'),expected='rainy')
print("hello")
if __name__ == '__main__':
main()