From: <man...@us...> - 2013-11-08 14:24:33
|
Revision: 3127 http://sourceforge.net/p/modplug/code/3127 Author: manxorist Date: 2013-11-08 14:24:25 +0000 (Fri, 08 Nov 2013) Log Message: ----------- [Ref] Add some test cases for AbsolutePathToRelative and RelativePathToAbsolute. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mptrack.h trunk/OpenMPT/test/test.cpp Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2013-11-08 13:18:39 UTC (rev 3126) +++ trunk/OpenMPT/mptrack/Mptrack.h 2013-11-08 14:24:25 UTC (rev 3127) @@ -131,6 +131,9 @@ static VOID SetAsProject(BOOL n) { m_nProject = n; } // -! NEW_FEATURE#0023 +#if defined(ENABLE_TESTS) + static void SetAppDirPath(mpt::PathString exePath) {m_szExePath=exePath;} +#endif static mpt::PathString GetAppDirPath() {return m_szExePath;} // Returns '\'-ended executable directory path. static MODTYPE GetDefaultDocType() { return m_nDefaultDocType; } static void SetDefaultDocType(MODTYPE n) { m_nDefaultDocType = n; } Modified: trunk/OpenMPT/test/test.cpp =================================================================== --- trunk/OpenMPT/test/test.cpp 2013-11-08 13:18:39 UTC (rev 3126) +++ trunk/OpenMPT/test/test.cpp 2013-11-08 14:24:25 UTC (rev 3127) @@ -576,6 +576,22 @@ VERIFY_EQUAL(strlen(ModSpecs::Collection[i]->volcommands), MAX_VOLCMDS); } + // Path conversions +#ifdef MODPLUG_TRACKER + const mpt::PathString realExePath = theApp.GetAppDirPath(); + const CString exePath = "C:\\OpenMPT\\"; + theApp.SetAppDirPath(mpt::PathString::FromCString(exePath)); + VERIFY_EQUAL(theApp.AbsolutePathToRelative("C:\\OpenMPT\\"), ".\\"); + VERIFY_EQUAL(theApp.AbsolutePathToRelative("c:\\OpenMPT\\foo"), ".\\foo"); + VERIFY_EQUAL(theApp.AbsolutePathToRelative("C:\\foo"), "\\foo"); + VERIFY_EQUAL(theApp.RelativePathToAbsolute(".\\"), "C:\\OpenMPT\\"); + VERIFY_EQUAL(theApp.RelativePathToAbsolute(".\\foo"), "C:\\OpenMPT\\foo"); + VERIFY_EQUAL(theApp.RelativePathToAbsolute("\\foo"), "C:\\foo"); + VERIFY_EQUAL(theApp.AbsolutePathToRelative("\\\\server\\path\\file"), "\\\\server\\path\\file"); + VERIFY_EQUAL(theApp.RelativePathToAbsolute("\\\\server\\path\\file"), "\\\\server\\path\\file"); + theApp.SetAppDirPath(realExePath); +#endif + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |