diff options
Diffstat (limited to 'Source/kwsys/testSystemTools.cxx')
-rw-r--r-- | Source/kwsys/testSystemTools.cxx | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx index e6fbf6c..1871f5d 100644 --- a/Source/kwsys/testSystemTools.cxx +++ b/Source/kwsys/testSystemTools.cxx @@ -758,6 +758,30 @@ static bool CheckGetPath() return res; } +static bool CheckGetFilenameName() +{ + const char* windowsFilepath = "C:\\somewhere\\something"; + const char* unixFilepath = "/somewhere/something"; + + std::string expectedFilename = "something"; + + bool res = true; + std::string filename = kwsys::SystemTools::GetFilenameName(windowsFilepath); + if (filename != expectedFilename) { + std::cerr << "GetFilenameName(" << windowsFilepath << ") yielded " + << filename << " instead of " << expectedFilename << std::endl; + res = false; + } + + filename = kwsys::SystemTools::GetFilenameName(unixFilepath); + if (filename != expectedFilename) { + std::cerr << "GetFilenameName(" << unixFilepath << ") yielded " << filename + << " instead of " << expectedFilename << std::endl; + res = false; + } + return res; +} + static bool CheckFind() { bool res = true; @@ -875,5 +899,7 @@ int testSystemTools(int, char* []) res &= CheckGetLineFromStream(); + res &= CheckGetFilenameName(); + return res ? 0 : 1; } |