Refactoring the unit testing of format strings

This commit is contained in:
Daniel Marjamäki 2009-09-27 22:13:15 +02:00
parent a61abcbbc8
commit a1e20290cd
1 changed files with 9 additions and 12 deletions

View File

@ -888,18 +888,15 @@ private:
void counter_test() void counter_test()
{ {
ASSERT_EQUALS(6, CheckBufferOverrun::count("Hello"));
std::string str1 = "Hello"; ASSERT_EQUALS(2, CheckBufferOverrun::count("s"));
std::string str2 = "Hello %2.2d %1d"; ASSERT_EQUALS(2, CheckBufferOverrun::count("i"));
std::string str3 = "Test \" "; ASSERT_EQUALS(2, CheckBufferOverrun::count("%d"));
std::string str4 = "Try %s"; ASSERT_EQUALS(2, CheckBufferOverrun::count("%1d"));
std::string str5 = "%d"; ASSERT_EQUALS(3, CheckBufferOverrun::count("%2.2d"));
ASSERT_EQUALS(1, CheckBufferOverrun::count("%s"));
ASSERT_EQUALS(6, CheckBufferOverrun::count(str1)); ASSERT_EQUALS(6, CheckBufferOverrun::count("%-5s"));
ASSERT_EQUALS(11, CheckBufferOverrun::count(str2)); TODO_ASSERT_EQUALS(2, CheckBufferOverrun::count("\\\""));
ASSERT_EQUALS(8, CheckBufferOverrun::count(str3));
ASSERT_EQUALS(5, CheckBufferOverrun::count(str4));
ASSERT_EQUALS(2, CheckBufferOverrun::count(str5));
} }
void strncpy1() void strncpy1()