Skip to content

Commit

Permalink
Coverage++
Browse files Browse the repository at this point in the history
  • Loading branch information
henricasanova committed May 21, 2024
1 parent 6cbe675 commit 15ec1ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/file_system_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ TEST_F(FileSystemTest, FileCreate) {
sg4::Actor::create("TestActor", host_, [this]() {
XBT_INFO("Create a 10MB file at /foo/foo.txt, which should fail");
ASSERT_THROW(this->fs_->create_file("/foo/foo.txt", "10MB"), sgfs::FileSystemException);
try {
this->fs_->create_file("/foo/foo.txt", "10MB");
} catch (sgfs::FileSystemException &e) {
auto msg = e.what(); // coverage
}
XBT_INFO("Create a 10MB file at /dev/a/foo.txt, which should fail");
ASSERT_THROW(this->fs_->create_file("/dev/a/foo.txt", "10MB"), sgfs::FileSystemException);
XBT_INFO("Create a 10kB file at /dev/a/foo.txt, which should work");
Expand Down Expand Up @@ -110,6 +115,7 @@ TEST_F(FileSystemTest, Directories) {
XBT_INFO("Create a 10kB file at /dev/a/b/c/faa.txt");
ASSERT_NO_THROW(fs_->create_file("/dev/a/b/c/faa.txt", "10kB"));
std::set<std::string> found_files;
ASSERT_THROW(found_files = fs_->list_files_in_directory("/dev/a/b/c_bogus"), sgfs::FileSystemException);
ASSERT_NO_THROW(found_files = fs_->list_files_in_directory("/dev/a/b/c"));
ASSERT_TRUE(found_files.find("foo.txt") != found_files.end());
ASSERT_TRUE(found_files.find("faa.txt") != found_files.end());
Expand Down
2 changes: 2 additions & 0 deletions test/seek_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ TEST_F(SeekTest, SeekandTell) {
std::shared_ptr<sgfs::File> file;
XBT_INFO("Create a 100kB file at /dev/a/foo.txt");
ASSERT_NO_THROW(this->fs_->create_file("/dev/a/foo.txt", "100kB"));
XBT_INFO("Opening a bogus file, which should fail");
ASSERT_THROW(file = fs_->open("/dev/a/foo_bogus.txt"), sgfs::FileSystemException);
XBT_INFO("Open File '/dev/a/foo.txt'");
ASSERT_NO_THROW(file = fs_->open("/dev/a/foo.txt"));
XBT_INFO("Check current position, should be 0");
Expand Down

0 comments on commit 15ec1ff

Please sign in to comment.