From 11f7c87d75073bfb7864aa398bd4d50345a5de64 Mon Sep 17 00:00:00 2001 From: Max Goryunov Date: Fri, 1 Sep 2023 14:34:37 +0300 Subject: [PATCH] #18 check architecture --- LinearSystemsToolkit/CommonTest.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/LinearSystemsToolkit/CommonTest.c b/LinearSystemsToolkit/CommonTest.c index 5d7206c..921d774 100644 --- a/LinearSystemsToolkit/CommonTest.c +++ b/LinearSystemsToolkit/CommonTest.c @@ -1,17 +1,20 @@ +#include #include #include #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); }