Skip to content

Commit 165d12d

Browse files
committed
Tests added
1 parent 9790a91 commit 165d12d

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ clean:
1919
-rm -rf bin lib share pyvenv.cfg
2020

2121
coverage:
22-
python3 -m coverage run setup.py test && python3 -m coverage report -m
22+
@pytest --cov --cov-report=term-missing
2323

2424
.PHONY: docs
2525
docs:

requirements-dev.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
coverage[toml]
2+
pytest-cov
23
flake8
34
mypy
45
tox

tests/test_define.py

+29
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import pytest
2929
import cstruct
3030
from cstruct import define, undef, sizeof, typedef
31+
from cstruct.exceptions import ParserError
3132

3233

3334
class Position(cstruct.CStruct):
@@ -65,3 +66,31 @@ def test_define():
6566
def test_typedef():
6667
typedef('int', 'integer')
6768
assert sizeof('integer') == 4
69+
70+
71+
def test_invalid_type():
72+
with pytest.raises(ParserError):
73+
74+
class Invalid(cstruct.CStruct):
75+
__def__ = """
76+
struct {
77+
unsigned xxx yyy;
78+
}
79+
"""
80+
81+
82+
def test_invalid_define():
83+
with pytest.raises(ParserError):
84+
cstruct.parse("""
85+
#define xxx yyy zzz
86+
""")
87+
88+
89+
def test_invalid_struct():
90+
with pytest.raises(ParserError):
91+
cstruct.parse("""
92+
struct {
93+
int a;
94+
int;
95+
}
96+
""")

0 commit comments

Comments
 (0)