================
@@ -986,6 +987,54 @@ def test_binop(self):
             c = get_cursor(tu, op)
             assert c.binary_operator == typ
 
+    def test_unaryop(self):
+        tu = get_tu(
+            """
+                void func(void) {
+                int a = 0;
+                a++;
+                ++a;
+                a--;
+                --a;
+                *(&a);
+                +a;
+                -a;
+                !a;
+                ~a;
+                float _Complex b;
+                __real b;
+                __imag b;
+                __extension__ a;
+            }""",
+            lang="cpp",
+        )
+
+        operators = {
+            "&": UnaryOperator.AddrOf,
+            "*": UnaryOperator.Deref,
+            "+": UnaryOperator.Plus,
+            "-": UnaryOperator.Minus,
+            "~": UnaryOperator.Not,
+            "!": UnaryOperator.LNot,
+            "__real": UnaryOperator.Real,
+            "__imag": UnaryOperator.Imag,
+            "__extension__": UnaryOperator.Extension,
+        }
+
+        for op, typ in operators.items():
+            c = get_cursor(tu, op)
+            assert c.unary_operator == typ
+
+        shoulds = (
+            UnaryOperator.PostInc,
+            UnaryOperator.PreInc,
+            UnaryOperator.PostDec,
+            UnaryOperator.PreDec,
+        )
+        haves = list(next(tu.cursor.get_children()).get_children())[1:]
----------------
DeinAlptraum wrote:

This is a bit hard to read, it would be nice if you could restructure the test 
TU so you can query the relevant range more directly.

https://github.com/llvm/llvm-project/pull/219983
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to