1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
#include <stdlib.h>
#include "zipios++/zipios-config.h"
#include "zipios++/meta-iostreams.h"
#include "zipios++/zipinputstream.h"
#include "zipinputstreamtest.h"
namespace zipios {
const TestFiles ZipInputStreamTest::TEST_FILES;
void ZipInputStreamTest::testFirstMethod() {
CPPUNIT_FAIL( "Implement this" );
}
void ZipInputStreamTest::testZipContents() {
ZipInputStream zis("test.zip");
int count(0);
while (zis.getNextEntry()->isValid())
count++;
CPPUNIT_ASSERT_EQUAL(4, count);
}
void ZipInputStreamTest::testZipContentNames() {
vector<string> entries;
entries.push_back("file1.txt"); // got these from unzip -l test.zip
entries.push_back("file2.txt");
entries.push_back("file3.txt");
entries.push_back("testfile.bin");
ZipInputStream zis("test.zip");
ConstEntryPointer poi(zis.getNextEntry());
int count(0);
while( poi->isValid() ) {
CPPUNIT_ASSERT_EQUAL( entries[count], poi->getName() );
poi = zis.getNextEntry();
count++;
}
}
void ZipInputStreamTest::testZipFileSizes() {
vector<uint32> entries;
entries.push_back(1327); // got these from unzip -l test.zip
entries.push_back(17992);
entries.push_back(8);
entries.push_back(76468);
ZipInputStream zis("test.zip");
ConstEntryPointer poi(zis.getNextEntry());
int count(0);
while( poi->isValid() ) {
CPPUNIT_ASSERT_EQUAL( entries[count], poi->getSize() );
poi = zis.getNextEntry();
count++;
}
}
void ZipInputStreamTest::testDirectory() {
ZipInputStream zis("test.zip"); //only files in this
ConstEntryPointer poi(zis.getNextEntry());
while( poi->isValid() ) {
CPPUNIT_ASSERT_EQUAL( false, poi->isDirectory() );
poi = zis.getNextEntry();
}
}
}
|