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