summaryrefslogtreecommitdiff
path: root/tests/test_domain_cpp.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_domain_cpp.py')
-rw-r--r--tests/test_domain_cpp.py28
1 files changed, 23 insertions, 5 deletions
diff --git a/tests/test_domain_cpp.py b/tests/test_domain_cpp.py
index 2181702f4..934f658f7 100644
--- a/tests/test_domain_cpp.py
+++ b/tests/test_domain_cpp.py
@@ -32,10 +32,8 @@ def parse(name, string):
return ast
-def check(name, input, idDict, output=None):
+def _check(name, input, idDict, output):
# first a simple check of the AST
- if output is None:
- output = input
ast = parse(name, input)
res = str(ast)
if res != output:
@@ -82,6 +80,15 @@ def check(name, input, idDict, output=None):
raise DefinitionError("")
+def check(name, input, idDict, output=None):
+ if output is None:
+ output = input
+ # First, check without semicolon
+ _check(name, input, idDict, output)
+ # Second, check with semicolon
+ _check(name, input + ' ;', idDict, output + ';')
+
+
def test_fundamental_types():
# see https://en.cppreference.com/w/cpp/language/types
for t, id_v2 in cppDomain._id_fundamental_v2.items():
@@ -392,7 +399,7 @@ def test_function_definitions():
x = 'std::vector<std::pair<std::string, int>> &module::test(register int ' \
'foo, bar, std::string baz = "foobar, blah, bleh") const = 0'
check('function', x, {1: "module::test__i.bar.ssC",
- 2: "NK6module4testEi3barNSt6stringE"})
+ 2: "NK6module4testEi3barNSt6stringE"})
check('function', 'void f(std::pair<A, B>)',
{1: "f__std::pair:A.B:", 2: "1fNSt4pairI1A1BEE"})
check('function', 'explicit module::myclass::foo::foo()',
@@ -426,6 +433,10 @@ def test_function_definitions():
{1: "get_valueCE", 2: "9get_valuev"})
check('function', 'int get_value() const noexcept',
{1: "get_valueC", 2: "NK9get_valueEv"})
+ check('function', 'int get_value() const noexcept(std::is_nothrow_move_constructible<T>::value)',
+ {1: "get_valueC", 2: "NK9get_valueEv"})
+ check('function', 'int get_value() const noexcept("see below")',
+ {1: "get_valueC", 2: "NK9get_valueEv"})
check('function', 'int get_value() const noexcept = delete',
{1: "get_valueC", 2: "NK9get_valueEv"})
check('function', 'int get_value() volatile const',
@@ -867,7 +878,7 @@ def test_xref_parsing():
def filter_warnings(warning, file):
- lines = warning.getvalue().split("\n");
+ lines = warning.getvalue().split("\n")
res = [l for l in lines if "domain-cpp" in l and "{}.rst".format(file) in l and
"WARNING: document isn't included in any toctree" not in l]
print("Filtered warnings for file '{}':".format(file))
@@ -902,6 +913,13 @@ def test_build_domain_cpp_backslash_ok(app, status, warning):
assert len(ws) == 0
+@pytest.mark.sphinx(testroot='domain-cpp', confoverrides={'nitpicky': True})
+def test_build_domain_cpp_semicolon(app, status, warning):
+ app.builder.build_all()
+ ws = filter_warnings(warning, "semicolon")
+ assert len(ws) == 0
+
+
@pytest.mark.sphinx(testroot='domain-cpp',
confoverrides={'nitpicky': True, 'strip_signature_backslash': True})
def test_build_domain_cpp_backslash_ok(app, status, warning):