]> git.ozlabs.org Git - ccan/blobdiff - ccan/rbuf/test/run-partial-read.c
failtest, rbuf: fix up incorrect lseek arg order.
[ccan] / ccan / rbuf / test / run-partial-read.c
index 362e6b60171aad27a750434a56d6bc15df1d2d0f..8b5d901864de910e8668da83f11e462407061281 100644 (file)
@@ -27,11 +27,11 @@ int main(void)
        int i, fd = open("test/run.c", O_RDONLY);
 
        /* This is how many tests you plan to run */
-       plan_tests(140);
+       plan_tests(160);
 
        /* Grab ourselves for comparison. */
        buf[full_read(fd, buf, sizeof(buf))] = '\0';
-       lseek(fd, SEEK_SET, 0);
+       lseek(fd, 0, SEEK_SET);
 
        for (i = 0, p = buf; *p; i++) {
                lines[i] = p;
@@ -41,26 +41,26 @@ int main(void)
        }
        lines[i] = NULL;
 
-       rbuf_init(&in, fd, malloc(31), 31);
+       rbuf_init(&in, fd, malloc(31), 31, membuf_realloc);
        ok1(in.fd == fd);
-       ok1(in.buf_end - in.buf == 31);
-       p = rbuf_read_str(&in, '\n', NULL);
+       ok1(membuf_num_space(&in.m) == 31);
+       p = rbuf_read_str(&in, '\n');
        ok1(p);
        ok1(strcmp(p, lines[0]) == 0);
 
-       p = rbuf_read_str(&in, '\n', realloc);
+       p = rbuf_read_str(&in, '\n');
        ok1(p);
        ok1(strcmp(p, lines[1]) == 0);
 
        for (i = 2; lines[i]; i++) {
-               ok1(p = rbuf_read_str(&in, '\n', realloc));
+               ok1(p = rbuf_read_str(&in, '\n'));
                ok1(strcmp(p, lines[i]) == 0);
        }
 
-       p = rbuf_read_str(&in, '\n', realloc);
+       p = rbuf_read_str(&in, '\n');
        ok1(errno == 0);
        ok1(p == NULL);
-       free(in.buf);
+       free(rbuf_cleanup(&in));
 
        /* This exits depending on whether all tests passed */
        return exit_status();