Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gafferongames committed Dec 24, 2023
1 parent d2ae572 commit dafba88
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ solution "reliable"
floatingpoint "Fast"
filter "configurations:Debug"
symbols "On"
defines { "RELIABLE_DEBUG" }
defines { "RELIABLE_DEBUG", "RELIABLE_ENABLE_TESTS" }
filter "configurations:Release"
symbols "Off"
optimize "Speed"
defines { "RELIABLE_RELEASE" }
defines { "RELIABLE_RELEASE", "RELIABLE_ENABLE_TESTS" }

project "test"
files { "test.cpp" }
Expand Down
16 changes: 8 additions & 8 deletions reliable.c
Original file line number Diff line number Diff line change
Expand Up @@ -2258,7 +2258,7 @@ void test_sequence_buffer_rollover()
reliable_endpoint_destroy( context.receiver );
}

#define RELIABLE_ARRAY_SIZE(x) ( int( sizeof((x)) / sizeof((x)[0]) ) )
#define ARRAY_LENGTH(x) (sizeof(x) / sizeof((x)[0]))

struct test_tracking_allocate_context_t
{
Expand All @@ -2270,15 +2270,15 @@ void * test_tracking_allocate_function( void * context, uint64_t bytes )
struct test_tracking_allocate_context_t* tracking_context = (struct test_tracking_allocate_context_t*)context;
void * allocation = malloc( bytes );
int tracking_index;
for ( tracking_index = 0; tracking_index < RELIABLE_ARRAY_SIZE(tracking_context->active_allocations); ++tracking_index )
for ( tracking_index = 0; tracking_index < (int) ARRAY_LENGTH(tracking_context->active_allocations); ++tracking_index )
{
if ( tracking_context->active_allocations[tracking_index] == NULL )
{
break;
}
}

reliable_assert(tracking_index < RELIABLE_ARRAY_SIZE(tracking_context->active_allocations));
reliable_assert(tracking_index < (int) ARRAY_LENGTH(tracking_context->active_allocations));
tracking_context->active_allocations[tracking_index] = allocation;
return allocation;
}
Expand All @@ -2287,15 +2287,15 @@ void test_tracking_free_function( void * context, void * pointer )
{
struct test_tracking_allocate_context_t* tracking_context = (struct test_tracking_allocate_context_t*)context;
int tracking_index;
for ( tracking_index = 0; tracking_index < RELIABLE_ARRAY_SIZE(tracking_context->active_allocations); ++tracking_index )
for ( tracking_index = 0; tracking_index < (int) ARRAY_LENGTH(tracking_context->active_allocations); ++tracking_index )
{
if ( tracking_context->active_allocations[tracking_index] == pointer )
{
break;
}
}

reliable_assert(tracking_index < RELIABLE_ARRAY_SIZE(tracking_context->active_allocations));
reliable_assert( tracking_index < (int) ARRAY_LENGTH(tracking_context->active_allocations) );
tracking_context->active_allocations[tracking_index] = NULL;
free( pointer );
}
Expand Down Expand Up @@ -2355,10 +2355,10 @@ void test_fragment_cleanup()
};

// Make sure we're sending more than receiver_config.fragment_reassembly_buffer_size packets, so the buffer wraps around.
reliable_assert( RELIABLE_ARRAY_SIZE( packet_sizes ) > receiver_config.fragment_reassembly_buffer_size );
reliable_assert( (int) ARRAY_LENGTH( packet_sizes ) > receiver_config.fragment_reassembly_buffer_size );

int i;
for ( i = 0; i < RELIABLE_ARRAY_SIZE( packet_sizes ); ++i )
for ( i = 0; i < (int) ARRAY_LENGTH( packet_sizes ); ++i )
{
// Only allow one packet per transmit, so that our fragmented packets are only partially
// delivered.
Expand All @@ -2384,7 +2384,7 @@ void test_fragment_cleanup()

// Make sure that there is no memory that hasn't been freed.
int tracking_index;
for ( tracking_index = 0; tracking_index < RELIABLE_ARRAY_SIZE(tracking_alloc_context.active_allocations); ++tracking_index )
for ( tracking_index = 0; tracking_index < (int) ARRAY_LENGTH(tracking_alloc_context.active_allocations); ++tracking_index )
{
check( tracking_alloc_context.active_allocations[tracking_index] == NULL );
}
Expand Down

0 comments on commit dafba88

Please sign in to comment.