You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TEST_CASE(deletedMemberPointer); // deleted member pointer in destructor
62
63
TEST_CASE(noOperatorEq); // class with memory management should have operator eq
63
64
TEST_CASE(noDestructor); // class with memory management should have destructor
64
65
@@ -893,7 +894,7 @@ class TestClass : public TestFixture {
893
894
" ~F();\n"
894
895
" F& operator=(const F&f);\n"
895
896
"};");
896
-
TODO_ASSERT_EQUALS("[test.cpp:8]: (warning) Class 'F' does not have a copy constructor which is recommended since it has dynamic memory/resource allocation(s).\n", "", errout_str());
897
+
TODO_ASSERT_EQUALS("[test.cpp:8]: (warning) Class 'F' does not have a copy constructor which is recommended since it has dynamic memory/resource management.\n", "", errout_str());
897
898
898
899
checkCopyConstructor("class F\n"
899
900
"{\n"
@@ -951,7 +952,7 @@ class TestClass : public TestFixture {
951
952
" ~F();\n"
952
953
" F& operator=(const F&f);\n"
953
954
"};");
954
-
ASSERT_EQUALS("[test.cpp:5:7]: (warning) Class 'F' does not have a copy constructor which is recommended since it has dynamic memory/resource allocation(s). [noCopyConstructor]\n", errout_str());
955
+
ASSERT_EQUALS("[test.cpp:5:7]: (warning) Class 'F' does not have a copy constructor which is recommended since it has dynamic memory/resource management. [noCopyConstructor]\n", errout_str());
955
956
956
957
checkCopyConstructor("class F {\n"
957
958
" char *p;\n"
@@ -970,7 +971,7 @@ class TestClass : public TestFixture {
970
971
" ~F();\n"
971
972
" F& operator=(const F&f);\n"
972
973
"};");
973
-
ASSERT_EQUALS("[test.cpp:3:10]: (warning) Class 'F' does not have a copy constructor which is recommended since it has dynamic memory/resource allocation(s). [noCopyConstructor]\n", errout_str());
974
+
ASSERT_EQUALS("[test.cpp:3:10]: (warning) Class 'F' does not have a copy constructor which is recommended since it has dynamic memory/resource management. [noCopyConstructor]\n", errout_str());
974
975
975
976
// #7198
976
977
checkCopyConstructor("struct F {\n"
@@ -1074,21 +1075,48 @@ class TestClass : public TestFixture {
1074
1075
" }\n"
1075
1076
" char* a[5];\n"
1076
1077
"};\n");
1077
-
TODO_ASSERT_EQUALS("[test.cpp:4]: (warning) Struct 'S' does not have a copy constructor which is recommended since it has dynamic memory/resource allocation(s).\n"
1078
-
"[test.cpp:4]: (warning) Struct 'S' does not have a operator= which is recommended since it has dynamic memory/resource allocation(s).\n"
1079
-
"[test.cpp:4]: (warning) Struct 'S' does not have a destructor which is recommended since it has dynamic memory/resource allocation(s).\n",
1078
+
TODO_ASSERT_EQUALS("[test.cpp:4]: (warning) Struct 'S' does not have a copy constructor which is recommended since it has dynamic memory/resource management.\n"
1079
+
"[test.cpp:4]: (warning) Struct 'S' does not have a operator= which is recommended since it has dynamic memory/resource management.\n"
1080
+
"[test.cpp:4]: (warning) Struct 'S' does not have a destructor which is recommended since it has dynamic memory/resource management.\n",
1080
1081
"",
1081
1082
errout_str());
1082
1083
}
1083
1084
1085
+
voiddeletedMemberPointer() {
1086
+
1087
+
// delete ...
1088
+
checkCopyConstructor("struct P {};\n"
1089
+
"class C {\n"
1090
+
" P *p;\n"
1091
+
"public:\n"
1092
+
" explicit C(P *p) : p(p) {}\n"
1093
+
" ~C() { delete p; }\n"
1094
+
" void f() {}\n"
1095
+
"};\n");
1096
+
ASSERT_EQUALS("[test.cpp:6:19]: (warning) Class 'C' does not have a copy constructor which is recommended since it has dynamic memory/resource management. [noCopyConstructor]\n"
1097
+
"[test.cpp:6:19]: (warning) Class 'C' does not have a operator= which is recommended since it has dynamic memory/resource management. [noOperatorEq]\n", errout_str());
1098
+
1099
+
// free(...)
1100
+
checkCopyConstructor("struct P {};\n"
1101
+
"class C {\n"
1102
+
" P *p;\n"
1103
+
"public:\n"
1104
+
" explicit C(P *p) : p(p) {}\n"
1105
+
" ~C() { free(p); }\n"
1106
+
" void f() {}\n"
1107
+
"};\n");
1108
+
ASSERT_EQUALS("[test.cpp:6:17]: (warning) Class 'C' does not have a copy constructor which is recommended since it has dynamic memory/resource management. [noCopyConstructor]\n"
1109
+
"[test.cpp:6:17]: (warning) Class 'C' does not have a operator= which is recommended since it has dynamic memory/resource management. [noOperatorEq]\n", errout_str());
1110
+
}
1111
+
1084
1112
voidnoOperatorEq() {
1085
1113
checkCopyConstructor("struct F {\n"
1086
1114
" char* c;\n"
1087
1115
" F() { c = malloc(100); }\n"
1088
1116
" F(const F &f);\n"
1089
1117
" ~F();\n"
1090
1118
"};");
1091
-
ASSERT_EQUALS("[test.cpp:3:10]: (warning) Struct 'F' does not have a operator= which is recommended since it has dynamic memory/resource allocation(s). [noOperatorEq]\n", errout_str());
1119
+
ASSERT_EQUALS("[test.cpp:3:10]: (warning) Struct 'F' does not have a operator= which is recommended since it has dynamic memory/resource management. [noOperatorEq]\n", errout_str());
1092
1120
1093
1121
// defaulted operator=
1094
1122
checkCopyConstructor("struct F {\n"
@@ -1127,7 +1155,7 @@ class TestClass : public TestFixture {
1127
1155
" F(const F &f);\n"
1128
1156
" F&operator=(const F&);"
1129
1157
"};");
1130
-
ASSERT_EQUALS("[test.cpp:3:10]: (warning) Struct 'F' does not have a destructor which is recommended since it has dynamic memory/resource allocation(s). [noDestructor]\n", errout_str());
1158
+
ASSERT_EQUALS("[test.cpp:3:10]: (warning) Struct 'F' does not have a destructor which is recommended since it has dynamic memory/resource management. [noDestructor]\n", errout_str());
1131
1159
1132
1160
checkCopyConstructor("struct F {\n"
1133
1161
" C* c;\n"
@@ -1143,7 +1171,7 @@ class TestClass : public TestFixture {
1143
1171
" F(const F &f);\n"
1144
1172
" F& operator=(const F&);"
1145
1173
"};");
1146
-
ASSERT_EQUALS("[test.cpp:3:10]: (warning) Struct 'F' does not have a destructor which is recommended since it has dynamic memory/resource allocation(s). [noDestructor]\n", errout_str());
1174
+
ASSERT_EQUALS("[test.cpp:3:10]: (warning) Struct 'F' does not have a destructor which is recommended since it has dynamic memory/resource management. [noDestructor]\n", errout_str());
1147
1175
1148
1176
checkCopyConstructor("struct Data { int x; int y; };\n"
1149
1177
"struct F {\n"
@@ -1152,7 +1180,7 @@ class TestClass : public TestFixture {
1152
1180
" F(const F &f);\n"
1153
1181
" F&operator=(const F&);"
1154
1182
"};");
1155
-
ASSERT_EQUALS("[test.cpp:4:10]: (warning) Struct 'F' does not have a destructor which is recommended since it has dynamic memory/resource allocation(s). [noDestructor]\n", errout_str());
1183
+
ASSERT_EQUALS("[test.cpp:4:10]: (warning) Struct 'F' does not have a destructor which is recommended since it has dynamic memory/resource management. [noDestructor]\n", errout_str());
0 commit comments