test/buffer_tests.c

changeset 269
591473851c95
parent 259
2f5dea574a75
child 290
d5d6ab809ad3
--- a/test/buffer_tests.c	Mon Nov 20 18:06:32 2017 +0100
+++ b/test/buffer_tests.c	Tue Jan 02 17:00:21 2018 +0100
@@ -342,6 +342,10 @@
 
     UcxBuffer *b = ucx_buffer_new(buffer, 16, UCX_BUFFER_DEFAULT);
     b->size = b->capacity;
+    
+    unsigned char ubuffer[] = {127, 128, 129, 130};
+    UcxBuffer *ub = ucx_buffer_new(ubuffer, 4, UCX_BUFFER_DEFAULT);
+    ub->size = 4;
 
     UCX_TEST_BEGIN
 
@@ -360,10 +364,21 @@
     UCX_TEST_ASSERT(ucx_buffer_getc(b) == EOF,
         "out of bounds read does not return EOF");
     UCX_TEST_ASSERT(b->pos == 16, "wrong position after out of bounds read");
+    
+    int uc[5];
+    for(int i=0;i<5;i++) {
+        uc[i] = ucx_buffer_getc(ub);
+    }
+    UCX_TEST_ASSERT(uc[0] == 127, "wrong unsigned value(0)");
+    UCX_TEST_ASSERT(uc[1] == 128, "wrong unsigned value(0)");
+    UCX_TEST_ASSERT(uc[2] == 129, "wrong unsigned value(0)");
+    UCX_TEST_ASSERT(uc[3] == 130, "wrong unsigned value(0)");
+    UCX_TEST_ASSERT(uc[4] == EOF, "EOF not set after last ub read");
 
     UCX_TEST_END
 
     ucx_buffer_free(b);
+    ucx_buffer_free(ub);
     free(buffer);
 }
 

mercurial