aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEugeniy E. Mikhailov <evgmik@gmail.com>2024-06-18 00:05:08 -0400
committerEugeniy E. Mikhailov <evgmik@gmail.com>2024-06-18 00:05:08 -0400
commit0230dc92c978c43ad452024047295e4b91943520 (patch)
treeb2b277803d3bbf7d63749d1bfd52265c6e0c10be /tests
parentc4afe448d31025f51148a74ae8a91be57338b826 (diff)
downloadqolab-0230dc92c978c43ad452024047295e4b91943520.tar.gz
qolab-0230dc92c978c43ad452024047295e4b91943520.zip
added test for response2numStr
Diffstat (limited to 'tests')
-rw-r--r--tests/test_response2numStr.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_response2numStr.py b/tests/test_response2numStr.py
new file mode 100644
index 0000000..bd41983
--- /dev/null
+++ b/tests/test_response2numStr.py
@@ -0,0 +1,20 @@
+import pytest
+from qolab.hardware.scpi import response2numStr
+
+def test_separator_and_unit():
+ assert response2numStr('TDIV 2.00E-08S', firstSeparator=' ', unit='Z') == ('TDIV', '2.00E-08S', None) # incorrect unit was specified
+ assert response2numStr('TDIV 2.00E-08S', firstSeparator=' ', unit='S') == ('TDIV', '2.00E-08', 'S')
+ assert response2numStr('TDIV,2.00E-08S', firstSeparator=',', unit='S') == ('TDIV', '2.00E-08', 'S')
+
+def test_separator_and_empty_unit():
+ assert response2numStr('TDIV,2.00E-08', firstSeparator=',', unit=None) == ('TDIV', '2.00E-08', None)
+ assert response2numStr('TDIV,2.00E-08', firstSeparator=',', unit='') == ('TDIV', '2.00E-08', '')
+
+def test_no_separator_with_unit():
+ assert response2numStr('2.00E-08S', firstSeparator=None, unit='S') == (None, '2.00E-08', 'S')
+ assert response2numStr('2.00E-08S', firstSeparator='', unit='S') == (None, '2.00E-08', 'S')
+
+def test_no_separator_and_no_unit():
+ assert response2numStr('2.00E-08', firstSeparator=None, unit=None) == (None, '2.00E-08', None)
+ assert response2numStr('2.00E-08', firstSeparator='', unit='') == (None, '2.00E-08', '')
+