diff options
Diffstat (limited to 'test/common')
-rw-r--r-- | test/common/str.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/common/str.h b/test/common/str.h index c59c5a5efd..b6080fe3be 100644 --- a/test/common/str.h +++ b/test/common/str.h @@ -403,6 +403,29 @@ class StringTestSuite : public CxxTest::TestSuite TS_ASSERT_EQUALS(strcmp(test4, resultString), 0); } + void test_strnlen() { + static const char * const testString = "123"; + TS_ASSERT_EQUALS(Common::strnlen(testString, 0), 0); + TS_ASSERT_EQUALS(Common::strnlen(testString, 1), 1); + TS_ASSERT_EQUALS(Common::strnlen(testString, 2), 2); + TS_ASSERT_EQUALS(Common::strnlen(testString, 3), 3); + TS_ASSERT_EQUALS(Common::strnlen(testString, 4), 3); + + const char testArray[4] = { '1', '2', '3', '4' }; + TS_ASSERT_EQUALS(Common::strnlen(testArray, 0), 0); + TS_ASSERT_EQUALS(Common::strnlen(testArray, 1), 1); + TS_ASSERT_EQUALS(Common::strnlen(testArray, 2), 2); + TS_ASSERT_EQUALS(Common::strnlen(testArray, 3), 3); + TS_ASSERT_EQUALS(Common::strnlen(testArray, 4), 4); + + const char testArray2[4] = { '1', '\0', '3', '4' }; + TS_ASSERT_EQUALS(Common::strnlen(testArray2, 0), 0); + TS_ASSERT_EQUALS(Common::strnlen(testArray2, 1), 1); + TS_ASSERT_EQUALS(Common::strnlen(testArray2, 2), 1); + TS_ASSERT_EQUALS(Common::strnlen(testArray2, 3), 1); + TS_ASSERT_EQUALS(Common::strnlen(testArray2, 4), 1); + } + void test_scumm_stricmp() { TS_ASSERT_EQUALS(scumm_stricmp("abCd", "abCd"), 0); TS_ASSERT_EQUALS(scumm_stricmp("abCd", "ABCd"), 0); |