diff --git a/test/usvfs_global_test/usvfs_global_test.cpp b/test/usvfs_global_test/usvfs_global_test.cpp index c9292a8..3447e4b 100644 --- a/test/usvfs_global_test/usvfs_global_test.cpp +++ b/test/usvfs_global_test/usvfs_global_test.cpp @@ -5,6 +5,9 @@ #include "../usvfs_global_test_runner/gtest_utils.h" +// anonymous class that allow tests to access parameters (currently only where the +// virtualized data folder is) +// class { bool initialize(int argc, char* argv[]) @@ -54,6 +57,8 @@ TEST(BasicTest, SimpleTest) ASSERT_FALSE(exists(data / "info.txt")); } +// see https://github.com/ModOrganizer2/modorganizer/issues/2039 for context +// TEST(RedFileSystemTest, RedFileSystemTest) { const auto data = parameters.data(); @@ -63,9 +68,15 @@ TEST(RedFileSystemTest, RedFileSystemTest) ASSERT_TRUE(exists(hudpainter_path / "DEFAULT.json")); + // TEST.json does not exist, so will be created in overwrite - this mainly check that + // weakly_canonical returns the path under data/ and not the actual path under + // overwrite/ + // + // this relies on the hook for NtQueryInformationFile + // + ASSERT_FALSE(exists(hudpainter_path / "TEST.json")); ASSERT_EQ(hudpainter_path / "TEST.json", weakly_canonical(hudpainter_path / "TEST.json")); - write_content(hudpainter_path / "TEST.json", "{}"); } diff --git a/test/usvfs_global_test_runner/gtest_utils.h b/test/usvfs_global_test_runner/gtest_utils.h index 564e273..5837ca6 100644 --- a/test/usvfs_global_test_runner/gtest_utils.h +++ b/test/usvfs_global_test_runner/gtest_utils.h @@ -15,8 +15,15 @@ ::testing::AssertionResult AssertContentEquals(std::string_view expected, const std::filesystem::path& path, bool trim = true); +// macro to assert that the contents of two directories are identical - directories are +// compared recursively and file contents are compared (excluding extra spaces or lines +// in file) +// #define ASSERT_DIRECTORY_EQ(Expected, Actual) \ ASSERT_TRUE(AssertDirectoryEquals(Expected, Actual)) +// macro to assert that the contents of two files are identical (excluding extra space +// or lines in file) +// #define ASSERT_CONTENT_EQ(Expected, Path) \ ASSERT_TRUE(AssertContentEquals(Expected, Path)) \ No newline at end of file