Skip to content

Commit

Permalink
Update testconstructors.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github authored Nov 12, 2024
1 parent ee99912 commit d048845
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions test/testconstructors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class TestConstructors : public TestFixture {
TEST_CASE(simple15); // #8942 multiple arguments, decltype
TEST_CASE(simple16); // copy members with c++11 init
TEST_CASE(simple17); // #10360
TEST_CASE(simple18);

TEST_CASE(noConstructor1);
TEST_CASE(noConstructor2);
Expand Down Expand Up @@ -510,6 +511,23 @@ class TestConstructors : public TestFixture {
ASSERT_EQUALS("", errout_str());
}

void simple15() { // #8942
check("class A\n"
"{\n"
"public:\n"
" int member;\n"
"};\n"
"class B\n"
"{\n"
"public:\n"
" B(const decltype(A::member)& x, const decltype(A::member)& y) : x(x), y(y) {}\n"
"private:\n"
" const decltype(A::member)& x;\n"
" const decltype(A::member)& y;\n"
"};\n");
ASSERT_EQUALS("", errout_str());
}

void simple16() {
check("struct S {\n"
" int i{};\n"
Expand Down Expand Up @@ -554,21 +572,13 @@ class TestConstructors : public TestFixture {
ASSERT_EQUALS("", errout_str());
}

void simple15() { // #8942
check("class A\n"
"{\n"
"public:\n"
" int member;\n"
"};\n"
"class B\n"
"{\n"
"public:\n"
" B(const decltype(A::member)& x, const decltype(A::member)& y) : x(x), y(y) {}\n"
"private:\n"
" const decltype(A::member)& x;\n"
" const decltype(A::member)& y;\n"
"};\n");
ASSERT_EQUALS("", errout_str());
void simple18() { // #13302
check("struct S {};\n"
"class C1 { S& r; };\n"
"class C2 { S* p; };\n");
ASSERT_EQUALS("[test.cpp:2]: (style) The class 'C1' does not declare a constructor although it has private member variables which likely require initialization.\n"
"[test.cpp:3]: (style) The class 'C2' does not declare a constructor although it has private member variables which likely require initialization.\n",
errout_str());
}

void noConstructor1() {
Expand Down

0 comments on commit d048845

Please sign in to comment.