Fix File test

This commit is contained in:
IlushaShurupov 2023-07-18 23:48:54 +03:00
parent 8e00882bb3
commit 62cb2bb8b7
5 changed files with 13 additions and 12 deletions

View file

@ -12,11 +12,11 @@ bool File::connect(const FileLocation& location, const FileConnectionType& conne
switch (connectionInfo.getType()) {
case FileConnectionType::READ:
handle->open(location.getLocation().read(), true);
handle->open(location.getLocation().read(), false);
break;
case FileConnectionType::WRITE:
handle->open(location.getLocation().read(), false);
handle->open(location.getLocation().read(), true);
break;
default:
@ -31,6 +31,7 @@ bool File::connect(const FileLocation& location, const FileConnectionType& conne
mStatus.setStatus(FileConnectionStatus::OPENED);
mHandle = handle;
mConnectionType = connectionInfo;
return true;
}

View file

@ -40,7 +40,7 @@ void FileSystemHandle::seekp(ualni in) {
void FileSystemHandle::read(int1* in, ualni size) {
auto strm = (std::fstream*) stream;
strm->write(in, size);
strm->read(in, size);
}
void FileSystemHandle::write(const int1* in, ualni size) {

View file

@ -75,7 +75,7 @@ namespace tp {
};
virtual ~File() {
File::disconnect();
if (mStatus.isOpened()) File::disconnect();
}
public:

View file

@ -6,20 +6,20 @@ using namespace tp;
TEST_DEF_STATIC(Simple) {
int1 data[] = { 0, 1, 2, 3, 4 };
int1 dataRead[]{};
const int1* data = "abcde\0";
int1 dataRead[6]{};
{
File file;
file.connect(FileLocation(String("tmp2")), FileConnectionType(false));
file.writeBytes(data, 5);
file.connect(FileLocation(String("tmp2.txt")), FileConnectionType(false));
file.writeBytes(data, 6);
file.disconnect();
}
{
File file;
file.connect(FileLocation(String("tmp2")), FileConnectionType(true));
file.readBytes(dataRead, 5);
file.connect(FileLocation(String("tmp2.txt")), FileConnectionType(true));
file.readBytes(dataRead, 6);
file.disconnect();
}

View file

@ -1,12 +1,12 @@
#include "Testing.hpp"
#include "Utils.hpp"
#include "Storage.hpp"
void testLocalStorage();
int main() {
tp::ModuleManifest* deps[] = { &tp::gModuleUtils, nullptr };
tp::ModuleManifest* deps[] = { &tp::gModuleStorage, nullptr };
tp::ModuleManifest testModule("StorageTest", nullptr, nullptr, deps);
if (!testModule.initialize()) {