summaryrefslogtreecommitdiffstats
path: root/bindings/python/tests/cindex/test_cursor.py
diff options
context:
space:
mode:
Diffstat (limited to 'bindings/python/tests/cindex/test_cursor.py')
-rw-r--r--bindings/python/tests/cindex/test_cursor.py82
1 files changed, 82 insertions, 0 deletions
diff --git a/bindings/python/tests/cindex/test_cursor.py b/bindings/python/tests/cindex/test_cursor.py
index c5ea50516a..6c8230d428 100644
--- a/bindings/python/tests/cindex/test_cursor.py
+++ b/bindings/python/tests/cindex/test_cursor.py
@@ -112,6 +112,88 @@ def test_is_const_method():
assert foo.is_const_method()
assert not bar.is_const_method()
+def test_is_converting_constructor():
+ """Ensure Cursor.is_converting_constructor works."""
+ source = 'class X { explicit X(int); X(double); X(); };'
+ tu = get_tu(source, lang='cpp')
+
+ xs = get_cursors(tu, 'X')
+
+ assert len(xs) == 4
+ assert xs[0].kind == CursorKind.CLASS_DECL
+ cs = xs[1:]
+ assert cs[0].kind == CursorKind.CONSTRUCTOR
+ assert cs[1].kind == CursorKind.CONSTRUCTOR
+ assert cs[2].kind == CursorKind.CONSTRUCTOR
+
+ assert not cs[0].is_converting_constructor()
+ assert cs[1].is_converting_constructor()
+ assert not cs[2].is_converting_constructor()
+
+
+def test_is_copy_constructor():
+ """Ensure Cursor.is_copy_constructor works."""
+ source = 'class X { X(); X(const X&); X(X&&); };'
+ tu = get_tu(source, lang='cpp')
+
+ xs = get_cursors(tu, 'X')
+ assert xs[0].kind == CursorKind.CLASS_DECL
+ cs = xs[1:]
+ assert cs[0].kind == CursorKind.CONSTRUCTOR
+ assert cs[1].kind == CursorKind.CONSTRUCTOR
+ assert cs[2].kind == CursorKind.CONSTRUCTOR
+
+ assert not cs[0].is_copy_constructor()
+ assert cs[1].is_copy_constructor()
+ assert not cs[2].is_copy_constructor()
+
+def test_is_default_constructor():
+ """Ensure Cursor.is_default_constructor works."""
+ source = 'class X { X(); X(int); };'
+ tu = get_tu(source, lang='cpp')
+
+ xs = get_cursors(tu, 'X')
+ assert xs[0].kind == CursorKind.CLASS_DECL
+ cs = xs[1:]
+ assert cs[0].kind == CursorKind.CONSTRUCTOR
+ assert cs[1].kind == CursorKind.CONSTRUCTOR
+
+ assert cs[0].is_default_constructor()
+ assert not cs[1].is_default_constructor()
+
+def test_is_move_constructor():
+ """Ensure Cursor.is_move_constructor works."""
+ source = 'class X { X(); X(const X&); X(X&&); };'
+ tu = get_tu(source, lang='cpp')
+
+ xs = get_cursors(tu, 'X')
+ assert xs[0].kind == CursorKind.CLASS_DECL
+ cs = xs[1:]
+ assert cs[0].kind == CursorKind.CONSTRUCTOR
+ assert cs[1].kind == CursorKind.CONSTRUCTOR
+ assert cs[2].kind == CursorKind.CONSTRUCTOR
+
+ assert not cs[0].is_move_constructor()
+ assert not cs[1].is_move_constructor()
+ assert cs[2].is_move_constructor()
+
+def test_is_default_method():
+ """Ensure Cursor.is_default_method works."""
+ source = 'class X { X() = default; }; class Y { Y(); };'
+ tu = get_tu(source, lang='cpp')
+
+ xs = get_cursors(tu, 'X')
+ ys = get_cursors(tu, 'Y')
+
+ assert len(xs) == 2
+ assert len(ys) == 2
+
+ xc = xs[1]
+ yc = ys[1]
+
+ assert xc.is_default_method()
+ assert not yc.is_default_method()
+
def test_is_mutable_field():
"""Ensure Cursor.is_mutable_field works."""
source = 'class X { int x_; mutable int y_; };'