Skip to content

Commit

Permalink
IO: removed unused methods from File class and moved tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mgerhardy committed Feb 13, 2025
1 parent 3be7e36 commit e51a562
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 24 deletions.
12 changes: 0 additions & 12 deletions src/modules/io/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,6 @@ bool File::validHandle() const {
return _file != nullptr;
}

bool File::isAnyOf(const io::FormatDescription* desc) const {
const core::String& ext = extension();
while (desc->valid()) {
if (desc->matchesExtension(ext)) {
// TODO: isA check
return true;
}
++desc;
}
return false;
}

bool File::exists() const {
if (_mode == FileMode::Read || _mode == FileMode::SysRead) {
return _file != nullptr;
Expand Down
2 changes: 0 additions & 2 deletions src/modules/io/File.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ class File : public IOResource {
long tell() const;
long seek(long offset, int seekType) const;

bool isAnyOf(const io::FormatDescription* desc) const;

/**
* @return The FileMode the file was opened with
*/
Expand Down
10 changes: 0 additions & 10 deletions src/modules/io/tests/FileTest.cpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
#include "app/tests/AbstractTest.h"
#include "core/StringUtil.h"
#include "io/Filesystem.h"
#include "io/FormatDescription.h"
#include <gtest/gtest.h>

namespace io {

class FileTest : public app::AbstractTest {};

TEST_F(FileTest, testIsAnyOf) {
io::Filesystem fs;
fs.init("test", "test");

const io::FilePtr &img = fs.open("image.png");
EXPECT_TRUE(img->isAnyOf(io::format::images()));
EXPECT_FALSE(img->isAnyOf(io::format::lua()));
}

TEST_F(FileTest, testGetPath) {
io::Filesystem fs;
fs.init("test", "test");
Expand Down
5 changes: 5 additions & 0 deletions src/modules/io/tests/FormatDescriptionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ namespace io {
class FormatDescriptionTest: public testing::Test {
};

TEST_F(FormatDescriptionTest, testIsA) {
EXPECT_TRUE(isA("image.png", io::format::images()));
EXPECT_FALSE(isA("something.else", io::format::lua()));
}

TEST_F(FormatDescriptionTest, testIsImage) {
ASSERT_TRUE(isImage("foobar.PNG"));
ASSERT_TRUE(isImage("foobar.png"));
Expand Down

0 comments on commit e51a562

Please sign in to comment.