-
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.
test: enable unity test fixture and update tests
- Loading branch information
Showing
25 changed files
with
416 additions
and
44 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,45 @@ | ||
#include <CoDeLib/RaiiString/RaiiString.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
RaiiString RaiiStringCreate(size_t length) { | ||
RaiiString newRaiistring = {NULL, length}; | ||
newRaiistring.pString = (char *)calloc(length, sizeof(char)); | ||
RaiiString RaiiStringCreate(size_t lengthWithTermination) { | ||
RaiiString newRaiistring = {NULL, 0}; | ||
|
||
if (lengthWithTermination == 0 || | ||
lengthWithTermination >= MAX_CSTRING_INCLUDING_TERMINATION_LENGTH) { | ||
return newRaiistring; | ||
} | ||
|
||
newRaiistring.lengthWithTermination = lengthWithTermination; | ||
newRaiistring.pString = (char *)calloc(lengthWithTermination, sizeof(char)); | ||
if (newRaiistring.pString == NULL) { | ||
newRaiistring.length = 0; | ||
newRaiistring.lengthWithTermination = 0; | ||
printf("Failed to allocate memory for RaiiString\n"); | ||
exit(1); | ||
} | ||
return newRaiistring; | ||
} | ||
|
||
RaiiString RaiiStringCreateFromCString(const char *pCString) { | ||
const size_t length = | ||
strnlen(pCString, MAX_CSTRING_INCLUDING_TERMINATION_LENGTH); | ||
RaiiString newRaiistring = RaiiStringCreate(length + 1); | ||
|
||
if (newRaiistring.pString == NULL) { | ||
return newRaiistring; | ||
} | ||
|
||
strncpy(newRaiistring.pString, pCString, | ||
newRaiistring.lengthWithTermination - 1); | ||
newRaiistring.pString[newRaiistring.lengthWithTermination - 1] = '\0'; | ||
return newRaiistring; | ||
} | ||
|
||
void RaiiStringClean(RaiiString *pThis) { | ||
if (pThis->pString != NULL) { | ||
free(pThis->pString); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,34 @@ | ||
add_executable(CoDeLib_Test | ||
src/TestDeflateInflateZlib.c) | ||
src/main.c | ||
src/TestDeflateInflateZlib.c | ||
src/TestUnzipMinizip.c | ||
src/TestRaiiString.c | ||
) | ||
|
||
target_include_directories(CoDeLib_Test PUBLIC | ||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> | ||
) | ||
|
||
target_link_libraries(CoDeLib_Test PRIVATE Deflate_zlib) | ||
target_link_libraries(CoDeLib_Test PRIVATE Inflate_zlib) | ||
target_link_libraries(CoDeLib_Test PRIVATE RaiiString) | ||
|
||
FetchContent_Declare( | ||
Unity | ||
GIT_REPOSITORY https://github.com/ThrowTheSwitch/Unity.git | ||
GIT_TAG 860062d51b2e8a75d150337b63ca2a472840d13c # v2.6.0 | ||
EXCLUDE_FROM_ALL | ||
) | ||
# Solution to use `CACHE INTERNAL` found here: https://discourse.cmake.org/t/what-is-the-correct-way-to-set-options-of-a-project-before-fetch-content/268/4 | ||
# If cache is not used, you will get `Policy CMP0077 is not set: option() honors normal variables.` | ||
set(UNITY_EXTENSION_FIXTURE ON CACHE INTERNAL "") | ||
FetchContent_MakeAvailable(Unity) | ||
target_link_libraries(CoDeLib_Test PRIVATE unity) | ||
|
||
add_subdirectory(Utility) | ||
target_link_libraries(CoDeLib_Test PUBLIC Utility) | ||
|
||
target_link_libraries(CoDeLib_Test PRIVATE Deflate_zlib) | ||
target_link_libraries(CoDeLib_Test PRIVATE Inflate_zlib) | ||
target_link_libraries(CoDeLib_Test PRIVATE Zip_minizip) | ||
target_link_libraries(CoDeLib_Test PRIVATE UnZip_minizip) | ||
target_link_libraries(CoDeLib_Test PRIVATE RaiiString) | ||
|
||
target_link_libraries(CoDeLib_Test PRIVATE unity) | ||
|
||
|
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 @@ | ||
void SetupTestDeflateInflateZlib(char *pFullPathToBenchmarkTestFiles); |
Oops, something went wrong.