Skip to content

Make all names of functions in test_helpers.c camelCase #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions test/common/test_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
#include "test_helpers.h"

// Check if the memory is filled with the given character
int is_filled_with_char(void *ptr, size_t size, char c) {
int bufferIsFilledWithChar(void *ptr, size_t size, char c) {
char *mem = (char *)ptr;
return (*mem == c) && memcmp(mem, mem + 1, size - 1) == 0;
}

// Check if two memory regions has the same content
int is_same_content(void *first, void *second, size_t size) {
int buffersHaveSameContent(void *first, void *second, size_t size) {
return memcmp(first, second, size) == 0;
}

int is_aligned(void *ptr, size_t alignment) {
int addressIsAligned(void *ptr, size_t alignment) {
return ((uintptr_t)ptr & (alignment - 1)) == 0;
}

Expand Down
7 changes: 4 additions & 3 deletions test/common/test_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
extern "C" {
#endif

int is_filled_with_char(void *ptr, size_t size, char c);
int bufferIsFilledWithChar(void *ptr, size_t size, char c);

int is_same_content(void *first, void *second, size_t size);
int buffersHaveSameContent(void *first, void *second, size_t size);

int is_aligned(void *ptr, size_t alignment);
int addressIsAligned(void *ptr, size_t alignment);

umf_memory_provider_handle_t nullProviderCreate(void);

umf_memory_provider_handle_t
traceProviderCreate(umf_memory_provider_handle_t hUpstreamProvider,
void (*trace)(const char *));
Expand Down
10 changes: 6 additions & 4 deletions test/malloc_compliance_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void malloc_compliance_test(umf_memory_pool_handle_t hPool) {
// For compatibility, on 64-bit systems malloc should align to 16 bytes
size_t alignment =
(sizeof(intptr_t) > 4 && alloc_ptr_size[i] > 8) ? 16 : 8;
ASSERT_NE(is_aligned(alloc_ptr[i], alignment), 0)
ASSERT_NE(addressIsAligned(alloc_ptr[i], alignment), 0)
<< "Malloc should return pointer that is suitably aligned so that "
"it may be assigned to a pointer to any type of object";
#endif
Expand All @@ -74,7 +74,8 @@ void malloc_compliance_test(umf_memory_pool_handle_t hPool) {
}
for (int i = 0; i < ITERATIONS; i++) {
ASSERT_NE(
is_filled_with_char(alloc_ptr[i], alloc_ptr_size[i], i % 0xFF), 0)
bufferIsFilledWithChar(alloc_ptr[i], alloc_ptr_size[i], i % 0xFF),
0)
<< "Object returned by malloc is not disjoined from others";
memset(alloc_ptr[i], 1, alloc_ptr_size[i]);
}
Expand All @@ -93,7 +94,7 @@ void calloc_compliance_test(umf_memory_pool_handle_t hPool) {

ASSERT_NE(alloc_ptr[i], nullptr)
<< "calloc returned NULL, couldn't allocate much memory";
ASSERT_NE(is_filled_with_char(alloc_ptr[i], alloc_size, 0), 0)
ASSERT_NE(bufferIsFilledWithChar(alloc_ptr[i], alloc_size, 0), 0)
<< "Memory returned by calloc was not zeroed";
}
free_memory(hPool, alloc_ptr);
Expand Down Expand Up @@ -131,7 +132,8 @@ void realloc_compliance_test(umf_memory_pool_handle_t hPool) {

// Reallocate with 100 byte size increasing
realloc_ptr[i] = umfPoolRealloc(hPool, malloc_obj, alloc_size + 100);
ASSERT_NE(is_same_content(realloc_ptr[i], saved_obj, alloc_size), 0)
ASSERT_NE(buffersHaveSameContent(realloc_ptr[i], saved_obj, alloc_size),
0)
<< "Content after realloc should remain the same";

// Delete saved memory
Expand Down