Fix File test
This commit is contained in:
parent
8e00882bb3
commit
62cb2bb8b7
5 changed files with 13 additions and 12 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ namespace tp {
|
|||
};
|
||||
|
||||
virtual ~File() {
|
||||
File::disconnect();
|
||||
if (mStatus.isOpened()) File::disconnect();
|
||||
}
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue