Add basic preprocessor test
This commit is contained in:
27
tests/test_preprocessor.py
Normal file
27
tests/test_preprocessor.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from cxxheaderparser.options import ParserOptions
|
||||
from cxxheaderparser.preprocessor import make_pcpp_preprocessor
|
||||
from cxxheaderparser.simple import NamespaceScope, ParsedData, parse_string
|
||||
from cxxheaderparser.types import FundamentalSpecifier, NameSpecifier, PQName, Token, Type, Value, Variable
|
||||
|
||||
|
||||
def test_basic_preprocessor() -> None:
|
||||
content = """
|
||||
#define X 1
|
||||
int x = X;
|
||||
"""
|
||||
options = ParserOptions(preprocessor=make_pcpp_preprocessor())
|
||||
data = parse_string(content, cleandoc=True, options=options)
|
||||
|
||||
assert data == ParsedData(
|
||||
namespace=NamespaceScope(
|
||||
variables=[
|
||||
Variable(
|
||||
name=PQName(segments=[NameSpecifier(name="x")]),
|
||||
type=Type(
|
||||
typename=PQName(segments=[FundamentalSpecifier(name="int")])
|
||||
),
|
||||
value=Value(tokens=[Token(value="1")]),
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
Reference in New Issue
Block a user