Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions test/src/cfile/test_cfile.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

#include <gtest/gtest.h>

#include <cfile/cfile.h>

#include "util/FSTestFixture.h"

class CFileTest : public test::FSTestFixture {
public:
CFileTest() : test::FSTestFixture(0) {
pushModDir("cfile");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the hows and whys, but there seems to be something wrong with the ways directories are handled in these tests. Changing this line to pushModDir("cfile/temp_subdir") makes the temp_subdir tests work, and changing it to pushModDir("cfile/temp_subdir_vps") makes the temp_subdir_vps tests work. Added debugging statements say that all file lookup happens relative to test_data/cfile/, not relative to test_data/cfile/temp_subdir/ and test_data/cfile/temp_subdir_vps/ as it should.

However, I don't know why for example adding a test like ASSERT_TRUE(cf_exists_full("test.eff", CF_TYPE_ANY)) doesn't cause a(nother) failure. Debug output tells me that it looks in the wrong path (as described above), yet that doesn't cause the test to fail.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pushModDir simply adds another -mod parameter so it seems like the subdirectory implementation doesn't handle mods correctly.

}
};

TEST_F(CFileTest, temp_subdir) {
ASSERT_FALSE(cf_exists_full("test_001.dds", CF_TYPE_ANY));

ASSERT_TRUE(cf_set_temp_subdir_pathtype("test.eff"));

ASSERT_TRUE(cf_exists_full("test_001.dds", CF_TYPE_ANY));
}

TEST_F(CFileTest, temp_subdir_vps) {
ASSERT_FALSE(cf_exists_full("test_001.dds", CF_TYPE_ANY));

ASSERT_TRUE(cf_set_temp_subdir_pathtype("test.eff"));

ASSERT_TRUE(cf_exists_full("test_001.dds", CF_TYPE_ANY));
}
4 changes: 4 additions & 0 deletions test/src/source_groups.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ add_file_folder(root ""
test_stubs.cpp
)

add_file_folder(graphics "CFile"
cfile/test_cfile.cpp
)

add_file_folder(graphics "Globalincs"
globalincs/test_flagset.cpp
globalincs/test_safe_strings.cpp
Expand Down
1 change: 1 addition & 0 deletions test/test_data/cfile/temp_subdir/data/effects/test.eff
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dummy file
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dummy content
Binary file added test/test_data/cfile/temp_subdir_vps/test.vp
Binary file not shown.