Skip to content

Commit

Permalink
chore: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hoffstadt committed Sep 28, 2024
1 parent b9c1b4d commit cb42237
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
7 changes: 2 additions & 5 deletions libs/pl_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,8 @@ pl_temp_allocator_alloc(plTempAllocator* ptAllocator, size_t szSize)
else // block available but too small
{
size_t szNewBlockSize = ptAllocator->szCurrentBlockSizes;
if(szSize > szNewBlockSize)
{
ptAllocator->szNextBlockSizes = szSize;
szNewBlockSize = szSize;
}
ptAllocator->szNextBlockSizes = szSize;
szNewBlockSize = szSize;

char** ppcOldBlocks = ptAllocator->ppcMemoryBlocks;
ptAllocator->ppcMemoryBlocks = (char**)PL_MEMORY_ALLOC(sizeof(char*) * (ptAllocator->szMemoryBlockCapacity + 1));
Expand Down
12 changes: 4 additions & 8 deletions libs/pl_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,20 +288,16 @@ pl_str_get_file_name_only(const char* pcFilePath, char* pcFileOut, size_t szOutS

if(uSlashCount == 0)
{
if(pcFileOut)
strncpy(pcFileOut, &pcFilePath[i + 1], szOutSize);
strncpy(pcFileOut, &pcFilePath[i + 1], szOutSize);
break;
}
}
}
else
{
if(pcFileOut)
{
if(szLen + 1 > szOutSize)
return false;
memcpy(pcFileOut, pcFilePath, szLen + 1);
}
if(szLen + 1 > szOutSize)
return false;
memcpy(pcFileOut, pcFilePath, szLen + 1);
}

if(szLen > szOutSize)
Expand Down
6 changes: 3 additions & 3 deletions libs/pl_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ Index of this file:

#ifdef PL_TEST_IMPLEMENTATION

#if defined(PL_TEST_WIN32_COLOR) || defined(_WIN32)
#if defined(PL_TEST_WIN32_COLOR) && defined(_WIN32)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
static DWORD gtOriginalMode = 0;
Expand Down Expand Up @@ -188,7 +188,7 @@ plTestContext*
pl_create_test_context(plTestOptions tOptions)
{

#if defined(PL_TEST_WIN32_COLOR) || defined(_WIN32)
#if defined(PL_TEST_WIN32_COLOR) && defined(_WIN32)
DWORD tCurrentMode = 0;
gtStdOutHandle = GetStdHandle(STD_OUTPUT_HANDLE);
if(gtStdOutHandle == INVALID_HANDLE_VALUE)
Expand Down Expand Up @@ -284,7 +284,7 @@ pl_test_finish(void)
printf("Tests failed: ");
pl__test_print_red("%u", NULL, gptTestContext->uTotalFailedTests);

#if defined(PL_TEST_WIN32_COLOR) || defined(_WIN32)
#if defined(PL_TEST_WIN32_COLOR) && defined(_WIN32)
if(!SetConsoleMode(gtStdOutHandle, gtOriginalMode))
exit(GetLastError());
#endif
Expand Down
4 changes: 3 additions & 1 deletion tests/main_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ int main()
pl_string_tests(NULL);
pl_test_run_suite("pl_string.h");

if(!pl_test_finish())
bool bResult = pl_test_finish();

if(!bResult)
{
exit(1);
}
Expand Down
8 changes: 6 additions & 2 deletions tests/pl_json_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
#include "pl_json.h"

void
write_json_test(char** ppcBuffer)
write_json_test(void* pData)
{

char** ppcBuffer = pData;

// root object
plJsonObject tRootJsonObject = {0};
pl_json_add_string_member(&tRootJsonObject, "first name", "John");
Expand Down Expand Up @@ -66,9 +68,11 @@ write_json_test(char** ppcBuffer)
}

void
read_json_test(char** ppcBuffer)
read_json_test(void* pData)
{

char** ppcBuffer = pData;

plJsonObject tRootJsonObject = {0};
pl_load_json(*ppcBuffer, &tRootJsonObject);

Expand Down

0 comments on commit cb42237

Please sign in to comment.