From 56397ae4575dc6819e69c66fbd901972353b482c Mon Sep 17 00:00:00 2001 From: Jaromir Wysoglad Date: Tue, 2 Apr 2019 14:33:31 +0200 Subject: COMMON: add tests for Common::String I added tests for firstChar, setChar, insertChar --- test/common/str.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'test') diff --git a/test/common/str.h b/test/common/str.h index 3c69d1792c..c6a6e7bed6 100644 --- a/test/common/str.h +++ b/test/common/str.h @@ -40,6 +40,15 @@ class StringTestSuite : public CxxTest::TestSuite TS_ASSERT_EQUALS(str2.lastChar(), 'r'); } + void test_firstChar() { + Common::String str; + TS_ASSERT_EQUALS(str.firstChar(), '\0'); + str = "first_test"; + TS_ASSERT_EQUALS(str.firstChar(), 'f'); + Common::String str2("bar"); + TS_ASSERT_EQUALS(str2.firstChar(), 'b'); + } + void test_concat1() { Common::String str("foo"); Common::String str2("bar"); @@ -542,4 +551,20 @@ class StringTestSuite : public CxxTest::TestSuite TS_ASSERT_EQUALS(s3, "TestTestTest"); TS_ASSERT_EQUALS(s4, "TestTestTestTestTestTestTestTestTestTestTest"); } + + void test_setChar() { + Common::String testString("123456"); + testString.setChar('2', 0); + TS_ASSERT(testString == "223456"); + testString.setChar('0', 5); + TS_ASSERT(testString == "223450"); + } + + void test_insertChar() { + Common::String testString("123456"); + testString.insertChar('2', 0); + TS_ASSERT(testString == "2123456"); + testString.insertChar('0', 5); + TS_ASSERT(testString == "21234056"); + } }; -- cgit v1.2.3