Skip to content

Commit

Permalink
#18 check architecture
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxGoryunov committed Sep 1, 2023
1 parent 72e5400 commit 11f7c87
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions LinearSystemsToolkit/CommonTest.c
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
#include <limits.h>
#include <assert.h>
#include <malloc.h>
#include "CommonTest.h"
#include "Common.h"

int arch() {
return CHAR_BIT * sizeof(void*);
}

/**
* safeMalloc can return allocated memory of correct size.
*/
void safeMallocReturnsAllocatedMemoryOfCorrectSize() {
size_t size = 16;
void* ptr = SafeMalloc(size);
printf("sizeof(ptr) = %i\n", sizeof(ptr));
printf("sizeof(int) = %i\n", sizeof(int));
assert(sizeof(int) == sizeof(int));
void* ptr = SafeMalloc(16);
int expected = (arch() == 64) ? sizeof(double) : sizeof(int);
assert(expected == sizeof(ptr));
free(ptr);
}

Expand Down

0 comments on commit 11f7c87

Please sign in to comment.