From b94ffc72113987fff6db17b379a4420d94decdba Mon Sep 17 00:00:00 2001 From: Alexander B Date: Tue, 15 Aug 2017 21:36:58 +0300 Subject: [PATCH] fix : rename test testExpandUnix to testExpandVariableFromPath, add usecases for windows (#1850) --- Foundation/testsuite/src/PathTest.cpp | 22 ++++++++++++++++------ Foundation/testsuite/src/PathTest.h | 2 +- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Foundation/testsuite/src/PathTest.cpp b/Foundation/testsuite/src/PathTest.cpp index 11d07c85f..aa9c0464d 100644 --- a/Foundation/testsuite/src/PathTest.cpp +++ b/Foundation/testsuite/src/PathTest.cpp @@ -373,17 +373,27 @@ void PathTest::testParseUnix5() assert (p.toString(Path::PATH_UNIX) == "/c:/windows/system32/"); } -void PathTest::testExpandUnix() +void PathTest::testExpandVariableFromPath() { +#ifdef POCO_OS_FAMILY_WINDOWS + std::string pathWithoutVar = "\\usr\\share\\O1%%\\folder"; + std::string pathWithVar = "%HOMEDRIVE%%HOMEPATH%\\folder"; + std::string correctStringWithoutVar = "\\usr\\share\\O1%%\\folder"; +#elif defined(POCO_OS_FAMILY_UNIX) std::string pathWithoutVar = "/usr/share/O1\\$\\$/folder"; std::string pathWithVar = "${HOME}/folder"; - Path p; + std::string correctStringWithoutVar = "/usr/share/O1$$/folder"; +#else + return; +#endif + + Poco::Path p; std::string s = p.expand(pathWithoutVar); - assert (s == "/usr/share/O1$$/folder"); + assert(s == correctStringWithoutVar); s = p.expand(pathWithVar); - Path tmpPath = Path::home(); + Poco::Path tmpPath = Poco::Path::home(); tmpPath.append("folder"); - assert (s == tmpPath.toString()); + assert(s == tmpPath.toString()); } void PathTest::testParseWindows1() @@ -1653,7 +1663,7 @@ CppUnit::Test* PathTest::suite() CppUnit_addTest(pSuite, PathTest, testParseUnix3); CppUnit_addTest(pSuite, PathTest, testParseUnix4); CppUnit_addTest(pSuite, PathTest, testParseUnix5); - CppUnit_addTest(pSuite, PathTest, testExpandUnix); + CppUnit_addTest(pSuite, PathTest, testExpandVariableFromPath); CppUnit_addTest(pSuite, PathTest, testParseWindows1); CppUnit_addTest(pSuite, PathTest, testParseWindows2); CppUnit_addTest(pSuite, PathTest, testParseWindows3); diff --git a/Foundation/testsuite/src/PathTest.h b/Foundation/testsuite/src/PathTest.h index 5ae982043..11a053ae4 100644 --- a/Foundation/testsuite/src/PathTest.h +++ b/Foundation/testsuite/src/PathTest.h @@ -31,7 +31,7 @@ public: void testParseUnix3(); void testParseUnix4(); void testParseUnix5(); - void testExpandUnix(); + void testExpandVariableFromPath(); void testParseWindows1(); void testParseWindows2(); void testParseWindows3();