From dd574c4f2ca1f505ff02106f88fe375c537ae1f4 Mon Sep 17 00:00:00 2001 From: XinyuHou Date: Tue, 14 Apr 2015 13:47:34 +0100 Subject: [PATCH] Added unit tests for string operations --- src/test/unittests/base/StringTests.cpp | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/test/unittests/base/StringTests.cpp b/src/test/unittests/base/StringTests.cpp index e0108413..2a461f05 100644 --- a/src/test/unittests/base/StringTests.cpp +++ b/src/test/unittests/base/StringTests.cpp @@ -53,3 +53,32 @@ TEST(StringTests, sprintf) EXPECT_EQ("answer=42", result); } + +TEST(StringTests, toHex) +{ + String subject = "foobar"; + int width = 2; + + string::toHex(subject, width); + + EXPECT_EQ("666f6f626172", subject); +} + +TEST(StringTests, uppercase) +{ + String subject = "12foo3BaR"; + + string::uppercase(subject); + + EXPECT_EQ("12FOO3BAR", subject); +} + +TEST(StringTests, removeChar) +{ + String subject = "foobar"; + const char c = 'o'; + + string::removeChar(subject, c); + + EXPECT_EQ("fbar", subject); +}