Zipios++
|
00001 #include <stdlib.h> 00002 00003 #include "zipios++/zipios-config.h" 00004 #include "zipios++/meta-iostreams.h" 00005 00006 #include "zipios++/zipinputstream.h" 00007 00008 #include "zipinputstreamtest.h" 00009 00010 namespace zipios { 00011 00012 const TestFiles ZipInputStreamTest::TEST_FILES; 00013 00014 00015 void ZipInputStreamTest::testFirstMethod() { 00016 CPPUNIT_FAIL( "Implement this" ); 00017 } 00018 00019 void ZipInputStreamTest::testZipContents() { 00020 ZipInputStream zis("test.zip"); 00021 int count(0); 00022 while (zis.getNextEntry()->isValid()) 00023 count++; 00024 CPPUNIT_ASSERT_EQUAL(4, count); 00025 } 00026 00027 void ZipInputStreamTest::testZipContentNames() { 00028 vector<string> entries; 00029 entries.push_back("file1.txt"); // got these from unzip -l test.zip 00030 entries.push_back("file2.txt"); 00031 entries.push_back("file3.txt"); 00032 entries.push_back("testfile.bin"); 00033 ZipInputStream zis("test.zip"); 00034 ConstEntryPointer poi(zis.getNextEntry()); 00035 int count(0); 00036 while( poi->isValid() ) { 00037 CPPUNIT_ASSERT_EQUAL( entries[count], poi->getName() ); 00038 poi = zis.getNextEntry(); 00039 count++; 00040 } 00041 } 00042 00043 void ZipInputStreamTest::testZipFileSizes() { 00044 vector<uint32> entries; 00045 entries.push_back(1327); // got these from unzip -l test.zip 00046 entries.push_back(17992); 00047 entries.push_back(8); 00048 entries.push_back(76468); 00049 ZipInputStream zis("test.zip"); 00050 ConstEntryPointer poi(zis.getNextEntry()); 00051 int count(0); 00052 while( poi->isValid() ) { 00053 CPPUNIT_ASSERT_EQUAL( entries[count], poi->getSize() ); 00054 poi = zis.getNextEntry(); 00055 count++; 00056 } 00057 } 00058 00059 void ZipInputStreamTest::testDirectory() { 00060 ZipInputStream zis("test.zip"); //only files in this 00061 ConstEntryPointer poi(zis.getNextEntry()); 00062 while( poi->isValid() ) { 00063 CPPUNIT_ASSERT_EQUAL( false, poi->isDirectory() ); 00064 poi = zis.getNextEntry(); 00065 } 00066 } 00067 00068 }