From e1fe238f06de4c5771d2bacf34bdd71e91174a26 Mon Sep 17 00:00:00 2001 From: Reijo Tomperi Date: Tue, 13 Apr 2010 23:52:19 +0300 Subject: [PATCH] Add simple --showtime test case --- test/testcppcheck.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/testcppcheck.cpp b/test/testcppcheck.cpp index 05ab8d28f..b371cf1d2 100644 --- a/test/testcppcheck.cpp +++ b/test/testcppcheck.cpp @@ -60,6 +60,7 @@ private: TEST_CASE(getErrorMessages); TEST_CASE(parseOutputtingArgs); TEST_CASE(parseOutputtingInvalidArgs); + TEST_CASE(parseArgsAndCheck); } bool argCheck(int argc, const char *argv[]) @@ -70,6 +71,30 @@ private: return cppCheck.parseFromArgs(argc, argv); } + bool argCheckWithCheck(int argc, const char *argv[], const std::string &data) + { + errout.str(""); + output.str(""); + CppCheck cppCheck(*this); + cppCheck.addFile("file.cpp", data); + bool result = cppCheck.parseFromArgs(argc, argv); + if (result) + cppCheck.check(); + + return result; + } + + void parseArgsAndCheck() + { + { + const char *argv[] = {"cppcheck", "--showtime=top5"}; + const char *data = "void foo(){}"; + ASSERT_EQUALS(true, argCheckWithCheck(2, argv, data)); + ASSERT_EQUALS("", errout.str()); +// ASSERT_EQUALS(true, output.str().find("Overall time:") != std::string::npos); + } + } + void parseOutputtingArgs() { {