fixed crash when working directory of unit tests is not set - fixes #601

This commit is contained in:
Mikulas Florek 2015-11-14 12:25:43 +01:00
parent 7cec190f5a
commit 92dc89b90c
2 changed files with 21 additions and 21 deletions

View file

@ -15,47 +15,47 @@ namespace Lumix
public:
DiskFile(DiskFileDevice& device, IAllocator& allocator) : m_device(device), m_allocator(allocator) {}
virtual IFileDevice& getDevice() override
IFileDevice& getDevice() override
{
return m_device;
}
virtual bool open(const char* path, Mode mode) override
bool open(const char* path, Mode mode) override
{
return m_file.open(path, mode, m_allocator);
}
virtual void close() override
void close() override
{
m_file.close();
}
virtual bool read(void* buffer, size_t size) override
bool read(void* buffer, size_t size) override
{
return m_file.read(buffer, size);
}
virtual bool write(const void* buffer, size_t size) override
bool write(const void* buffer, size_t size) override
{
return m_file.write(buffer, size);
}
virtual const void* getBuffer() const override
const void* getBuffer() const override
{
return nullptr;
}
virtual size_t size() override
size_t size() override
{
return m_file.size();
}
virtual size_t seek(SeekMode base, size_t pos) override
size_t seek(SeekMode base, size_t pos) override
{
return m_file.seek(base, pos);
}
virtual size_t pos() override
size_t pos() override
{
return m_file.pos();
}

View file

@ -16,38 +16,38 @@ namespace
Lumix::FS::IFile* file2 = disk_file_device.createFile(NULL);
// if it fails somewhere here, check whether you have set working directory
file1->open("unit_tests/texture/1.tga", Lumix::FS::Mode::OPEN_AND_READ);
file2->open("unit_tests/texture/2.tga", Lumix::FS::Mode::OPEN_AND_READ);
LUMIX_EXPECT_TRUE(file1->open("unit_tests/texture/1.tga", Lumix::FS::Mode::OPEN_AND_READ));
LUMIX_EXPECT_TRUE(file2->open("unit_tests/texture/2.tga", Lumix::FS::Mode::OPEN_AND_READ));
LUMIX_EXPECT_EQ(Lumix::Texture::compareTGA(allocator, file1, file2, 0), 0);
file1->close();
file2->close();
file1->open("unit_tests/texture/1.tga", Lumix::FS::Mode::OPEN_AND_READ);
file2->open("unit_tests/texture/3.tga", Lumix::FS::Mode::OPEN_AND_READ);
LUMIX_EXPECT_TRUE(file1->open("unit_tests/texture/1.tga", Lumix::FS::Mode::OPEN_AND_READ));
LUMIX_EXPECT_TRUE(file2->open("unit_tests/texture/3.tga", Lumix::FS::Mode::OPEN_AND_READ));
LUMIX_EXPECT_EQ(Lumix::Texture::compareTGA(allocator, file1, file2, 128), 51*51);
file1->close();
file2->close();
file1->open("unit_tests/texture/1.tga", Lumix::FS::Mode::OPEN_AND_READ);
file2->open("unit_tests/texture/4.tga", Lumix::FS::Mode::OPEN_AND_READ);
LUMIX_EXPECT_TRUE(file1->open("unit_tests/texture/1.tga", Lumix::FS::Mode::OPEN_AND_READ));
LUMIX_EXPECT_TRUE(file2->open("unit_tests/texture/4.tga", Lumix::FS::Mode::OPEN_AND_READ));
LUMIX_EXPECT_EQ(Lumix::Texture::compareTGA(allocator, file1, file2, 1), 512 * 512 >> 1);
file1->close();
file2->close();
file1->open("unit_tests/texture/1.tga", Lumix::FS::Mode::OPEN_AND_READ);
file2->open("unit_tests/texture/5.tga", Lumix::FS::Mode::OPEN_AND_READ);
LUMIX_EXPECT_TRUE(file1->open("unit_tests/texture/1.tga", Lumix::FS::Mode::OPEN_AND_READ));
LUMIX_EXPECT_TRUE(file2->open("unit_tests/texture/5.tga", Lumix::FS::Mode::OPEN_AND_READ));
LUMIX_EXPECT_EQ(Lumix::Texture::compareTGA(allocator, file1, file2, 250), 512*512);
file1->close();
file2->close();
file1->open("unit_tests/texture/6.tga", Lumix::FS::Mode::OPEN_AND_READ);
file2->open("unit_tests/texture/7.tga", Lumix::FS::Mode::OPEN_AND_READ);
LUMIX_EXPECT_TRUE(file1->open("unit_tests/texture/6.tga", Lumix::FS::Mode::OPEN_AND_READ));
LUMIX_EXPECT_TRUE(file2->open("unit_tests/texture/7.tga", Lumix::FS::Mode::OPEN_AND_READ));
LUMIX_EXPECT_EQ(Lumix::Texture::compareTGA(allocator, file1, file2, 0), 512*512);
file1->close();
file2->close();
file1->open("unit_tests/texture/6.tga", Lumix::FS::Mode::OPEN_AND_READ);
file2->open("unit_tests/texture/8.tga", Lumix::FS::Mode::OPEN_AND_READ);
LUMIX_EXPECT_TRUE(file1->open("unit_tests/texture/6.tga", Lumix::FS::Mode::OPEN_AND_READ));
LUMIX_EXPECT_TRUE(file2->open("unit_tests/texture/8.tga", Lumix::FS::Mode::OPEN_AND_READ));
LUMIX_EXPECT_EQ(Lumix::Texture::compareTGA(allocator, file1, file2, 0), 416);
file1->close();