etk/test/testFileSystem.cpp

43 lines
1.1 KiB
C++

/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license MPL v2.0 (see license file)
*/
#include <etest/etest.hpp>
#include <test-debug/debug.hpp>
#include <etk/fs/fileSystem.hpp>
TEST(TestFileSystem, checkHomePath) {
etk::String basicPath = getenv("HOME");
EXPECT_EQ(etk::fs::getHomePath(), basicPath);
}
TEST(TestFileSystem, checkTmpPath) {
EXPECT_EQ(etk::fs::getTemporaryPath(), "/tmp");
}
TEST(TestFileSystem, getBinaryName) {
EXPECT_EQ(etk::fs::getBinaryName(), "etk-test");
}
TEST(TestFileSystem, getBinaryPath) {
EXPECT_EQ(etk::fs::getBinaryPath().getString().split('/').size() > 2, true);
}
TEST(TestFileSystem, createDirectory) {
etk::Path pathRandom = etk::fs::getTemporaryRandomPath();
etk::Path path = pathRandom / "eee" / "kjlk" / "kjhkjh";
TEST_WARNING("path tmp: " << path);
EXPECT_EQ(etk::fs::exist(path), false);
EXPECT_EQ(etk::fs::makeDirectories(path), true);
EXPECT_EQ(etk::fs::exist(path), true);
EXPECT_EQ(etk::fs::removeDirectory(pathRandom, true), true);
EXPECT_EQ(etk::fs::exist(pathRandom), false);
EXPECT_EQ(etk::fs::exist(path), false);
}