File: zipinputstreamtest.cpp

package info (click to toggle)
zipios%2B%2B 0.1.7-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 952 kB
  • sloc: cpp: 4,150; ansic: 148; makefile: 132; sh: 1
file content (68 lines) | stat: -rw-r--r-- 1,717 bytes parent folder | download | duplicates (6)
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();
  }
}

}