Fix #line directives

This commit is contained in:
Dustin Spicuzza
2023-08-21 17:15:55 -04:00
parent dffcbf9034
commit 4febbe5d0d
2 changed files with 23 additions and 8 deletions

View File

@@ -1,5 +1,6 @@
# Note: testcases generated via `python -m cxxheaderparser.gentest`
from cxxheaderparser.errors import CxxParseError
from cxxheaderparser.types import (
BaseClass,
ClassDecl,
@@ -22,6 +23,8 @@ from cxxheaderparser.simple import (
ParsedData,
)
import pytest
#
# minimal preprocessor support
#
@@ -93,6 +96,19 @@ def test_pragma_more() -> None:
)
def test_line_and_define() -> None:
content = """
// this should work + change line number of error
#line 40 "filename.h"
// this should fail
#define 1
"""
with pytest.raises(CxxParseError) as e:
parse_string(content, cleandoc=True)
assert "filename.h:41" in str(e.value)
#
# extern "C"
#