summaryrefslogtreecommitdiffstats
path: root/mmc_updater/src/tests/TestFileUtils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'mmc_updater/src/tests/TestFileUtils.cpp')
-rw-r--r--mmc_updater/src/tests/TestFileUtils.cpp33
1 files changed, 31 insertions, 2 deletions
diff --git a/mmc_updater/src/tests/TestFileUtils.cpp b/mmc_updater/src/tests/TestFileUtils.cpp
index 709acc5c..f8535a28 100644
--- a/mmc_updater/src/tests/TestFileUtils.cpp
+++ b/mmc_updater/src/tests/TestFileUtils.cpp
@@ -5,10 +5,39 @@
void TestFileUtils::testDirName()
{
+ std::string dirName;
+ std::string fileName;
+
#ifdef PLATFORM_WINDOWS
- std::string dirName = FileUtils::dirname("E:/Some Dir/App.exe");
- TEST_COMPARE(dirName,"E:/Some Dir/");
+ // absolute paths
+ dirName = FileUtils::dirname("E:/Some Dir/App.exe");
+ TEST_COMPARE(dirName,"E:/Some Dir");
+ fileName = FileUtils::fileName("E:/Some Dir/App.exe");
+ TEST_COMPARE(fileName,"App.exe");
+
+ dirName = FileUtils::dirname("C:/Users/kitteh/AppData/Local/Temp/MultiMC5-yidaaa/MultiMC.exe");
+ TEST_COMPARE(dirName,"C:/Users/kitteh/AppData/Local/Temp/MultiMC5-yidaaa");
+ fileName = FileUtils::fileName("C:/Users/kitteh/AppData/Local/Temp/MultiMC5-yidaaa/MultiMC.exe");
+ TEST_COMPARE(fileName,"MultiMC.exe");
+
+#else
+ // absolute paths
+ dirName = FileUtils::dirname("/home/tester/foo bar/baz");
+ TEST_COMPARE(dirName,"/home/tester/foo bar");
+ fileName = FileUtils::fileName("/home/tester/foo bar/baz");
+ TEST_COMPARE(fileName,"baz");
#endif
+ // current directory
+ dirName = FileUtils::dirname("App.exe");
+ TEST_COMPARE(dirName,".");
+ fileName = FileUtils::fileName("App.exe");
+ TEST_COMPARE(fileName,"App.exe");
+
+ // relative paths
+ dirName = FileUtils::dirname("Foo/App.exe");
+ TEST_COMPARE(dirName,"Foo");
+ fileName = FileUtils::fileName("Foo/App.exe");
+ TEST_COMPARE(fileName,"App.exe");
}
void TestFileUtils::testIsRelative()