Skip to content

Commit

Permalink
tests(core): add FileSystem::move tests
Browse files Browse the repository at this point in the history
  • Loading branch information
roby2014 committed Apr 27, 2024
1 parent e20d59a commit 0992d2c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion core/tests/data/fs/file_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ TEST_CASE("data::FileSystem") // NOLINT(readability-function-size)
return 5;
}

REQUIRE(name == "newbaz");
auto correctName = name == "newbaz" || name == "qux_moved";
REQUIRE(correctName);
REQUIRE(parent == 2);
REQUIRE_FALSE(directory);
children[2] = 6;
Expand Down Expand Up @@ -364,6 +365,10 @@ TEST_CASE("data::FileSystem") // NOLINT(readability-function-size)
fillFileBuffers = true;
}

// Test move files
REQUIRE_FALSE(FileSystem::move("/dir/sub/arc/bar/newfiledoesntmatter", "/dir/sub/arc/bar/newbaz"));
REQUIRE_FALSE(FileSystem::move("/dir/sub/arc/bar/nonexistent", "/dir/sub/arc/bar/newfiledoesntmatter"));

// Cannot create a file with an invalid path.
REQUIRE(bar->create("/qux", false) == nullptr);

Expand All @@ -372,6 +377,11 @@ TEST_CASE("data::FileSystem") // NOLINT(readability-function-size)

// Check that "qux" was created correctly.
auto qux = FileSystem::find("/dir/sub/arc/bar/qux");

// move and move back
REQUIRE(FileSystem::move("/dir/sub/arc/bar/qux", "/dir/sub/arc/bar/qux_moved"));
REQUIRE(FileSystem::move("/dir/sub/arc/bar/qux_moved", "/dir/sub/arc/bar/qux"));

REQUIRE(qux != nullptr);
REQUIRE(qux->name() == "qux");
REQUIRE(qux->path() == "/dir/sub/arc/bar/qux");
Expand Down

0 comments on commit 0992d2c

Please sign in to comment.