enh(Net): additional tests for StreamSocket::sendFile()

This commit is contained in:
Günter Obiltschnig
2025-02-08 13:02:43 +01:00
parent 66c1d30bb4
commit a1abf9659d
2 changed files with 18 additions and 9 deletions

View File

@@ -736,7 +736,9 @@ void SocketTest::testSendFile()
ostr.close(); ostr.close();
Poco::FileInputStream istr(file.path()); Poco::FileInputStream istr(file.path());
ss.sendFile(istr); std::streamsize n = ss.sendFile(istr);
assertTrue (n == file.getSize());
istr.close(); istr.close();
ss.close(); ss.close();
@@ -771,7 +773,9 @@ void SocketTest::testSendFileLarge()
ostr.close(); ostr.close();
Poco::FileInputStream istr(file.path()); Poco::FileInputStream istr(file.path());
ss.sendFile(istr); std::streamsize n = ss.sendFile(istr);
assertTrue (n == file.getSize());
istr.close(); istr.close();
ss.close(); ss.close();
@@ -809,7 +813,9 @@ void SocketTest::testSendFileRange()
const std::streamsize count = 10000; const std::streamsize count = 10000;
Poco::FileInputStream istr(file.path()); Poco::FileInputStream istr(file.path());
ss.sendFile(istr, offset, count); std::streamsize n = ss.sendFile(istr, offset, count);
assertTrue (n == count);
istr.close(); istr.close();
ss.close(); ss.close();

View File

@@ -259,7 +259,9 @@ void SecureStreamSocketTest::testSendFile()
ostr.close(); ostr.close();
Poco::FileInputStream istr(file.path()); Poco::FileInputStream istr(file.path());
ss.sendFile(istr); std::streamsize n = ss.sendFile(istr);
assertTrue (n == file.getSize());
istr.close(); istr.close();
ss.close(); ss.close();
@@ -294,7 +296,9 @@ void SecureStreamSocketTest::testSendFileLarge()
ostr.close(); ostr.close();
Poco::FileInputStream istr(file.path()); Poco::FileInputStream istr(file.path());
ss.sendFile(istr); std::streamsize n = ss.sendFile(istr);
assertTrue (n == file.getSize());
istr.close(); istr.close();
ss.close(); ss.close();
@@ -332,7 +336,9 @@ void SecureStreamSocketTest::testSendFileRange()
const std::streamsize count = 10000; const std::streamsize count = 10000;
Poco::FileInputStream istr(file.path()); Poco::FileInputStream istr(file.path());
ss.sendFile(istr, offset, count); std::streamsize n = ss.sendFile(istr, offset, count);
assertTrue (n == count);
istr.close(); istr.close();
ss.close(); ss.close();
@@ -341,9 +347,6 @@ void SecureStreamSocketTest::testSendFileRange()
Poco::Thread::sleep(100); Poco::Thread::sleep(100);
} }
std::cout << "\n" << fileData.size() << std::endl;
std::cout << "\n" << CopyToStringConnection::data().size() << std::endl;
assertTrue (CopyToStringConnection::data() == fileData.substr(offset, count)); assertTrue (CopyToStringConnection::data() == fileData.substr(offset, count));
} }