From 29207e3eebb5ea7597d4160bbf171f1cec0edd5c Mon Sep 17 00:00:00 2001 From: Leander Schulten Date: Sat, 30 Jan 2021 22:11:04 +0100 Subject: CppEditor: Add Base Class Support for Generate Constructor QuickFix Change-Id: Idd92229134609c0ac87aad030a6bb645ff4cce1b Reviewed-by: Christian Kandeler --- src/plugins/cppeditor/cppquickfix_test.cpp | 69 ++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'src/plugins/cppeditor/cppquickfix_test.cpp') diff --git a/src/plugins/cppeditor/cppquickfix_test.cpp b/src/plugins/cppeditor/cppquickfix_test.cpp index e2bc42cf4c..7bfdf5b7ba 100644 --- a/src/plugins/cppeditor/cppquickfix_test.cpp +++ b/src/plugins/cppeditor/cppquickfix_test.cpp @@ -7878,6 +7878,75 @@ public: QTest::newRow("default parameters") << header << expected << QByteArray() << QByteArray() << Inside; + header = R"--( +struct Bar{ + Bar(int i); +}; +class@ Foo : public Bar{ + int test; +public: +}; +)--"; + expected = R"--( +struct Bar{ + Bar(int i); +}; +class Foo : public Bar{ + int test; +public: + Foo(int test, int i) : Bar(i), + test(test) + {} +}; +)--"; + QTest::newRow("parent constructor") + << header << expected << QByteArray() << QByteArray() << Inside; + + header = R"--( +struct Bar{ + Bar(int use_i = 6); +}; +class@ Foo : public Bar{ + int test; +public: +}; +)--"; + expected = R"--( +struct Bar{ + Bar(int use_i = 6); +}; +class Foo : public Bar{ + int test; +public: + Foo(int test, int use_i = 6) : Bar(use_i), + test(test) + {} +}; +)--"; + QTest::newRow("parent constructor with default") + << header << expected << QByteArray() << QByteArray() << Inside; + + header = R"--( +struct Bar{ + Bar(int use_i = L'A', int use_i2 = u8"B"); +}; +class@ Foo : public Bar{ +public: +}; +)--"; + expected = R"--( +struct Bar{ + Bar(int use_i = L'A', int use_i2 = u8"B"); +}; +class Foo : public Bar{ +public: + Foo(int use_i = L'A', int use_i2 = u8"B") : Bar(use_i, use_i2) + {} +}; +)--"; + QTest::newRow("parent constructor with char/string default value") + << header << expected << QByteArray() << QByteArray() << Inside; + const QByteArray common = R"--( namespace N{ template -- cgit v1.2.1