From 866d66ba78be81d09fa63e99873790159eaa0547 Mon Sep 17 00:00:00 2001 From: Martin Ettl Date: Sun, 20 Jun 2010 13:32:00 +0200 Subject: [PATCH] added testcases for testing dangerous functions: mktemp --- test/testdangerousfunctions.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/testdangerousfunctions.cpp b/test/testdangerousfunctions.cpp index 8181f03c4..22a0e662f 100644 --- a/test/testdangerousfunctions.cpp +++ b/test/testdangerousfunctions.cpp @@ -76,6 +76,18 @@ private: " char *x = mktemp(\"/tmp/zxcv\");\n" "}\n"); ASSERT_EQUALS("[test.cpp:3]: (style) Found 'mktemp'. You should use 'mkstemp' instead\n", errout.str()); + + check("char * f(const std::string& strVal)\n" + "{\n" + " return(mktemp(strVal.c_str()));\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:3]: (style) Found 'mktemp'. You should use 'mkstemp' instead\n", errout.str()); + + check("char * f(const std::string& strVal)\n" + "{\n" + " return mktemp(strVal.c_str()) ;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:3]: (style) Found 'mktemp'. You should use 'mkstemp' instead\n", errout.str()); } void testgets()