예제 #1
0
TEST(FileTest, IsAbsolute) {
  static const string kFileName = this->test_info_->name();
  FileHelper helper;
  const string path = helper.CreateTempFile(kFileName, "Hello World");

  EXPECT_TRUE(File::IsAbsolutePath(path));
  EXPECT_FALSE(File::IsAbsolutePath(kFileName));
}
예제 #2
0
TEST(FileTest, LastWriteTime_NotOpen) {
    static const string kHelloWorld = "Hello World";
    FileHelper helper;
    time_t now = time(nullptr);
    string path = helper.CreateTempFile(this->test_info_->name(), kHelloWorld);
    File file(path);
    ASSERT_LE(now, file.last_write_time());
}
예제 #3
0
파일: file_test.cpp 프로젝트: TRI0N/wwiv
TEST(FileTest, IsOpen_Open) {
    static const string kHelloWorld = "Hello World";
    FileHelper helper;
    string path = helper.CreateTempFile(this->test_info_->name(), kHelloWorld);
    File file(path);
    ASSERT_TRUE(file.Open(File::modeBinary | File::modeReadOnly));
    EXPECT_TRUE(file.IsOpen());
    EXPECT_TRUE((bool) file);
}
예제 #4
0
파일: file_test.cpp 프로젝트: TRI0N/wwiv
TEST(FileTest, RealPath_Same) {
    static const string kFileName = this->test_info_->name();
    FileHelper helper;
    const string path = helper.CreateTempFile(kFileName, "Hello World");

    string realpath;
    ASSERT_TRUE(File::RealPath(path, &realpath));
    EXPECT_EQ(path, realpath);
}
예제 #5
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);
}
예제 #6
0
파일: file_test.cpp 프로젝트: TRI0N/wwiv
TEST(FileTest, IsDirectory_Open) {
    static const string kHelloWorld = "Hello World";
    FileHelper helper;
    string path = helper.CreateTempFile(this->test_info_->name(), kHelloWorld);
    File file(path);
    ASSERT_TRUE(file.Open(File::modeBinary | File::modeReadOnly));
    ASSERT_FALSE(file.IsDirectory());
    ASSERT_TRUE(file.IsFile());
}
예제 #7
0
파일: file_test.cpp 프로젝트: TRI0N/wwiv
TEST(FileTest, Length_Open) {
    static const string kHelloWorld = "Hello World";
    FileHelper helper;
    string path = helper.CreateTempFile(this->test_info_->name(), kHelloWorld);
    File file(path);
    ASSERT_TRUE(file.Open(File::modeBinary | File::modeReadOnly));
    ASSERT_EQ(static_cast<long>(kHelloWorld.size()),
              file.GetLength());
}
예제 #8
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);
}
예제 #9
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;
}
예제 #10
0
TEST(PPPConfigTest, NodeConfig) {
  FileHelper files;
  files.Mkdir("network");
  const string line("@2 [email protected]");
  files.CreateTempFile("network/address.net", line);
  const string network_dir = files.DirName("network");
  PPPConfig config(1, "mybbs", network_dir);
  const PPPNodeConfig* node_config = config.node_config_for(2);
  ASSERT_TRUE(node_config != nullptr);
  EXPECT_EQ("*****@*****.**", node_config->email_address);
}
예제 #11
0
파일: file_test.cpp 프로젝트: TRI0N/wwiv
TEST(FileTest, Read) {
    static const string kHelloWorld = "Hello World";
    FileHelper helper;
    string path = helper.CreateTempFile(this->test_info_->name(), kHelloWorld);
    File file(path);
    ASSERT_TRUE(file.Open(File::modeBinary | File::modeReadOnly));
    char buf[255];
    ASSERT_EQ(static_cast<int>(kHelloWorld.length()),
              file.Read(buf, kHelloWorld.length()));
    buf[11] = 0;
    ASSERT_STREQ(kHelloWorld.c_str(), buf);
}
예제 #12
0
TEST_F(CalloutTest, NodeConfig) {
  FileHelper files;
  files.Mkdir("network");
  const string line("@1 & \"foo\"");
  files.CreateTempFile("network/callout.net", line);
  const string network_dir = files.DirName("network");
  Callout callout(network_dir);
  const net_call_out_rec* con = callout.node_config_for(1);
  ASSERT_TRUE(con != nullptr);
  EXPECT_EQ(options_sendback, con->options);
  EXPECT_STREQ("foo", con->password);
}