From 4dd38356178fe273042f3cccf0358c1766092874 Mon Sep 17 00:00:00 2001 From: Slava Semushin Date: Sun, 14 Jun 2009 12:33:46 +0700 Subject: [PATCH] Embed errout.str() into ASSERT_EQUALS() call. Get rid of useless variables. No functional change. --- test/testbufferoverrun.cpp | 6 ++---- test/testconstructors.cpp | 16 +++++----------- test/testmemleak.cpp | 18 ++++++------------ 3 files changed, 13 insertions(+), 27 deletions(-) diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index 03236147c..4ee0694b4 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -414,8 +414,7 @@ private: "{\n" " str[10] = 0;\n" "}\n"); - std::string err(errout.str()); - ASSERT_EQUALS("[test.cpp:10]: (all) Array index out of bounds\n", err); + ASSERT_EQUALS("[test.cpp:10]: (all) Array index out of bounds\n", errout.str()); } @@ -456,8 +455,7 @@ private: " for (i = 0; i <= 10; ++i)\n" " a[i] = 0;\n" "}\n"); - std::string err(errout.str()); - ASSERT_EQUALS("[test.cpp:7]: (all) Buffer overrun\n", err); + ASSERT_EQUALS("[test.cpp:7]: (all) Buffer overrun\n", errout.str()); } diff --git a/test/testconstructors.cpp b/test/testconstructors.cpp index ef0859505..653a29ab1 100644 --- a/test/testconstructors.cpp +++ b/test/testconstructors.cpp @@ -86,9 +86,7 @@ private: "public:\n" " int i;\n" "};\n"); - std::string actual(errout.str()); - std::string expected("[test.cpp:1]: (style) The class 'Fred' has no constructor\n"); - ASSERT_EQUALS(expected, actual); + ASSERT_EQUALS("[test.cpp:1]: (style) The class 'Fred' has no constructor\n", errout.str()); } @@ -186,8 +184,7 @@ private: " { i = fred.i; return *this; }\n" "};\n"); - std::string err(errout.str()); - ASSERT_EQUALS("", err); + ASSERT_EQUALS("", errout.str()); } @@ -239,8 +236,7 @@ private: " };\n" "}\n"); - std::string err(errout.str()); - ASSERT_EQUALS("", err); + ASSERT_EQUALS("", errout.str()); } void initvar_chained_assign() @@ -260,8 +256,7 @@ private: " m_iMyInt1 = m_iMyInt2 = 0;\n" "}\n"); - std::string err(errout.str()); - ASSERT_EQUALS("", err); + ASSERT_EQUALS("", errout.str()); } @@ -295,8 +290,7 @@ private: " m_iMyInt = 0;\n" "}\n"); - std::string err(errout.str()); - ASSERT_EQUALS("", err); + ASSERT_EQUALS("", errout.str()); } diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index ffb0d4915..a4ed8f0c4 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -1222,8 +1222,8 @@ private: " char *p = new char[100];\n" " foo(p);\n" "}\n", true); - std::string err(errout.str()); - ASSERT_EQUALS("[test.cpp:9] -> [test.cpp:3]: (error) Mismatching allocation and deallocation: str\n", err); + ASSERT_EQUALS("[test.cpp:9] -> [test.cpp:3]: (error) Mismatching allocation and deallocation: str\n", + errout.str()); } @@ -1239,8 +1239,7 @@ private: " char *p = new char[100];\n" " foo(p);\n" "}\n"); - std::string err(errout.str()); - ASSERT_EQUALS("[test.cpp:10]: (error) Memory leak: p\n", err); + ASSERT_EQUALS("[test.cpp:10]: (error) Memory leak: p\n", errout.str()); } @@ -1258,8 +1257,7 @@ private: " char *p = new char[100];\n" " foo(p);\n" "}\n"); - std::string err(errout.str()); - TODO_ASSERT_EQUALS("[test.cpp:11]: (error) Memory leak: p\n", err); + TODO_ASSERT_EQUALS("[test.cpp:11]: (error) Memory leak: p\n", errout.str()); } @@ -1471,9 +1469,7 @@ private: " return;\n" "}\n"); - std::string err(errout.str()); - - ASSERT_EQUALS("[test.cpp:12]: (error) Memory leak: s2\n", err); + ASSERT_EQUALS("[test.cpp:12]: (error) Memory leak: s2\n", errout.str()); } @@ -1995,9 +1991,7 @@ private: " memset(&(out[0]), 0, 1);\n" "}\n"); - std::string err(errout.str()); - - ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: out\n", err); + ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: out\n", errout.str()); } void strndup_function()