summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHartmut Goebel <h.goebel@crazy-compilers.com>2019-01-19 21:50:07 +0100
committerHartmut Goebel <h.goebel@crazy-compilers.com>2019-01-19 21:50:07 +0100
commit7bff5380fb22fa27eecd09d3a2e37d9fc085246c (patch)
tree9c4b12ea71518d292ac9aadc330a209e9ed7bc8b
parent5759c1f7ceff3d1ff6da06cf86d129623ce0512e (diff)
Add test-cases for strings.data_to_string and string_to_data.
-rw-r--r--tests/unit/test_strings.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/unit/test_strings.py b/tests/unit/test_strings.py
index a0b5617..835a508 100644
--- a/tests/unit/test_strings.py
+++ b/tests/unit/test_strings.py
@@ -23,10 +23,28 @@ def test_string_to_absolute_time(datestr, expected):
dt = strings.string_to_absolute_time(datestr)
assert dt.timetuple()[:6] == expected
+
def test_string_to_absolute_time_end_of_time():
assert strings.string_to_absolute_time("end of time") is None
+
def test_string_to_absolute_invalid():
with pytest.raises(ValueError) as excinfo:
strings.string_to_absolute_time("asdfgh")
assert str(excinfo.value).startswith("asdfgh is not a properly formatted")
+
+
+def test_data_to_string():
+ assert strings.data_to_string(b"") == ""
+ assert strings.data_to_string(b"dfgzu") == "CHJ6EUJL"
+
+
+def test_string_to_data():
+ assert strings.string_to_data("") == b""
+ assert strings.string_to_data("CHJ6EUJL") == b"dfgzu"
+ with pytest.raises(ValueError) as excinfo:
+ strings.string_to_data("asdfgh")
+ assert "is not a valid data-encoding string" in str(excinfo.value)
+ with pytest.raises(ValueError) as excinfo:
+ strings.string_to_data(["asdfgh"])
+ assert "is not a valid data-encoding string" in str(excinfo.value)