From a1e20290cdcb1bf9f9a0a2859b03a15ab2f98289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 27 Sep 2009 22:13:15 +0200 Subject: [PATCH] Refactoring the unit testing of format strings --- test/testbufferoverrun.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index 84c6544e4..0552ace4b 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -888,18 +888,15 @@ private: void counter_test() { - - std::string str1 = "Hello"; - std::string str2 = "Hello %2.2d %1d"; - std::string str3 = "Test \" "; - std::string str4 = "Try %s"; - std::string str5 = "%d"; - - ASSERT_EQUALS(6, CheckBufferOverrun::count(str1)); - ASSERT_EQUALS(11, CheckBufferOverrun::count(str2)); - ASSERT_EQUALS(8, CheckBufferOverrun::count(str3)); - ASSERT_EQUALS(5, CheckBufferOverrun::count(str4)); - ASSERT_EQUALS(2, CheckBufferOverrun::count(str5)); + ASSERT_EQUALS(6, CheckBufferOverrun::count("Hello")); + ASSERT_EQUALS(2, CheckBufferOverrun::count("s")); + ASSERT_EQUALS(2, CheckBufferOverrun::count("i")); + ASSERT_EQUALS(2, CheckBufferOverrun::count("%d")); + ASSERT_EQUALS(2, CheckBufferOverrun::count("%1d")); + ASSERT_EQUALS(3, CheckBufferOverrun::count("%2.2d")); + ASSERT_EQUALS(1, CheckBufferOverrun::count("%s")); + ASSERT_EQUALS(6, CheckBufferOverrun::count("%-5s")); + TODO_ASSERT_EQUALS(2, CheckBufferOverrun::count("\\\"")); } void strncpy1()