예제 #1
0
파일: file_test.cpp 프로젝트: TRI0N/wwiv
TEST(FileTest, ExistsWildCard_Extension) {
    FileHelper helper;
    const string path = helper.CreateTempFile("msg00000.001", "msg00000.001");
    ASSERT_TRUE(File::Exists(path));

    string wildcard_path = StrCat(helper.TempDir(), File::pathSeparatorString, "msg*.001");
    ASSERT_TRUE(File::ExistsWildcard(wildcard_path)) << path << "; w: " << wildcard_path;

    wildcard_path = StrCat(helper.TempDir(), File::pathSeparatorString, "msg*.??1");
    ASSERT_TRUE(File::ExistsWildcard(wildcard_path)) << path << "; w: " << wildcard_path;
}
예제 #2
0
파일: file_test.cpp 프로젝트: TRI0N/wwiv
TEST(FileTest, SetCurrentDirectory) {
    char expected[MAX_PATH];
    getcwd(expected, MAX_PATH);
    string original_dir = File::current_directory();
    ASSERT_STREQ(expected, original_dir.c_str());

    FileHelper helper;
    File::set_current_directory(helper.TempDir());
    EXPECT_EQ(helper.TempDir(), File::current_directory());

    File::set_current_directory(original_dir);
}
예제 #3
0
파일: file_test.cpp 프로젝트: TRI0N/wwiv
TEST(FileTest, mkdir) {
    FileHelper helper;
    const string path = StrCat(helper.TempDir(), File::pathSeparatorString, "a");
    const string path_missing_middle = StrCat(helper.TempDir(), File::pathSeparatorString, "a",
                                       File::pathSeparatorString, "b", File::pathSeparatorString, "c");
    ASSERT_FALSE(File::Exists(path));

    ASSERT_TRUE(File::mkdir(path));
    ASSERT_TRUE(File::mkdir(path));  // 2nd time should still return true.
    EXPECT_FALSE(File::mkdir(path_missing_middle));  // Can't create missing path elements.

    ASSERT_TRUE(File::Exists(path));
}
예제 #4
0
파일: file_test.cpp 프로젝트: TRI0N/wwiv
TEST(FileTest, DoesNotExist_Static) {
    FileHelper file;
    string tmp = file.TempDir();
    GTEST_ASSERT_NE("", tmp);
    File dne(tmp, "doesnotexist");
    ASSERT_FALSE(File::Exists(dne.full_pathname()));
}
예제 #5
0
파일: file_test.cpp 프로젝트: TRI0N/wwiv
TEST(FileTest, Stream) {
    FileHelper file;
    File f(file.TempDir(), "newdir");
    std::stringstream s;
    s << f;
    ASSERT_EQ(f.full_pathname(), s.str());
}
예제 #6
0
파일: file_test.cpp 프로젝트: TRI0N/wwiv
TEST(FileTest, DoesNotExist) {
    FileHelper file;
    string tmp = file.TempDir();
    GTEST_ASSERT_NE("", tmp);
    File dne(tmp, "doesnotexist");
    ASSERT_FALSE(dne.Exists());
}
예제 #7
0
파일: file_test.cpp 프로젝트: TRI0N/wwiv
TEST(FileTest, GetParent) {
    static const string kFileName = this->test_info_->name();
    FileHelper helper;
    string path = helper.CreateTempFile(kFileName, "Hello World");
    File file(path);
    ASSERT_EQ(helper.TempDir(), file.GetParent());
}
예제 #8
0
파일: file_test.cpp 프로젝트: TRI0N/wwiv
TEST(FileTest, Exists_Static) {
    FileHelper file;
    string tmp = file.TempDir();
    GTEST_ASSERT_NE("", tmp);
    ASSERT_TRUE(file.Mkdir("newdir"));
    File dne(tmp, "newdir");
    ASSERT_TRUE(File::Exists(dne.full_pathname())) << dne.full_pathname();
}
예제 #9
0
파일: file_test.cpp 프로젝트: TRI0N/wwiv
TEST(FileTest, Exists) {
    FileHelper file;
    string tmp = file.TempDir();
    GTEST_ASSERT_NE("", tmp);
    ASSERT_TRUE(file.Mkdir("newdir"));
    File f(tmp, "newdir");
    ASSERT_TRUE(f.Exists()) << f.full_pathname();
}
예제 #10
0
파일: file_test.cpp 프로젝트: TRI0N/wwiv
TEST(FileTest, Exists_TrailingSlash) {
    FileHelper file;
    string tmp = file.TempDir();
    GTEST_ASSERT_NE("", tmp);
    ASSERT_TRUE(file.Mkdir("newdir"));
    File dne(tmp, "newdir");
    string path = StringPrintf("%s%c", dne.full_pathname().c_str(), File::pathSeparatorChar);
    ASSERT_TRUE(File::Exists(path)) << path;
}
예제 #11
0
파일: file_test.cpp 프로젝트: TRI0N/wwiv
TEST(FileTest, MakeAbsolutePath_AlreadyAbsolute) {
    static const string kFileName = this->test_info_->name();
    FileHelper helper;
    const string path = helper.CreateTempFile(kFileName, "Hello World");

    string relative(path);  // Note: relative == absolute path (path)
    File::MakeAbsolutePath(helper.TempDir(), &relative);
    EXPECT_EQ(path, relative);
}
예제 #12
0
파일: file_test.cpp 프로젝트: TRI0N/wwiv
TEST(FileTest, RealPath_Different) {
    static const string kFileName = this->test_info_->name();
    FileHelper helper;
    const string path = helper.CreateTempFile(kFileName, "Hello World");

    string realpath;
    // Add an extra ./ into the path.
    ASSERT_TRUE(File::RealPath(StrCat(helper.TempDir(), File::pathSeparatorString, ".", File::pathSeparatorString, kFileName), &realpath));
    EXPECT_EQ(path, realpath);
}
예제 #13
0
파일: file_test.cpp 프로젝트: TRI0N/wwiv
TEST(FileTest, mkdirs) {
    FileHelper helper;
    const string path = StrCat(helper.TempDir(), File::pathSeparatorString, "a",
                               File::pathSeparatorString, "b", File::pathSeparatorString, "c");
    ASSERT_FALSE(File::Exists(path));

    ASSERT_TRUE(File::mkdirs(path));
    ASSERT_TRUE(File::mkdirs(path));

    ASSERT_TRUE(File::Exists(path));
}