From ad80ad44cdc65c814dccbfb841bf217af05d6353 Mon Sep 17 00:00:00 2001 From: Oleg Skinderev <> Date: Fri, 24 Mar 2023 19:34:32 +0300 Subject: [PATCH] add new task --- tests/test_s01_sum_of_two_numbers.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/test_s01_sum_of_two_numbers.py diff --git a/tests/test_s01_sum_of_two_numbers.py b/tests/test_s01_sum_of_two_numbers.py new file mode 100644 index 0000000..cda233b --- /dev/null +++ b/tests/test_s01_sum_of_two_numbers.py @@ -0,0 +1,18 @@ +from hypothesis import given +from hypothesis.strategies import integers +from subprocess import Popen, PIPE + + +# TODO: поменять на правильный вызов бинаря +def sum_two_int64(x, y): + p = Popen(['python3', 'main.py'], stdout=PIPE, stdin=PIPE) + stdout, stderr = p.communicate(input=f'{x} {y}\n'.encode()) + return int(stdout.strip()) + + +BOUND = 2**16 + + +@given(integers(min_value=-BOUND, max_value=BOUND-1), integers(min_value=-BOUND, max_value=BOUND-1)) +def test_sum(x, y): + assert x + y == sum_two_int64(x, y)