| 1615 | } |
| 1616 | |
| 1617 | void TestCodeCompletion::testCompleteFunction_data() |
| 1618 | { |
| 1619 | QTest::addColumn<QString>("code"); |
| 1620 | QTest::addColumn<CompletionItems>("expectedItems"); |
| 1621 | QTest::addColumn<QString>("itemToExecute"); |
| 1622 | QTest::addColumn<QString>("expectedCode"); |
| 1623 | |
| 1624 | QTest::newRow("add-parens") |
| 1625 | << "int foo();\nint main() {\n\n}" |
| 1626 | << CompletionItems({2, 0}, {"foo", "main"}) |
| 1627 | << "foo" |
| 1628 | << "int foo();\nint main() {\nfoo()\n}"; |
| 1629 | |
| 1630 | QTest::newRow("keep-parens") |
| 1631 | << "int foo();\nint main() {\nfoo();\n}" |
| 1632 | << CompletionItems({2, 0}, {"foo", "main"}) |
| 1633 | << "main" |
| 1634 | << "int foo();\nint main() {\nmain();\n}"; |
| 1635 | |
| 1636 | QTest::newRow("bug375635") |
| 1637 | << "enum class Color {\nBlue, Green, Red, Yellow\n};\nvoid foo() {\nColor x;\nswitch (x) {\ncase : break;}\n}" |
| 1638 | << CompletionItems({6, 5}, {"Blue", "Green", "Red", "Yellow"}) |
| 1639 | << "Yellow" |
| 1640 | << "enum class Color {\nBlue, Green, Red, Yellow\n};\nvoid foo() {\nColor x;\nswitch (x) {\ncase Color::Yellow: break;}\n}"; |
| 1641 | |
| 1642 | QTest::newRow("bug368544") |
| 1643 | << "class Klass {\npublic:\ntemplate <typename T>\nvoid func(int a, T x, int b) const;\n};\n" |
| 1644 | << CompletionItems({5, 0}, {"Klass", "Klass::func(int a, T x, int b) const"}) |
| 1645 | << "Klass::func(int a, T x, int b) const" |
| 1646 | << "class Klass {\npublic:\ntemplate <typename T>\nvoid func(int a, T x, int b) const;\n};\ntemplate<typename T> void Klass::func(int a, T x, int b) const\n{\n}\n"; |
| 1647 | |
| 1648 | QTest::newRow("bug377397") |
| 1649 | << "template<typename T> class Foo {\nvoid bar();\n};\n" |
| 1650 | << CompletionItems({3, 0}, {"Foo", "Foo<T>::bar()"}) |
| 1651 | << "Foo<T>::bar()" |
| 1652 | << "template<typename T> class Foo {\nvoid bar();\n};\ntemplate<typename T> void Foo<T>::bar()\n{\n}\n"; |
| 1653 | |
| 1654 | QTest::newRow("template-template-parameter") |
| 1655 | << "template <template<class, int> class X, typename B>\nclass Test {\npublic:\nvoid bar(B a);\n};\n" |
| 1656 | << CompletionItems({5, 0}, {"Test", "Test<X, B>::bar(B a)"}) |
| 1657 | << "Test<X, B>::bar(B a)" |
| 1658 | << "template <template<class, int> class X, typename B>\nclass Test {\npublic:\nvoid bar(B a);\n};\ntemplate<template<typename, int> class X, typename B> void Test<X, B>::bar(B a)\n{\n}\n"; |
| 1659 | |
| 1660 | QTest::newRow("replace-leading-return-type") |
| 1661 | << "void foo(int x);\nvoid " |
| 1662 | << CompletionItems({1, 5}, {"foo(int x)"}) |
| 1663 | << "foo(int x)" |
| 1664 | << "void foo(int x);\nvoid foo(int x)\n{\n}\n"; |
| 1665 | |
| 1666 | QTest::newRow("replace-leading-function-name") |
| 1667 | << "void foo(int x);\nfoo" |
| 1668 | << CompletionItems({1, 3}, {"foo(int x)"}) |
| 1669 | << "foo(int x)" |
| 1670 | << "void foo(int x);\nvoid foo(int x)\n{\n}\n"; |
| 1671 | |
| 1672 | QTest::newRow("replace-leading-with-class-method") |
| 1673 | << "class Foo { int bar(int x); };\nint " |
| 1674 | << CompletionItems({1, 4}, {"Foo", "Foo::bar(int x)"}) |
nothing calls this directly
no test coverage detected