-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathtest_signal.py
32 lines (26 loc) · 925 Bytes
/
test_signal.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import pytest
from ldfparser import LinSignal
@pytest.mark.unit
def test_signal_create_scalar_valid():
signal = LinSignal.create('LSM', 8, 0)
assert signal.is_array() is False
@pytest.mark.unit
def test_signal_create_scalar_invalid_size():
with pytest.raises(ValueError):
LinSignal.create('LSM', 20, 0)
@pytest.mark.unit
def test_signal_create_array_valid():
signal = LinSignal.create('LSM', 24, [1, 2, 3])
assert signal.is_array() is True
@pytest.mark.unit
def test_signal_create_array_invalid_length():
with pytest.raises(ValueError):
LinSignal.create('LSM', 13, [0, 1, 2, 3])
@pytest.mark.unit
def test_signal_create_array_invalid_width():
with pytest.raises(ValueError):
LinSignal.create('LSM', 0, [0, 1])
@pytest.mark.unit
def test_signal_create_array_invalid_initvalue():
with pytest.raises(ValueError):
LinSignal.create('LSM', 24, [1, 2, 3, 4, 5])