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()) {
|
switch (connectionInfo.getType()) {
|
||||||
case FileConnectionType::READ:
|
case FileConnectionType::READ:
|
||||||
handle->open(location.getLocation().read(), true);
|
handle->open(location.getLocation().read(), false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FileConnectionType::WRITE:
|
case FileConnectionType::WRITE:
|
||||||
handle->open(location.getLocation().read(), false);
|
handle->open(location.getLocation().read(), true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
@ -31,6 +31,7 @@ bool File::connect(const FileLocation& location, const FileConnectionType& conne
|
||||||
|
|
||||||
mStatus.setStatus(FileConnectionStatus::OPENED);
|
mStatus.setStatus(FileConnectionStatus::OPENED);
|
||||||
mHandle = handle;
|
mHandle = handle;
|
||||||
|
mConnectionType = connectionInfo;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ void FileSystemHandle::seekp(ualni in) {
|
||||||
|
|
||||||
void FileSystemHandle::read(int1* in, ualni size) {
|
void FileSystemHandle::read(int1* in, ualni size) {
|
||||||
auto strm = (std::fstream*) stream;
|
auto strm = (std::fstream*) stream;
|
||||||
strm->write(in, size);
|
strm->read(in, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileSystemHandle::write(const int1* in, ualni size) {
|
void FileSystemHandle::write(const int1* in, ualni size) {
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ namespace tp {
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual ~File() {
|
virtual ~File() {
|
||||||
File::disconnect();
|
if (mStatus.isOpened()) File::disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -6,20 +6,20 @@ using namespace tp;
|
||||||
|
|
||||||
TEST_DEF_STATIC(Simple) {
|
TEST_DEF_STATIC(Simple) {
|
||||||
|
|
||||||
int1 data[] = { 0, 1, 2, 3, 4 };
|
const int1* data = "abcde\0";
|
||||||
int1 dataRead[]{};
|
int1 dataRead[6]{};
|
||||||
|
|
||||||
{
|
{
|
||||||
File file;
|
File file;
|
||||||
file.connect(FileLocation(String("tmp2")), FileConnectionType(false));
|
file.connect(FileLocation(String("tmp2.txt")), FileConnectionType(false));
|
||||||
file.writeBytes(data, 5);
|
file.writeBytes(data, 6);
|
||||||
file.disconnect();
|
file.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
File file;
|
File file;
|
||||||
file.connect(FileLocation(String("tmp2")), FileConnectionType(true));
|
file.connect(FileLocation(String("tmp2.txt")), FileConnectionType(true));
|
||||||
file.readBytes(dataRead, 5);
|
file.readBytes(dataRead, 6);
|
||||||
file.disconnect();
|
file.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
|
|
||||||
#include "Testing.hpp"
|
#include "Testing.hpp"
|
||||||
#include "Utils.hpp"
|
#include "Storage.hpp"
|
||||||
|
|
||||||
void testLocalStorage();
|
void testLocalStorage();
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
tp::ModuleManifest* deps[] = { &tp::gModuleUtils, nullptr };
|
tp::ModuleManifest* deps[] = { &tp::gModuleStorage, nullptr };
|
||||||
tp::ModuleManifest testModule("StorageTest", nullptr, nullptr, deps);
|
tp::ModuleManifest testModule("StorageTest", nullptr, nullptr, deps);
|
||||||
|
|
||||||
if (!testModule.initialize()) {
|
if (!testModule.initialize()) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue