From 93394902368a0fb2c25647f0d6205f5a43282933 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Mon, 26 Dec 2016 10:42:29 +0100 Subject: WINTERMUTE: only access -1th char of string if length > 0 in getFileName Fixes #6594 --- test/engines/wintermute/path_utils.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test/engines') diff --git a/test/engines/wintermute/path_utils.h b/test/engines/wintermute/path_utils.h index c3f1776231..3cacf47fd9 100644 --- a/test/engines/wintermute/path_utils.h +++ b/test/engines/wintermute/path_utils.h @@ -53,6 +53,10 @@ class PathUtilTestSuite : public CxxTest::TestSuite { Wintermute::PathUtil::getDirectoryName(windowsCapPath), Common::String("C:\\SOME\\") ); + TS_ASSERT_EQUALS( + Wintermute::PathUtil::getDirectoryName(emptyString), + Common::String("") + ); } void test_getfilename() { @@ -72,6 +76,10 @@ class PathUtilTestSuite : public CxxTest::TestSuite { Wintermute::PathUtil::getFileName(windowsCapPath), Common::String("FILE.EXT") ); + TS_ASSERT_EQUALS( + Wintermute::PathUtil::getFileName(emptyString), + Common::String("") + ); TS_ASSERT_EQUALS( Wintermute::PathUtil::getFileName(unixRelativePath), Common::String("file.ext") @@ -80,6 +88,14 @@ class PathUtilTestSuite : public CxxTest::TestSuite { Wintermute::PathUtil::getFileName(windowsRelativePath), Common::String("file.ext") ); + TS_ASSERT_EQUALS( + Wintermute::PathUtil::getFileName(windowsDirPath), + Common::String("") + ); + TS_ASSERT_EQUALS( + Wintermute::PathUtil::getFileName(unixDirPath), + Common::String("") + ); } void test_getextension() { @@ -91,6 +107,10 @@ class PathUtilTestSuite : public CxxTest::TestSuite { Wintermute::PathUtil::getExtension(windowsCapPath), Common::String("EXT") ); + TS_ASSERT_EQUALS( + Wintermute::PathUtil::getExtension(emptyString), + Common::String("") + ); TS_ASSERT_EQUALS( Wintermute::PathUtil::getExtension(dualExtPath), Common::String("gz") @@ -118,6 +138,10 @@ class PathUtilTestSuite : public CxxTest::TestSuite { Wintermute::PathUtil::getFileNameWithoutExtension(windowsCapPath), Common::String("FILE") ); + TS_ASSERT_EQUALS( + Wintermute::PathUtil::getFileNameWithoutExtension(emptyString), + Common::String("") + ); TS_ASSERT_EQUALS( Wintermute::PathUtil::getFileNameWithoutExtension(dualExtPath), Common::String("file.tar") -- cgit v1.2.3