Esempio n. 1
0
TEST(TestMemFile, EmptyFileInCache) {
  StaticContentCache::TheFileCache = std::make_shared<FileCache>();
  StaticContentCache::TheFileCache->write("/no/content/entry");

  MemFile mf;

  // The file itself...
  ASSERT_FALSE(mf.open("/no/content/entry", "r"));

  // ... and one of the automatically-created "directory" entries.
  ASSERT_FALSE(mf.open("/no/content", "r"));
}
Esempio n. 2
0
TEST(TestMemFile, RealFileInCache) {
  string temp_fn;
  ASSERT_TRUE(makeTempFile("123abc", &temp_fn));

  StaticContentCache::TheFileCache = std::make_shared<FileCache>();
  StaticContentCache::TheFileCache->write("/content", temp_fn.c_str());

  MemFile mf;
  ASSERT_TRUE(mf.open("/content", "r"));

  ASSERT_EQ(mf.getc(), '1');
  ASSERT_EQ(mf.getc(), '2');
  ASSERT_EQ(mf.getc(), '3');
  ASSERT_EQ(mf.getc(), 'a');
  ASSERT_EQ(mf.getc(), 'b');
  ASSERT_EQ(mf.getc(), 'c');

  ASSERT_EQ(mf.getc(), EOF);

  ASSERT_TRUE(mf.close());

  ASSERT_EQ(unlink(temp_fn.c_str()), 0);
}
Esempio n. 3
0
TEST(TestMemFile, NotInCache) {
  StaticContentCache::TheFileCache = std::make_shared<FileCache>();

  MemFile mf;
  ASSERT_FALSE(mf.open("/not/even/there", "r"));
}
Esempio n. 4
0
TEST(TestMemFile, BadOpenModes) {
  MemFile mf;
  ASSERT_FALSE(mf.open("/some/file1", "+"));
  ASSERT_FALSE(mf.open("/some/file2", "a"));
  ASSERT_FALSE(mf.open("/some/file3", "w"));
}
Esempio n. 5
0
TEST(TestMemFile, BadReadFromCache) {
  StaticContentCache::TheFileCache = std::make_shared<FileCache>();

  MemFile mf;
  ASSERT_FALSE(mf.open("/some/random/file", "r"));
}
Esempio n. 6
0
TEST(TestMemFile, NotInCache) {
  StaticContentCache::TheFileCache = FileCachePtr(new FileCache());

  MemFile mf;
  ASSERT_FALSE(mf.open("/not/even/there", "r"));
}
Esempio n. 7
0
TEST(TestMemFile, BadReadFromCache) {
  StaticContentCache::TheFileCache = FileCachePtr(new FileCache());

  MemFile mf;
  ASSERT_FALSE(mf.open("/some/random/file", "r"));
}