test/buffer_tests.c

changeset 63
1d3500806565
parent 62
6814aea8462d
child 64
16590c9c497c
     1.1 --- a/test/buffer_tests.c	Wed Oct 10 10:46:20 2012 +0200
     1.2 +++ b/test/buffer_tests.c	Wed Oct 10 13:58:51 2012 +0200
     1.3 @@ -16,29 +16,29 @@
     1.4  
     1.5      r = ucx_buffer_seek(b, 5, SEEK_SET);
     1.6      UCX_TEST_ASSERT(r == 0, "seek SET+5 failed");
     1.7 -    UCX_TEST_ASSERT(ucx_buffer_tell(b) == 5, "seek SET+5 set wrong position");
     1.8 +    UCX_TEST_ASSERT(b->pos == 5, "seek SET+5 set wrong position");
     1.9  
    1.10      r = ucx_buffer_seek(b, 20, SEEK_SET);
    1.11      UCX_TEST_ASSERT(r != 0, "seek beyond bounds shall fail");
    1.12 -    UCX_TEST_ASSERT(ucx_buffer_tell(b) == 5,
    1.13 +    UCX_TEST_ASSERT(b->pos == 5,
    1.14              "failed seek shall leave pos unchanged");
    1.15  
    1.16      r = ucx_buffer_seek(b, 5, SEEK_CUR);
    1.17      UCX_TEST_ASSERT(r == 0, "seek CUR+5 failed");
    1.18 -    UCX_TEST_ASSERT(ucx_buffer_tell(b) == 10, "seek CUR+5 set wrong position");
    1.19 +    UCX_TEST_ASSERT(b->pos == 10, "seek CUR+5 set wrong position");
    1.20  
    1.21      r = ucx_buffer_seek(b, 10, SEEK_CUR);
    1.22      UCX_TEST_ASSERT(r != 0, "seek CUR beyond bounds shall fail");
    1.23 -    UCX_TEST_ASSERT(ucx_buffer_tell(b) == 10,
    1.24 +    UCX_TEST_ASSERT(b->pos == 10,
    1.25              "failed seek shall leave pos unchanged");
    1.26  
    1.27      r = ucx_buffer_seek(b, -5, SEEK_END);
    1.28      UCX_TEST_ASSERT(r == 0, "seek END-5 failed");
    1.29 -    UCX_TEST_ASSERT(ucx_buffer_tell(b) == 2, "seek END-5 set wrong position");
    1.30 +    UCX_TEST_ASSERT(b->pos == 2, "seek END-5 set wrong position");
    1.31  
    1.32      r = ucx_buffer_seek(b, -10, SEEK_END);
    1.33      UCX_TEST_ASSERT(r != 0, "seek END beyond bounds shall fail");
    1.34 -    UCX_TEST_ASSERT(ucx_buffer_tell(b) == 2,
    1.35 +    UCX_TEST_ASSERT(b->pos == 2,
    1.36              "failed seek shall leave pos unchanged");
    1.37  
    1.38      UCX_TEST_END
    1.39 @@ -57,10 +57,10 @@
    1.40      UCX_TEST_BEGIN
    1.41  
    1.42      ucx_buffer_putc(b, 48); ucx_buffer_putc(b, 48); ucx_buffer_putc(b, 48);
    1.43 -    UCX_TEST_ASSERT(ucx_buffer_tell(b) == 3, "pos wrong after first 3 puts");
    1.44 +    UCX_TEST_ASSERT(b->pos == 3, "pos wrong after first 3 puts");
    1.45      ucx_buffer_seek(b, 10, SEEK_CUR);
    1.46      ucx_buffer_putc(b, 48); ucx_buffer_putc(b, 48); ucx_buffer_putc(b, 48);
    1.47 -    UCX_TEST_ASSERT(ucx_buffer_tell(b) == 16, "pos wrong after last 3 puts");
    1.48 +    UCX_TEST_ASSERT(b->pos == 16, "pos wrong after last 3 puts");
    1.49      UCX_TEST_ASSERT(ucx_buffer_eof(b), "eof not set");
    1.50      UCX_TEST_ASSERT(ucx_buffer_putc(b, 48) == EOF,
    1.51              "put shall return EOF when buffer is full");
    1.52 @@ -87,12 +87,12 @@
    1.53  
    1.54      char rb[16];
    1.55      for (int i = 0 ; i < 16 ; i++) {
    1.56 -        UCX_TEST_ASSERT(ucx_buffer_tell(b) == i, "pos wrong during read loop");
    1.57 +        UCX_TEST_ASSERT(b->pos == i, "pos wrong during read loop");
    1.58          UCX_TEST_ASSERT(!ucx_buffer_eof(b),
    1.59                  "EOF shall not be set during read loop");
    1.60          rb[i] = ucx_buffer_getc(b);
    1.61      }
    1.62 -    UCX_TEST_ASSERT(ucx_buffer_tell(b) == 16, "pos wrong after read loop");
    1.63 +    UCX_TEST_ASSERT(b->pos == 16, "pos wrong after read loop");
    1.64      UCX_TEST_ASSERT(ucx_buffer_eof(b), "EOF not set");
    1.65      UCX_TEST_ASSERT(memcmp(rb, "        01234567", 16) == 0,
    1.66              "read data incorrect");
    1.67 @@ -133,7 +133,7 @@
    1.68      ucx_buffer_seek(b, 0, SEEK_SET);
    1.69      r = ucx_buffer_write(threebytestring, 3, 6, b);
    1.70      UCX_TEST_ASSERT(r == 15, "three byte string not correctly trimed");
    1.71 -    UCX_TEST_ASSERT(ucx_buffer_tell(b) == 15,
    1.72 +    UCX_TEST_ASSERT(b->pos == 15,
    1.73              "position after write of three byte string incorrect");
    1.74      UCX_TEST_ASSERT(!ucx_buffer_eof(b), "eof shall not be set");
    1.75      UCX_TEST_ASSERT(memcmp(buffer, "  t  h  r  e  e1", 16) == 0,
    1.76 @@ -194,9 +194,9 @@
    1.77              *dst = ucx_buffer_extract(src, 5, 5, UCX_BUFFER_DEFAULT);
    1.78  
    1.79      UCX_TEST_BEGIN
    1.80 -    UCX_TEST_ASSERT(ucx_buffer_testflags(dst, UCX_BUFFER_AUTOFREE),
    1.81 +    UCX_TEST_ASSERT((dst->flags & UCX_BUFFER_AUTOFREE) == UCX_BUFFER_AUTOFREE,
    1.82              "autofree flag shall be enforced");
    1.83 -    UCX_TEST_ASSERT(ucx_buffer_size(dst) == 5, "wrong size for new buffer");
    1.84 +    UCX_TEST_ASSERT(dst->size == 5, "wrong size for new buffer");
    1.85      char rb[5];
    1.86      ucx_buffer_read(rb, 1, 5, dst);
    1.87      UCX_TEST_ASSERT(memcmp(rb, "is a ", 5) == 0,

mercurial