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
Copy file name to clipboardExpand all lines: test/testobsoletefunctions.cpp
+50Lines changed: 50 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -53,6 +53,16 @@ class TestObsoleteFunctions : public TestFixture
53
53
54
54
// declared function ticket #3121
55
55
TEST_CASE(test_declared_function);
56
+
57
+
// test std::gets
58
+
TEST_CASE(test_std_gets);
59
+
60
+
// multiple use of obsolete functions
61
+
TEST_CASE(test_multiple);
62
+
63
+
// c declared function
64
+
TEST_CASE(test_c_declaration);
65
+
56
66
}
57
67
58
68
voidcheck(constchar code[])
@@ -242,6 +252,46 @@ class TestObsoleteFunctions : public TestFixture
242
252
"}\n");
243
253
ASSERT_EQUALS("", errout.str());
244
254
}
255
+
256
+
// test std::gets
257
+
voidtest_std_gets()
258
+
{
259
+
check("void f(char * str)\n"
260
+
"{\n"
261
+
" char *x = std::gets(str);\n"
262
+
"}\n");
263
+
ASSERT_EQUALS("[test.cpp:3]: (style) Found obsolete function 'gets'. It is recommended to use the function 'fgets' instead\n", errout.str());
264
+
}
265
+
266
+
// multiple use
267
+
voidtest_multiple()
268
+
{
269
+
check("void f(char * str)\n"
270
+
"{\n"
271
+
" char *x = std::gets(str);\n"
272
+
" usleep( 1000 );\n"
273
+
"}\n");
274
+
ASSERT_EQUALS("[test.cpp:3]: (style) Found obsolete function 'gets'. It is recommended to use the function 'fgets' instead\n[test.cpp:4]: (style) Found obsolete function 'usleep'. It is recommended that new applications use the 'nanosleep' or 'setitimer' function\n", errout.str());
0 commit comments