Skip to content

Commit

Permalink
Add tests for issue #55
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderWells-diamond committed Jan 13, 2022
1 parent 4cbdb94 commit 98de8f6
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/test_records.py
Expand Up @@ -85,7 +85,31 @@ def test_DISP_can_be_overridden():
# Note: DISP attribute won't exist if field not specified
assert record.DISP.Value() == 0

def test_waveform_disallows_zero_length(clear_records):
"""Test that WaveformIn/Out records throw an exception when being
initialized with a zero length array"""
with pytest.raises(AssertionError):
builder.WaveformIn("W_IN", [])
with pytest.raises(AssertionError):
builder.WaveformOut("W_OUT", [])

def test_waveform_disallows_too_long_values(clear_records):
"""Test that Waveform and longString records throw an exception when
an overlong value is written"""
w_in = builder.WaveformIn("W_IN", [1, 2, 3])
w_out = builder.WaveformOut("W_OUT", [1, 2, 3])

ls_in = builder.longStringIn("LS_IN", initial_value="ABC")
ls_out = builder.longStringOut("LS_OUT", initial_value="ABC")

with pytest.raises(AssertionError):
w_in.set([1, 2, 3, 4])
with pytest.raises(AssertionError):
w_out.set([1, 2, 3, 4])
with pytest.raises(AssertionError):
ls_in.set("ABCD")
with pytest.raises(AssertionError):
ls_out.set("ABCD")

def validate_fixture_names(params):
"""Provide nice names for the out_records fixture in TestValidate class"""
Expand Down

0 comments on commit 98de8f6

Please sign in to comment.