Commit 3d6a890c authored by Mike Iovine's avatar Mike Iovine
Browse files

Add myunzip0 tests

parent 1fd6ab2d
No related merge requests found
Pipeline #30617 canceled with stage
Showing with 917 additions and 10 deletions
+917 -10
all : myzip0 myunzip0 huffman inflate test_inflate myunzip myzip lz77
all : myzip0 myunzip0 huffman inflate myunzip myzip lz77
myzip0 : myzip0.c
cc myzip0.c -o myzip0
myunzip0 : myunzip0.c
cc myunzip0.c -o myunzip0
myunzip0 : src/myunzip0/myunzip0.c
cc src/myunzip0/myunzip0.c -o myunzip0
huffman : huffman.c
cc huffman.c -o huffman
......@@ -15,10 +15,6 @@ inflate : include/inflate.h src/inflate/main.c src/inflate/inflate.c
myunzip : include/inflate.h src/inflate/inflate.c src/myunzip/myunzip.c
gcc -I include src/inflate/inflate.c src/myunzip/myunzip.c -o myunzip
test_inflate : src/inflate/inflate.c tests/inflate_test.cpp
g++ -I include src/inflate/inflate.c tests/inflate_test.cpp -o test_inflate -l gtest
./test_inflate
lz77 : include/bitwriter.h include/hashmap.h include/lz77.h src/lz77/bitwriter.c src/lz77/hashmap.c src/lz77/lz77.c src/lz77/main.c
cc -I include src/lz77/lz77.c src/lz77/hashmap.c src/lz77/bitwriter.c src/lz77/main.c -o lz77
......@@ -26,4 +22,4 @@ myzip : include/bitwriter.h include/hashmap.h include/lz77.h src/lz77/bitwriter.
cc -I include src/lz77/lz77.c src/lz77/hashmap.c src/lz77/bitwriter.c src/myzip/myzip.c -o myzip
clean :
rm -f myzip0 myunzip0 huffman inflate test_inflate myunzip myzip lz77
rm -f myzip0 myunzip0 huffman inflate myunzip myzip lz77 test_myunzip0
......@@ -57,8 +57,6 @@ void unzip(FILE *fp) {
FILE *out = fopen(fname, "wb");
/* TODO is there a better way to do this?
* worried about storing a huge buffer for large files... */
char *buf = (char *) malloc(size * sizeof(char));
fread(buf, 1, size, fp);
fwrite(buf, 1, size, out);
......
File added
File added
File added
File added
This diff is collapsed.
File added
This is a test file. It is not compressed and should, therefore, be extracted
from myunzip0.
import unittest
import os
import filecmp
import subprocess
EXEC_NAME = './myunzip0'
class TestMyUnzip0(unittest.TestCase):
def test_uncompressed(self):
subprocess.run([EXEC_NAME, 'tests/resources/uncompressed.zip'])
# Check that the correct file was extracted
self.assertTrue(os.path.exists('tests/resources/uncompressed.txt'))
# Check correct output
self.assertTrue(filecmp.cmp('tests/resources/uncompressed.txt',
'tests/resources/uncompressed_expected.txt'))
# Remove output
os.remove('tests/resources/uncompressed.txt')
def test_compressed(self):
subprocess.run([EXEC_NAME, 'tests/resources/compressed.zip'])
# Check that we extracted a DEFLATE stream
self.assertTrue(os.path.exists('tests/resources/compressed.txt.deflate'))
# Check correct output
self.assertTrue(filecmp.cmp('tests/resources/compressed_expected.deflate',
'tests/resources/compressed.txt.deflate'))
# Remove output
os.remove('tests/resources/compressed.txt.deflate')
if __name__ == '__main__':
unittest.main()
These tests are specific to our implementation and were used for debugging.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment