-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
48 changed files
with
519 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
Benchmark/Files/MultiTextFileAndSubDirZip_store/DirFileOne/TextFileOne_store.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This is | ||
the first text file. |
2 changes: 2 additions & 0 deletions
2
Benchmark/Files/MultiTextFileAndSubDirZip_store/DirFileTwo/TextFileTwo_store.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Second file is this | ||
. |
1 change: 1 addition & 0 deletions
1
Benchmark/Files/MultiTextFileAndSubDirZip_store/DirOfDirs/OtherDir/FilleInDirectory.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This file is in a directory |
3 changes: 3 additions & 0 deletions
3
...MultiTextFileAndSubDirZip_store/DirOfDirs/SubDirWithCopyOfTopLevelFile/TextFile_store.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
The 3rd file contains | ||
|
||
an empty line on line 2. |
Binary file added
BIN
+1.81 KB
Benchmark/Files/MultiTextFileAndSubDirZip_store/MultiTextFileAndSubDirZip_store.zip
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The zip file has been created with 7zip and using deflate compression level `store` to not compress the files. |
3 changes: 3 additions & 0 deletions
3
Benchmark/Files/MultiTextFileAndSubDirZip_store/TextFile_store.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
The 3rd file contains | ||
|
||
an empty line on line 2. |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The zip file has been created with 7zip and using deflate compression level `store` to not compress the files. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This is | ||
the first text file. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Second file is this | ||
. |
Empty file.
3 changes: 3 additions & 0 deletions
3
Benchmark/Files/MultiTextFileZip_store/ThirdTextFile_store.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
The 3rd file contains | ||
|
||
an empty line on line 2. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The zip file has been created with 7zip and using deflate compression level `store` to not compress the file. |
4 changes: 4 additions & 0 deletions
4
Benchmark/Files/SmallBasicTextFileZip_store/SmallBasicTextFile_store.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
This is a test file. | ||
On the second line there are eight words | ||
The third line has a tab. | ||
And the last line is a longer piece. Consising of two sentences. |
Empty file.
Binary file added
BIN
+337 Bytes
Benchmark/Files/SmallBasicTextFileZip_store/SmallBasicTextFile_store.zip
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,4 +42,4 @@ void RaiiStringClean(RaiiString *pThis) { | |
pThis->pString = NULL; | ||
} | ||
pThis->lengthWithTermination = 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#include "unity_fixture.h" | ||
#include <CoDeLib/RaiiString/RaiiString.h> | ||
#include <CoDeLib/Test/Utility/FileUtils.h> | ||
#include <CoDeLib/UnZip_minizip/UnZip_minizip.h> | ||
#include <assert.h> | ||
#include <stdbool.h> | ||
#include <stdio.h> | ||
|
||
static char *g_pFullPathToBenchmarkTestFiles = NULL; | ||
|
||
void SetupTestUnZipMinizip(char *pFullPathToBenchmarkTestFiles) { | ||
g_pFullPathToBenchmarkTestFiles = pFullPathToBenchmarkTestFiles; | ||
} | ||
|
||
TEST_GROUP(TestUnZipMinizip); | ||
|
||
TEST_SETUP(TestUnZipMinizip) { | ||
// Nothing | ||
} | ||
|
||
TEST_TEAR_DOWN(TestUnZipMinizip) { | ||
// Nothing | ||
} | ||
|
||
TEST(TestUnZipMinizip, test_UnZipMinizip_UnZipsSingleFileCorrectly) { | ||
TEST_IGNORE_MESSAGE("In progress"); | ||
|
||
FILE *pInFile = NULL; | ||
FILE *pUnZippedFile = NULL; | ||
FILE *pReferenceUnZippedFile = NULL; | ||
|
||
OpenFile(&pInFile, g_pFullPathToBenchmarkTestFiles, | ||
"/SmallBasicTextFileZip_store/SmallBasicTextFile_store.zip", "r"); | ||
OpenFile( | ||
&pUnZippedFile, g_pFullPathToBenchmarkTestFiles, | ||
"/SmallBasicTextFileZip_store/SmallBasicTextFile_store.unzipped.txt", | ||
"w+"); | ||
OpenFile(&pReferenceUnZippedFile, g_pFullPathToBenchmarkTestFiles, | ||
"/SmallBasicTextFileZip_store/SmallBasicTextFile_store.txt", "r"); | ||
|
||
TEST_ASSERT(FilesAreEqual(pUnZippedFile, pReferenceUnZippedFile)); | ||
fclose(pInFile); | ||
fclose(pUnZippedFile); | ||
fclose(pReferenceUnZippedFile); | ||
} | ||
|
||
TEST(TestUnZipMinizip, test_UnZipMinizip_UnZipsMultipleFilesCorrectly) { | ||
TEST_IGNORE_MESSAGE("In progress"); | ||
|
||
FILE *pInFile = NULL; | ||
FILE *pUnZippedFiles[] = {NULL, NULL, NULL}; | ||
FILE *pReferenceUnZippedFiles[] = {NULL, NULL, NULL}; | ||
const size_t fileCount = 3; | ||
|
||
OpenFile(&pInFile, g_pFullPathToBenchmarkTestFiles, | ||
"/MultiTextFileZip_store/MultiTextFileZip_store.zip", "r"); | ||
// Output files | ||
OpenFile(&pUnZippedFiles[0], g_pFullPathToBenchmarkTestFiles, | ||
"/MultiTextFileZip_store/TextFileOne_store.unzipped.txt", "w+"); | ||
OpenFile(&pUnZippedFiles[1], g_pFullPathToBenchmarkTestFiles, | ||
"/MultiTextFileZip_store/TextFileTwo_store.unzipped.txt", "w+"); | ||
OpenFile(&pUnZippedFiles[2], g_pFullPathToBenchmarkTestFiles, | ||
"/MultiTextFileZip_store/ThirdTextFile_store.unzipped.txt", "w+"); | ||
// Reference files | ||
OpenFile(&pReferenceUnZippedFiles[0], g_pFullPathToBenchmarkTestFiles, | ||
"/MultiTextFileZip_store/TextFileOne_store.txt", "r"); | ||
OpenFile(&pReferenceUnZippedFiles[1], g_pFullPathToBenchmarkTestFiles, | ||
"/MultiTextFileZip_store/TextFileTwo_store.txt", "r"); | ||
OpenFile(&pReferenceUnZippedFiles[2], g_pFullPathToBenchmarkTestFiles, | ||
"/MultiTextFileZip_store/ThirdTextFile_store.txt", "r"); | ||
|
||
for (size_t i = 0; i < fileCount; ++i) { | ||
TEST_ASSERT( | ||
FilesAreEqual(pUnZippedFiles[i], pReferenceUnZippedFiles[i])); | ||
} | ||
fclose(pInFile); | ||
for (size_t i = 0; i < fileCount; ++i) { | ||
fclose(pUnZippedFiles[i]); | ||
fclose(pReferenceUnZippedFiles[i]); | ||
} | ||
} | ||
|
||
TEST_GROUP_RUNNER(TestUnZipMinizip) { | ||
RUN_TEST_CASE(TestUnZipMinizip, | ||
test_UnZipMinizip_UnZipsSingleFileCorrectly); | ||
RUN_TEST_CASE(TestUnZipMinizip, | ||
test_UnZipMinizip_UnZipsMultipleFilesCorrectly); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#pragma once | ||
|
||
void SetupTestUnZipMinizip(char *pFullPathToBenchmarkTestFiles); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#include "unity_fixture.h" | ||
#include <CoDeLib/ZipContentInfo/ZipContentInfo.h> | ||
#include <assert.h> | ||
#include <string.h> | ||
|
||
TEST_GROUP(TestZipContentInfo); | ||
|
||
static ZipContentInfo zipContentInfo; | ||
|
||
TEST_SETUP(TestZipContentInfo) {} | ||
|
||
TEST_TEAR_DOWN(TestZipContentInfo) { ZipContentInfoClean(&zipContentInfo); } | ||
|
||
//============================== | ||
// ZipContentInfoClean() | ||
//============================== | ||
|
||
TEST( | ||
TestZipContentInfo, | ||
test_ZipContentInfoClean_SetsZipFileNameToNullptrIfThereIsNoFileNameArray) { | ||
|
||
zipContentInfo = | ||
(ZipContentInfo){.name = RaiiStringCreateFromCString("myZip.zip"), | ||
.pFileArray = NULL, | ||
.fileCount = 0}; | ||
|
||
ZipContentInfoClean(&zipContentInfo); | ||
|
||
TEST_ASSERT_NULL(zipContentInfo.name.pString); | ||
TEST_ASSERT_NULL(zipContentInfo.pFileArray); | ||
TEST_ASSERT_EQUAL(0, zipContentInfo.fileCount); | ||
} | ||
|
||
TEST(TestZipContentInfo, test_ZipContentInfoClean_CleansAllFileNamesInArray) { | ||
|
||
RaiiString fileNames[] = { | ||
RaiiStringCreateFromCString("file1.txt"), | ||
RaiiStringCreateFromCString("SomeDir/file2.txt"), | ||
RaiiStringCreateFromCString("file3.txt"), | ||
}; | ||
zipContentInfo = | ||
(ZipContentInfo){.name = RaiiStringCreateFromCString("myZip.zip"), | ||
.pFileArray = &fileNames[0], | ||
.fileCount = 3}; | ||
|
||
ZipContentInfoClean(&zipContentInfo); | ||
|
||
TEST_ASSERT_NULL(zipContentInfo.name.pString); | ||
TEST_ASSERT_NULL(zipContentInfo.pFileArray); | ||
TEST_ASSERT_EQUAL(0, zipContentInfo.fileCount); | ||
|
||
for (size_t i = 0; i < 3; i++) { | ||
TEST_ASSERT_NULL(fileNames[i].pString); | ||
} | ||
} | ||
|
||
//============================== | ||
// TEST_GROUP_RUNNER | ||
//============================== | ||
|
||
TEST_GROUP_RUNNER(TestZipContentInfo) { | ||
// ZipContentInfoClean() | ||
RUN_TEST_CASE( | ||
TestZipContentInfo, | ||
test_ZipContentInfoClean_SetsZipFileNameToNullptrIfThereIsNoFileNameArray); | ||
RUN_TEST_CASE(TestZipContentInfo, | ||
test_ZipContentInfoClean_CleansAllFileNamesInArray); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.