mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-29 20:59:45 +01:00
make testsuite compile with C++03 compiler
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#undef min
|
||||
#include <algorithm>
|
||||
|
||||
@@ -38,7 +37,7 @@ CompressTest::~CompressTest()
|
||||
|
||||
void CompressTest::testSingleFile()
|
||||
{
|
||||
std::ofstream out(Poco::Path::temp() + "appinf.zip", std::ios::binary);
|
||||
Poco::FileOutputStream out(Poco::Path::temp() + "appinf.zip");
|
||||
Poco::Path theFile(ZipTest::getTestFile("data", "test.zip"));
|
||||
Compress c(out, true);
|
||||
c.addFile(theFile, theFile.getFileName());
|
||||
@@ -48,7 +47,7 @@ void CompressTest::testSingleFile()
|
||||
|
||||
void CompressTest::testDirectory()
|
||||
{
|
||||
std::ofstream out(Poco::Path::temp() + "pocobin.zip", std::ios::binary);
|
||||
Poco::FileOutputStream out(Poco::Path::temp() + "pocobin.zip");
|
||||
Poco::File aFile("some/");
|
||||
if (aFile.exists()) aFile.remove(true);
|
||||
Poco::File aDir("some/recursive/dir/");
|
||||
@@ -73,7 +72,7 @@ void CompressTest::testDirectory()
|
||||
void CompressTest::testManipulator()
|
||||
{
|
||||
{
|
||||
std::ofstream out(Poco::Path::temp() + "appinf.zip", std::ios::binary);
|
||||
Poco::FileOutputStream out(Poco::Path::temp() + "appinf.zip");
|
||||
Poco::Path theFile(ZipTest::getTestFile("data", "test.zip"));
|
||||
Compress c(out, true);
|
||||
c.addFile(theFile, theFile.getFileName());
|
||||
@@ -90,7 +89,7 @@ void CompressTest::testManipulator()
|
||||
void CompressTest::testManipulatorDel()
|
||||
{
|
||||
{
|
||||
std::ofstream out(Poco::Path::temp() + "appinf.zip", std::ios::binary);
|
||||
Poco::FileOutputStream out(Poco::Path::temp() + "appinf.zip");
|
||||
Poco::Path theFile(ZipTest::getTestFile("data", "test.zip"));
|
||||
Compress c(out, true);
|
||||
c.addFile(theFile, theFile.getFileName());
|
||||
@@ -108,7 +107,7 @@ void CompressTest::testManipulatorDel()
|
||||
void CompressTest::testManipulatorReplace()
|
||||
{
|
||||
{
|
||||
std::ofstream out(Poco::Path::temp() + "appinf.zip", std::ios::binary);
|
||||
Poco::FileOutputStream out(Poco::Path::temp() + "appinf.zip");
|
||||
Poco::Path theFile(ZipTest::getTestFile("data", "test.zip"));
|
||||
Compress c(out, true);
|
||||
c.addFile(theFile, theFile.getFileName());
|
||||
@@ -126,7 +125,7 @@ void CompressTest::testManipulatorReplace()
|
||||
void CompressTest::testSetZipComment()
|
||||
{
|
||||
std::string comment("Testing...123...");
|
||||
std::ofstream out(Poco::Path::temp() + "comment.zip", std::ios::binary);
|
||||
Poco::FileOutputStream out(Poco::Path::temp() + "comment.zip");
|
||||
Poco::Path theFile(ZipTest::getTestFile("data", "test.zip"));
|
||||
Compress c(out, true);
|
||||
c.addFile(theFile, theFile.getFileName());
|
||||
@@ -138,7 +137,7 @@ void CompressTest::testSetZipComment()
|
||||
|
||||
void CompressTest::createDataFile(const std::string& path, Poco::UInt64 size)
|
||||
{
|
||||
std::ofstream out(path.c_str(), std::ios::binary | std::ios::trunc);
|
||||
Poco::FileOutputStream out(path.c_str(), std::ios::trunc);
|
||||
assert( ! out.fail() );
|
||||
Poco::Buffer<char> buffer(MB);
|
||||
for(int i = 0; size != 0; i++) {
|
||||
@@ -169,7 +168,7 @@ void CompressTest::testZip64()
|
||||
std::cout << '\t' << "createDataFile(" << it->first << ", " << it->second << ");" << std::endl;
|
||||
createDataFile(it->first, it->second);
|
||||
}
|
||||
std::ofstream out(Poco::Path::temp() + "zip64.zip", std::ios::binary | std::ios::trunc);
|
||||
Poco::FileOutputStream out(Poco::Path::temp() + "zip64.zip", std::ios::trunc);
|
||||
Compress c(out, true, true);
|
||||
for(FileMap::const_iterator it = files.begin(); it != files.end(); it++)
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "Poco/Zip/ZipCommon.h"
|
||||
#include "Poco/StreamCopier.h"
|
||||
#include "Poco/File.h"
|
||||
#include "Poco/FileStream.h"
|
||||
#include "Poco/URI.h"
|
||||
#include "Poco/Path.h"
|
||||
#include "Poco/Delegate.h"
|
||||
@@ -27,7 +28,6 @@
|
||||
#undef min
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ ZipTest::~ZipTest()
|
||||
void ZipTest::testSkipSingleFile()
|
||||
{
|
||||
std::string testFile = getTestFile("data", "test.zip");
|
||||
std::ifstream inp(testFile.c_str(), std::ios::binary);
|
||||
Poco::FileInputStream inp(testFile);
|
||||
assert (inp.good());
|
||||
SkipCallback skip;
|
||||
ZipLocalFileHeader hdr(inp, false, skip);
|
||||
@@ -69,7 +69,7 @@ void ZipTest::testSkipSingleFile()
|
||||
void ZipTest::testDecompressSingleFile()
|
||||
{
|
||||
std::string testFile = getTestFile("data", "test.zip");
|
||||
std::ifstream inp(testFile.c_str(), std::ios::binary);
|
||||
Poco::FileInputStream inp(testFile);
|
||||
assert (inp.good());
|
||||
ZipArchive arch(inp);
|
||||
ZipArchive::FileHeaders::const_iterator it = arch.findHeader("testfile.txt");
|
||||
@@ -84,7 +84,7 @@ void ZipTest::testDecompressSingleFile()
|
||||
void ZipTest::testDecompressSingleFileInDir()
|
||||
{
|
||||
std::string testFile = getTestFile("data","test.zip");
|
||||
std::ifstream inp(testFile.c_str(), std::ios::binary);
|
||||
Poco::FileInputStream inp(testFile);
|
||||
assert (inp.good());
|
||||
ZipArchive arch(inp);
|
||||
ZipArchive::FileHeaders::const_iterator it = arch.findHeader("testdir/testfile.txt");
|
||||
@@ -99,7 +99,7 @@ void ZipTest::testDecompressSingleFileInDir()
|
||||
void ZipTest::testCrcAndSizeAfterData()
|
||||
{
|
||||
std::string testFile = getTestFile("data", "data.zip");
|
||||
std::ifstream inp(testFile.c_str(), std::ios::binary);
|
||||
Poco::FileInputStream inp(testFile);
|
||||
assert (inp.good());
|
||||
Decompress dec(inp, Poco::Path::temp());
|
||||
dec.EError += Poco::Delegate<ZipTest, std::pair<const Poco::Zip::ZipLocalFileHeader, const std::string> >(this, &ZipTest::onDecompressError);
|
||||
@@ -113,7 +113,7 @@ void ZipTest::testCrcAndSizeAfterData()
|
||||
void ZipTest::testCrcAndSizeAfterDataWithArchive()
|
||||
{
|
||||
std::string testFile = getTestFile("data", "data.zip");
|
||||
std::ifstream inp(testFile.c_str(), std::ios::binary);
|
||||
Poco::FileInputStream inp(testFile);
|
||||
assert (inp.good());
|
||||
Poco::Zip::ZipArchive zip(inp);
|
||||
inp.clear();
|
||||
@@ -125,7 +125,7 @@ void ZipTest::testCrcAndSizeAfterDataWithArchive()
|
||||
Poco::Path path(it->second.getFileName());
|
||||
if (path.isFile())
|
||||
{
|
||||
std::ofstream os(Poco::Path::temp() + "test.dat");
|
||||
Poco::FileOutputStream os(Poco::Path::temp() + "test.dat");
|
||||
Poco::StreamCopier::copyStream(zipis,os);
|
||||
}
|
||||
}
|
||||
@@ -160,7 +160,7 @@ std::string ZipTest::getTestFile(const std::string& directory, const std::string
|
||||
void ZipTest::testDecompress()
|
||||
{
|
||||
std::string testFile = getTestFile("data", "test.zip");
|
||||
std::ifstream inp(testFile.c_str(), std::ios::binary);
|
||||
Poco::FileInputStream inp(testFile);
|
||||
assert (inp.good());
|
||||
Decompress dec(inp, Poco::Path::temp());
|
||||
dec.EError += Poco::Delegate<ZipTest, std::pair<const Poco::Zip::ZipLocalFileHeader, const std::string> >(this, &ZipTest::onDecompressError);
|
||||
@@ -174,7 +174,7 @@ void ZipTest::testDecompress()
|
||||
void ZipTest::testDecompressFlat()
|
||||
{
|
||||
std::string testFile = getTestFile("data", "test.zip");
|
||||
std::ifstream inp(testFile.c_str(), std::ios::binary);
|
||||
Poco::FileInputStream inp(testFile);
|
||||
assert (inp.good());
|
||||
Decompress dec(inp, Poco::Path::temp(), true);
|
||||
dec.EError += Poco::Delegate<ZipTest, std::pair<const Poco::Zip::ZipLocalFileHeader, const std::string> >(this, &ZipTest::onDecompressError);
|
||||
@@ -188,7 +188,7 @@ void ZipTest::testDecompressFlat()
|
||||
void ZipTest::testDecompressVuln()
|
||||
{
|
||||
std::string testFile = getTestFile("data", "vuln.zip");
|
||||
std::ifstream inp(testFile.c_str(), std::ios::binary);
|
||||
Poco::FileInputStream inp(testFile);
|
||||
assert(inp.good());
|
||||
Decompress dec(inp, Poco::Path::temp());
|
||||
dec.EError += Poco::Delegate<ZipTest, std::pair<const Poco::Zip::ZipLocalFileHeader, const std::string> >(this, &ZipTest::onDecompressError);
|
||||
@@ -202,7 +202,7 @@ void ZipTest::testDecompressVuln()
|
||||
void ZipTest::testDecompressFlatVuln()
|
||||
{
|
||||
std::string testFile = getTestFile("data", "vuln.zip");
|
||||
std::ifstream inp(testFile.c_str(), std::ios::binary);
|
||||
Poco::FileInputStream inp(testFile);
|
||||
assert(inp.good());
|
||||
Decompress dec(inp, Poco::Path::temp(), true);
|
||||
dec.EError += Poco::Delegate<ZipTest, std::pair<const Poco::Zip::ZipLocalFileHeader, const std::string> >(this, &ZipTest::onDecompressError);
|
||||
@@ -215,7 +215,7 @@ void ZipTest::testDecompressFlatVuln()
|
||||
|
||||
void ZipTest::verifyDataFile(const std::string& path, Poco::UInt64 size)
|
||||
{
|
||||
std::ifstream in(path.c_str(), std::ios::binary);
|
||||
Poco::FileInputStream in(path);
|
||||
assert( ! in.fail() );
|
||||
Poco::Buffer<char> buffer1(MB);
|
||||
Poco::Buffer<char> buffer2(MB);
|
||||
@@ -248,7 +248,7 @@ void ZipTest::testDecompressZip64()
|
||||
if(file.exists())
|
||||
file.remove();
|
||||
}
|
||||
std::ifstream in(Poco::Path::temp() + "zip64.zip", std::ios::binary);
|
||||
Poco::FileInputStream in(Poco::Path::temp() + "zip64.zip");
|
||||
Decompress c(in, Poco::Path::temp());
|
||||
c.decompressAllFiles();
|
||||
for(std::map<std::string, Poco::UInt64>::const_iterator it = files.begin(); it != files.end(); it++)
|
||||
|
||||
Reference in New Issue
Block a user