From dda0f77bcf093dced1ad833982be8a9e0951a85e Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Sat, 7 Oct 2017 22:01:13 -0500 Subject: COMMON: Add basic fixed-width word wrap to Common::String --- test/common/str.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test') diff --git a/test/common/str.h b/test/common/str.h index b7ad28e56e..9f8c6fbd60 100644 --- a/test/common/str.h +++ b/test/common/str.h @@ -443,6 +443,28 @@ class StringTestSuite : public CxxTest::TestSuite TS_ASSERT_LESS_THAN(scumm_strnicmp("abCd", "ABCde", 5), 0); } + void test_wordWrap() { + Common::String testString("123456"); + testString.wordWrap(10); + TS_ASSERT(testString == "123456"); + testString.wordWrap(2); + TS_ASSERT(testString == "12\n34\n56"); + testString = "1234 5678"; + testString.wordWrap(4); + TS_ASSERT(testString == "1234\n5678"); + testString = "12 3 45"; + testString.wordWrap(4); + TS_ASSERT(testString == "12 3\n45"); + testString = "\n1\n23 45\n\n"; + testString.wordWrap(3); + TS_ASSERT(testString == "\n1\n23\n45\n\n"); + testString = "123 "; + testString.wordWrap(4); + TS_ASSERT(testString == "123 "); + testString.wordWrap(3); + TS_ASSERT(testString == "123\n"); + } + void test_replace() { // Tests created with the results of the STL std::string class -- cgit v1.2.3