Skip to content

Commit

Permalink
Add test for issue #37
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderWells-diamond committed Feb 3, 2022
1 parent 5f14ca3 commit 40175f2
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/test_record_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ def test_long_string_rejects_overlong_strings(self):
lso = builder.longStringIn("LSTROUT2", length=WAVEFORM_LENGTH)
lso.set(OVERLONG_STR)

# And a different way to initialise the records to trigger same behaviour:
# And a different way to initialise records to trigger same behaviour:
with pytest.raises(AssertionError):
lsi = builder.longStringIn("LSTRIN3", initial_value="ABC")
lsi.set(OVERLONG_STR)
Expand Down
38 changes: 38 additions & 0 deletions tests/test_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,44 @@ def test_DISP_can_be_overridden():
# Note: DISP attribute won't exist if field not specified
assert record.DISP.Value() == 0


def test_waveform_construction():
"""Test the various ways to construct a Waveform records all produce
correct results"""

wi = builder.WaveformIn("WI1", [1, 2, 3])
assert wi.NELM.Value() == 3

wi = builder.WaveformIn("WI2", initial_value=[1, 2, 3, 4])
assert wi.NELM.Value() == 4

wi = builder.WaveformIn("WI3", length=5)
assert wi.NELM.Value() == 5

wi = builder.WaveformIn("WI4", NELM=6)
assert wi.NELM.Value() == 6

wi = builder.WaveformIn("WI5", [1, 2, 3], length=7)
assert wi.NELM.Value() == 7

wi = builder.WaveformIn("WI6", initial_value=[1, 2, 3], length=8)
assert wi.NELM.Value() == 8

wi = builder.WaveformIn("WI7", [1, 2, 3], NELM=9)
assert wi.NELM.Value() == 9

wi = builder.WaveformIn("WI8", initial_value=[1, 2, 3], NELM=10)
assert wi.NELM.Value() == 10

# Specifying neither value nor length should produce an error
with pytest.raises(AssertionError):
builder.WaveformIn("WI9")

# Specifying both value and initial_value should produce an error
with pytest.raises(AssertionError):
builder.WaveformIn("WI10", [1, 2, 4], initial_value=[5, 6])


def validate_fixture_names(params):
"""Provide nice names for the out_records fixture in TestValidate class"""
return params[0].__name__
Expand Down

0 comments on commit 40175f2

Please sign in to comment.