test/buffer_tests.c

changeset 218
b20d6088795c
parent 192
1e51558b9d09
child 219
2df780a4482b
--- a/test/buffer_tests.c	Fri Feb 26 16:22:20 2016 +0100
+++ b/test/buffer_tests.c	Fri Feb 26 16:33:04 2016 +0100
@@ -27,7 +27,6 @@
  */
 
 #include "buffer_tests.h"
-#include <stdint.h>
 
 UCX_TEST(test_ucx_buffer_new) {
     UcxBuffer *b = ucx_buffer_new(NULL, 16, UCX_BUFFER_AUTOEXTEND);
@@ -88,7 +87,8 @@
     int r;
     
     UCX_TEST_BEGIN
-    size_t bigpos = SIZE_MAX - 5000;
+    const size_t sizemax = (size_t)-1;
+    size_t bigpos = sizemax - 5000;
     b->pos = bigpos;
     r = ucx_buffer_seek(b, 5016, SEEK_CUR);
     UCX_TEST_ASSERT(r != 0, "seek cur overflow");
@@ -96,8 +96,8 @@
             "failed seek shall leave pos unchanged");
     
     b->pos = 0;
-    b->size = SIZE_MAX / 2 + 32;
-    off_t bigoff = SIZE_MAX / 2 - 16;
+    b->size = sizemax / 2 + 32;
+    off_t bigoff = sizemax / 2 - 16;
     r = ucx_buffer_seek(b, -bigoff, SEEK_CUR);
     UCX_TEST_ASSERT(r != 0, "seek cur underflow");
     UCX_TEST_ASSERT(b->pos == 0,
@@ -593,7 +593,7 @@
     UCX_TEST_ASSERT((b->size == 0 && b->pos == 0),
         "pos and size shall remain unchanged");
     
-    UCX_TEST_ASSERT(ucx_buffer_extend(b, SIZE_MAX - 60) != 0,
+    UCX_TEST_ASSERT(ucx_buffer_extend(b, (size_t) - 61) != 0,
         "shall fail and return a non-zero value on overflow");
     
     UCX_TEST_END

mercurial