forked from pcewebpython/streams-exercise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.py
80 lines (58 loc) · 2.11 KB
/
tests.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
"""
streams-exercise.tests.py
This file is intentionally written without the benefit of the Python
unittest library. This can be used to demonstrate in-class that unit testing
is a simple concept which benefits from the use of a library, but does not
require it.
Run with `python tests.py`. The return code will be the number of test FAILURES.
"""
import io
from stream_exercise import StreamProcessor
FAILURES = 0
VALUE = "234761640930110349378289194"
EXPECTED = 5
my_stream_processor = StreamProcessor(io.StringIO(VALUE))
RESULT = my_stream_processor.process()
success = RESULT == EXPECTED
FAILURES += (not success)
MESSAGE = "Testing \"{}\", EXPECTED {} got {}. ".format(VALUE, EXPECTED, RESULT)
MESSAGE += "SUCCESS" if success else "FAILURE"
print(MESSAGE)
VALUE = "03050403020309060707070708"
EXPECTED = 10
my_stream_processor = StreamProcessor(io.StringIO(VALUE))
RESULT = my_stream_processor.process()
success = RESULT == EXPECTED
FAILURES += (not success)
MESSAGE = "Testing \"{}\", EXPECTED {} got {}. ".format(VALUE, EXPECTED, RESULT)
MESSAGE += "SUCCESS" if success else "FAILURE"
print(MESSAGE)
VALUE = "3"
EXPECTED = 0
my_stream_processor = StreamProcessor(io.StringIO(VALUE))
RESULT = my_stream_processor.process()
success = RESULT == EXPECTED
FAILURES += (not success)
MESSAGE = "Testing \"{}\", EXPECTED {} got {}. ".format(VALUE, EXPECTED, RESULT)
MESSAGE += "SUCCESS" if success else "FAILURE"
print(MESSAGE)
VALUE = "2347"
EXPECTED = 2
my_stream_processor = StreamProcessor(io.StringIO(VALUE))
RESULT = my_stream_processor.process()
success = RESULT == EXPECTED
FAILURES += (not success)
MESSAGE = "Testing \"{}\", EXPECTED {} got {}. ".format(VALUE, EXPECTED, RESULT)
MESSAGE += "SUCCESS" if success else "FAILURE"
print(MESSAGE)
VALUE = "23478"
EXPECTED = 2
my_stream_processor = StreamProcessor(io.StringIO(VALUE))
RESULT = my_stream_processor.process()
success = RESULT == EXPECTED
FAILURES += (not success)
MESSAGE = "Testing \"{}\", EXPECTED {} got {}. ".format(VALUE, EXPECTED, RESULT)
MESSAGE += "SUCCESS" if success else "FAILURE"
print(MESSAGE)
print("\n\nTest FAILURES: {} ".format(FAILURES))
exit(FAILURES)