summaryrefslogtreecommitdiff
path: root/tests/test_ports.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_ports.py')
-rw-r--r--tests/test_ports.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/test_ports.py b/tests/test_ports.py
new file mode 100644
index 0000000..c2d1e06
--- /dev/null
+++ b/tests/test_ports.py
@@ -0,0 +1,29 @@
+from hypothesis import given
+from hypothesis.strategies import integers, text
+
+from actinide.ports import *
+
+@given(text(), integers(min_value=1, max_value=2**32 - 1))
+def test_read(input, n):
+ port = string_to_input_port(input)
+ output = read(port, n)
+
+ assert input.startswith(output)
+ assert (len(output) == 0 and len(input) == 0) != (0 < len(output) <= n)
+ assert output + read_fully(port) == input
+
+@given(text(), integers(min_value=1, max_value=2**32 - 1))
+def test_peek(input, n):
+ port = string_to_input_port(input)
+ output = peek(port, n)
+
+ assert input.startswith(output)
+ assert (len(output) == 0 and len(input) == 0) != (0 < len(output) <= n)
+ assert read_fully(port) == input
+
+@given(text(), integers(min_value=1, max_value=2**32 - 1))
+def test_read_fully(input, n):
+ port = string_to_input_port(input)
+ output = read_fully(port)
+
+ assert output == input