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/TestCaller.h"
|
||||||
#include "CppUnit/TestSuite.h"
|
#include "CppUnit/TestSuite.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
|
||||||
#undef min
|
#undef min
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@@ -38,7 +37,7 @@ CompressTest::~CompressTest()
|
|||||||
|
|
||||||
void CompressTest::testSingleFile()
|
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"));
|
Poco::Path theFile(ZipTest::getTestFile("data", "test.zip"));
|
||||||
Compress c(out, true);
|
Compress c(out, true);
|
||||||
c.addFile(theFile, theFile.getFileName());
|
c.addFile(theFile, theFile.getFileName());
|
||||||
@@ -48,7 +47,7 @@ void CompressTest::testSingleFile()
|
|||||||
|
|
||||||
void CompressTest::testDirectory()
|
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/");
|
Poco::File aFile("some/");
|
||||||
if (aFile.exists()) aFile.remove(true);
|
if (aFile.exists()) aFile.remove(true);
|
||||||
Poco::File aDir("some/recursive/dir/");
|
Poco::File aDir("some/recursive/dir/");
|
||||||
@@ -73,7 +72,7 @@ void CompressTest::testDirectory()
|
|||||||
void CompressTest::testManipulator()
|
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"));
|
Poco::Path theFile(ZipTest::getTestFile("data", "test.zip"));
|
||||||
Compress c(out, true);
|
Compress c(out, true);
|
||||||
c.addFile(theFile, theFile.getFileName());
|
c.addFile(theFile, theFile.getFileName());
|
||||||
@@ -90,7 +89,7 @@ void CompressTest::testManipulator()
|
|||||||
void CompressTest::testManipulatorDel()
|
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"));
|
Poco::Path theFile(ZipTest::getTestFile("data", "test.zip"));
|
||||||
Compress c(out, true);
|
Compress c(out, true);
|
||||||
c.addFile(theFile, theFile.getFileName());
|
c.addFile(theFile, theFile.getFileName());
|
||||||
@@ -108,7 +107,7 @@ void CompressTest::testManipulatorDel()
|
|||||||
void CompressTest::testManipulatorReplace()
|
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"));
|
Poco::Path theFile(ZipTest::getTestFile("data", "test.zip"));
|
||||||
Compress c(out, true);
|
Compress c(out, true);
|
||||||
c.addFile(theFile, theFile.getFileName());
|
c.addFile(theFile, theFile.getFileName());
|
||||||
@@ -116,7 +115,7 @@ void CompressTest::testManipulatorReplace()
|
|||||||
}
|
}
|
||||||
ZipManipulator zm(Poco::Path::temp() + "appinf.zip", true);
|
ZipManipulator zm(Poco::Path::temp() + "appinf.zip", true);
|
||||||
zm.replaceFile("test.zip", ZipTest::getTestFile("data", "doc.zip"));
|
zm.replaceFile("test.zip", ZipTest::getTestFile("data", "doc.zip"));
|
||||||
|
|
||||||
ZipArchive archive=zm.commit();
|
ZipArchive archive=zm.commit();
|
||||||
assert (archive.findHeader("test.zip") != archive.headerEnd());
|
assert (archive.findHeader("test.zip") != archive.headerEnd());
|
||||||
assert (archive.findHeader("doc.zip") == archive.headerEnd());
|
assert (archive.findHeader("doc.zip") == archive.headerEnd());
|
||||||
@@ -126,7 +125,7 @@ void CompressTest::testManipulatorReplace()
|
|||||||
void CompressTest::testSetZipComment()
|
void CompressTest::testSetZipComment()
|
||||||
{
|
{
|
||||||
std::string comment("Testing...123...");
|
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"));
|
Poco::Path theFile(ZipTest::getTestFile("data", "test.zip"));
|
||||||
Compress c(out, true);
|
Compress c(out, true);
|
||||||
c.addFile(theFile, theFile.getFileName());
|
c.addFile(theFile, theFile.getFileName());
|
||||||
@@ -138,7 +137,7 @@ void CompressTest::testSetZipComment()
|
|||||||
|
|
||||||
void CompressTest::createDataFile(const std::string& path, Poco::UInt64 size)
|
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() );
|
assert( ! out.fail() );
|
||||||
Poco::Buffer<char> buffer(MB);
|
Poco::Buffer<char> buffer(MB);
|
||||||
for(int i = 0; size != 0; i++) {
|
for(int i = 0; size != 0; i++) {
|
||||||
@@ -163,13 +162,13 @@ void CompressTest::testZip64()
|
|||||||
files["data1.bin"] = static_cast<Poco::UInt64>(KB)*4096+1;
|
files["data1.bin"] = static_cast<Poco::UInt64>(KB)*4096+1;
|
||||||
files["data2.bin"] = static_cast<Poco::UInt64>(KB)*16;
|
files["data2.bin"] = static_cast<Poco::UInt64>(KB)*16;
|
||||||
files["data3.bin"] = static_cast<Poco::UInt64>(KB)*4096-1;
|
files["data3.bin"] = static_cast<Poco::UInt64>(KB)*4096-1;
|
||||||
|
|
||||||
for(FileMap::const_iterator it = files.begin(); it != files.end(); it++)
|
for(FileMap::const_iterator it = files.begin(); it != files.end(); it++)
|
||||||
{
|
{
|
||||||
std::cout << '\t' << "createDataFile(" << it->first << ", " << it->second << ");" << std::endl;
|
std::cout << '\t' << "createDataFile(" << it->first << ", " << it->second << ");" << std::endl;
|
||||||
createDataFile(it->first, it->second);
|
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);
|
Compress c(out, true, true);
|
||||||
for(FileMap::const_iterator it = files.begin(); it != files.end(); it++)
|
for(FileMap::const_iterator it = files.begin(); it != files.end(); it++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#include "Poco/Zip/ZipCommon.h"
|
#include "Poco/Zip/ZipCommon.h"
|
||||||
#include "Poco/StreamCopier.h"
|
#include "Poco/StreamCopier.h"
|
||||||
#include "Poco/File.h"
|
#include "Poco/File.h"
|
||||||
|
#include "Poco/FileStream.h"
|
||||||
#include "Poco/URI.h"
|
#include "Poco/URI.h"
|
||||||
#include "Poco/Path.h"
|
#include "Poco/Path.h"
|
||||||
#include "Poco/Delegate.h"
|
#include "Poco/Delegate.h"
|
||||||
@@ -27,7 +28,6 @@
|
|||||||
#undef min
|
#undef min
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ ZipTest::~ZipTest()
|
|||||||
void ZipTest::testSkipSingleFile()
|
void ZipTest::testSkipSingleFile()
|
||||||
{
|
{
|
||||||
std::string testFile = getTestFile("data", "test.zip");
|
std::string testFile = getTestFile("data", "test.zip");
|
||||||
std::ifstream inp(testFile.c_str(), std::ios::binary);
|
Poco::FileInputStream inp(testFile);
|
||||||
assert (inp.good());
|
assert (inp.good());
|
||||||
SkipCallback skip;
|
SkipCallback skip;
|
||||||
ZipLocalFileHeader hdr(inp, false, skip);
|
ZipLocalFileHeader hdr(inp, false, skip);
|
||||||
@@ -69,7 +69,7 @@ void ZipTest::testSkipSingleFile()
|
|||||||
void ZipTest::testDecompressSingleFile()
|
void ZipTest::testDecompressSingleFile()
|
||||||
{
|
{
|
||||||
std::string testFile = getTestFile("data", "test.zip");
|
std::string testFile = getTestFile("data", "test.zip");
|
||||||
std::ifstream inp(testFile.c_str(), std::ios::binary);
|
Poco::FileInputStream inp(testFile);
|
||||||
assert (inp.good());
|
assert (inp.good());
|
||||||
ZipArchive arch(inp);
|
ZipArchive arch(inp);
|
||||||
ZipArchive::FileHeaders::const_iterator it = arch.findHeader("testfile.txt");
|
ZipArchive::FileHeaders::const_iterator it = arch.findHeader("testfile.txt");
|
||||||
@@ -84,7 +84,7 @@ void ZipTest::testDecompressSingleFile()
|
|||||||
void ZipTest::testDecompressSingleFileInDir()
|
void ZipTest::testDecompressSingleFileInDir()
|
||||||
{
|
{
|
||||||
std::string testFile = getTestFile("data","test.zip");
|
std::string testFile = getTestFile("data","test.zip");
|
||||||
std::ifstream inp(testFile.c_str(), std::ios::binary);
|
Poco::FileInputStream inp(testFile);
|
||||||
assert (inp.good());
|
assert (inp.good());
|
||||||
ZipArchive arch(inp);
|
ZipArchive arch(inp);
|
||||||
ZipArchive::FileHeaders::const_iterator it = arch.findHeader("testdir/testfile.txt");
|
ZipArchive::FileHeaders::const_iterator it = arch.findHeader("testdir/testfile.txt");
|
||||||
@@ -99,7 +99,7 @@ void ZipTest::testDecompressSingleFileInDir()
|
|||||||
void ZipTest::testCrcAndSizeAfterData()
|
void ZipTest::testCrcAndSizeAfterData()
|
||||||
{
|
{
|
||||||
std::string testFile = getTestFile("data", "data.zip");
|
std::string testFile = getTestFile("data", "data.zip");
|
||||||
std::ifstream inp(testFile.c_str(), std::ios::binary);
|
Poco::FileInputStream inp(testFile);
|
||||||
assert (inp.good());
|
assert (inp.good());
|
||||||
Decompress dec(inp, Poco::Path::temp());
|
Decompress dec(inp, Poco::Path::temp());
|
||||||
dec.EError += Poco::Delegate<ZipTest, std::pair<const Poco::Zip::ZipLocalFileHeader, const std::string> >(this, &ZipTest::onDecompressError);
|
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()
|
void ZipTest::testCrcAndSizeAfterDataWithArchive()
|
||||||
{
|
{
|
||||||
std::string testFile = getTestFile("data", "data.zip");
|
std::string testFile = getTestFile("data", "data.zip");
|
||||||
std::ifstream inp(testFile.c_str(), std::ios::binary);
|
Poco::FileInputStream inp(testFile);
|
||||||
assert (inp.good());
|
assert (inp.good());
|
||||||
Poco::Zip::ZipArchive zip(inp);
|
Poco::Zip::ZipArchive zip(inp);
|
||||||
inp.clear();
|
inp.clear();
|
||||||
@@ -125,7 +125,7 @@ void ZipTest::testCrcAndSizeAfterDataWithArchive()
|
|||||||
Poco::Path path(it->second.getFileName());
|
Poco::Path path(it->second.getFileName());
|
||||||
if (path.isFile())
|
if (path.isFile())
|
||||||
{
|
{
|
||||||
std::ofstream os(Poco::Path::temp() + "test.dat");
|
Poco::FileOutputStream os(Poco::Path::temp() + "test.dat");
|
||||||
Poco::StreamCopier::copyStream(zipis,os);
|
Poco::StreamCopier::copyStream(zipis,os);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -160,7 +160,7 @@ std::string ZipTest::getTestFile(const std::string& directory, const std::string
|
|||||||
void ZipTest::testDecompress()
|
void ZipTest::testDecompress()
|
||||||
{
|
{
|
||||||
std::string testFile = getTestFile("data", "test.zip");
|
std::string testFile = getTestFile("data", "test.zip");
|
||||||
std::ifstream inp(testFile.c_str(), std::ios::binary);
|
Poco::FileInputStream inp(testFile);
|
||||||
assert (inp.good());
|
assert (inp.good());
|
||||||
Decompress dec(inp, Poco::Path::temp());
|
Decompress dec(inp, Poco::Path::temp());
|
||||||
dec.EError += Poco::Delegate<ZipTest, std::pair<const Poco::Zip::ZipLocalFileHeader, const std::string> >(this, &ZipTest::onDecompressError);
|
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()
|
void ZipTest::testDecompressFlat()
|
||||||
{
|
{
|
||||||
std::string testFile = getTestFile("data", "test.zip");
|
std::string testFile = getTestFile("data", "test.zip");
|
||||||
std::ifstream inp(testFile.c_str(), std::ios::binary);
|
Poco::FileInputStream inp(testFile);
|
||||||
assert (inp.good());
|
assert (inp.good());
|
||||||
Decompress dec(inp, Poco::Path::temp(), true);
|
Decompress dec(inp, Poco::Path::temp(), true);
|
||||||
dec.EError += Poco::Delegate<ZipTest, std::pair<const Poco::Zip::ZipLocalFileHeader, const std::string> >(this, &ZipTest::onDecompressError);
|
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()
|
void ZipTest::testDecompressVuln()
|
||||||
{
|
{
|
||||||
std::string testFile = getTestFile("data", "vuln.zip");
|
std::string testFile = getTestFile("data", "vuln.zip");
|
||||||
std::ifstream inp(testFile.c_str(), std::ios::binary);
|
Poco::FileInputStream inp(testFile);
|
||||||
assert(inp.good());
|
assert(inp.good());
|
||||||
Decompress dec(inp, Poco::Path::temp());
|
Decompress dec(inp, Poco::Path::temp());
|
||||||
dec.EError += Poco::Delegate<ZipTest, std::pair<const Poco::Zip::ZipLocalFileHeader, const std::string> >(this, &ZipTest::onDecompressError);
|
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()
|
void ZipTest::testDecompressFlatVuln()
|
||||||
{
|
{
|
||||||
std::string testFile = getTestFile("data", "vuln.zip");
|
std::string testFile = getTestFile("data", "vuln.zip");
|
||||||
std::ifstream inp(testFile.c_str(), std::ios::binary);
|
Poco::FileInputStream inp(testFile);
|
||||||
assert(inp.good());
|
assert(inp.good());
|
||||||
Decompress dec(inp, Poco::Path::temp(), true);
|
Decompress dec(inp, Poco::Path::temp(), true);
|
||||||
dec.EError += Poco::Delegate<ZipTest, std::pair<const Poco::Zip::ZipLocalFileHeader, const std::string> >(this, &ZipTest::onDecompressError);
|
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)
|
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() );
|
assert( ! in.fail() );
|
||||||
Poco::Buffer<char> buffer1(MB);
|
Poco::Buffer<char> buffer1(MB);
|
||||||
Poco::Buffer<char> buffer2(MB);
|
Poco::Buffer<char> buffer2(MB);
|
||||||
@@ -248,7 +248,7 @@ void ZipTest::testDecompressZip64()
|
|||||||
if(file.exists())
|
if(file.exists())
|
||||||
file.remove();
|
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());
|
Decompress c(in, Poco::Path::temp());
|
||||||
c.decompressAllFiles();
|
c.decompressAllFiles();
|
||||||
for(std::map<std::string, Poco::UInt64>::const_iterator it = files.begin(); it != files.end(); it++)
|
for(std::map<std::string, Poco::UInt64>::const_iterator it = files.begin(); it != files.end(); it++)
|
||||||
|
|||||||
Reference in New Issue
Block a user