2#include "zipios++/zipios-config.h"
4#include "zipios++/meta-iostreams.h"
15#include "zipfiletest.h"
17using namespace zipios ;
27void zipios::ZipFileTest::testUnzip() {
28 vector<string> entries;
29 entries.push_back(
"file1.txt");
30 entries.push_back(
"file2.txt");
31 entries.push_back(
"file3.txt");
32 entries.push_back(
"testfile.bin");
35 CPPUNIT_ASSERT_EQUAL(4, zipFile.size());
36 compareZipFile(
"test.zip", entries);
39void zipios::ZipFileTest::testZipUnzip() {
40 const string zipFileName =
"gentest.zip";
41 vector<string> entries;
42 entries.push_back(
"testfile.bin");
43 entries.push_back(
"Makefile.in");
44 entries.push_back(
"zipfiletest.cpp");
45 entries.push_back(
"zipfiletest.h");
46 entries.push_back(
"all_tests");
47 writeZipFile(zipFileName, entries);
48 compareZipFile(zipFileName, entries);
51void zipios::ZipFileTest::testComment(){
56void zipios::ZipFileTest::writeZipFile(
const string &zipFileName, vector<string> entryFileNames) {
58 std::vector<string>::const_iterator it = entryFileNames.begin();
59 for ( ; it != entryFileNames.end() ; ++it ) {
60 writeFileToZipOutputStream(zos, *it);
65void zipios::ZipFileTest::compareZipFile(
const string &zipFileName, vector<string> entryFileNames) {
68 vector<string>::const_iterator it = entryFileNames.begin();
69 for ( ; it != entryFileNames.end() ; ++it ) {
70 auto_ptr<istream> zis(zipFile.getInputStream(*it));
72 CPPUNIT_FAIL(
"Entry '"+*it+
"' not found in zip file");
73 ifstream fis((*it).c_str(), ios::in | ios::binary);
74 compareStreams(*it, *zis, fis);
78void zipios::ZipFileTest::writeFileToZipOutputStream(
ZipOutputStream &zos,
const string &filename ) {
80 ifstream ifs( filename.c_str(), ios::in | ios::binary ) ;
82 CPPUNIT_FAIL(
"Could not open file '"+filename+
"'");
99void zipios::ZipFileTest::compareStreams(
const std::string& entryName,
100 istream &is1, istream &is2) {
104 CPPUNIT_ASSERT_MESSAGE(
"Streams differ for entry '"+entryName+
"'",
105 buf1.
str() == buf2.
str());
108void zipios::ZipFileTest::testClone(){
110 std::cout<<
"Testing cloning..need some help here"<<std::endl;
OutputStringStream is typedefed to ostringstream if sstream is part of the standard library (unless Z...
string str()
Specialization of ostrstream::str() that takes care of null-terminating the string and unfreezing the...
Specialization of ZipLocalEntry, that add fields for storing the extra information,...
ZipFile is a FileCollection, where the files are stored in a .zip file.
ZipOutputStream is an ostream that writes the output to a zip file.
void putNextEntry(const ZipCDirEntry &entry)
Begins writing the next entry.
Header file that defines OutputStringStream.
Header file that defines ZipFile.