src/server/test/writer.c

changeset 415
d938228c382e
parent 232
499711b2a970
equal deleted inserted replaced
414:99a34860c105 415:d938228c382e
29 #include <stdio.h> 29 #include <stdio.h>
30 #include <stdlib.h> 30 #include <stdlib.h>
31 31
32 #include "../util/writer.h" 32 #include "../util/writer.h"
33 33
34 #include <ucx/buffer.h> 34 #include <cx/buffer.h>
35 35
36 #include "writer.h" 36 #include "writer.h"
37 #include "testutils.h" 37 #include "testutils.h"
38 38
39 UCX_TEST(test_writer_putc) { 39 UCX_TEST(test_writer_putc) {
40 Session *sn = testutil_session(); 40 Session *sn = testutil_session();
41 TestIOStream *st = testutil_iostream(2048, TRUE); 41 TestIOStream *st = testutil_iostream(2048, TRUE);
42 UcxBuffer *buf = st->buf; 42 CxBuffer *buf = st->buf;
43 43
44 UCX_TEST_BEGIN; 44 UCX_TEST_BEGIN;
45 45
46 Writer writer; 46 Writer writer;
47 char wbuf[1024]; 47 char wbuf[1024];
74 } 74 }
75 75
76 UCX_TEST(test_writer_flush) { 76 UCX_TEST(test_writer_flush) {
77 Session *sn = testutil_session(); 77 Session *sn = testutil_session();
78 TestIOStream *st = testutil_iostream(2048, TRUE); 78 TestIOStream *st = testutil_iostream(2048, TRUE);
79 UcxBuffer *buf = st->buf; 79 CxBuffer *buf = st->buf;
80 80
81 UCX_TEST_BEGIN; 81 UCX_TEST_BEGIN;
82 82
83 Writer writer; 83 Writer writer;
84 char wbuf[1024]; 84 char wbuf[1024];
104 } 104 }
105 105
106 UCX_TEST(test_writer_put) { 106 UCX_TEST(test_writer_put) {
107 Session *sn = testutil_session(); 107 Session *sn = testutil_session();
108 TestIOStream *st = testutil_iostream(2048, TRUE); 108 TestIOStream *st = testutil_iostream(2048, TRUE);
109 UcxBuffer *buf = st->buf; 109 CxBuffer *buf = st->buf;
110 110
111 UCX_TEST_BEGIN; 111 UCX_TEST_BEGIN;
112 112
113 Writer writer; 113 Writer writer;
114 char wbuf[1024]; 114 char wbuf[1024];
133 UCX_TEST_ASSERT(!memcmp(wbuf, "xx", 2), "4: wrong content"); 133 UCX_TEST_ASSERT(!memcmp(wbuf, "xx", 2), "4: wrong content");
134 UCX_TEST_ASSERT(writer.pos == 2, "4: wrong pos"); 134 UCX_TEST_ASSERT(writer.pos == 2, "4: wrong pos");
135 UCX_TEST_ASSERT(!memcmp(buf->space, "abcdefgh12345678", 16), "4: wrong UcxBuffer content"); 135 UCX_TEST_ASSERT(!memcmp(buf->space, "abcdefgh12345678", 16), "4: wrong UcxBuffer content");
136 UCX_TEST_ASSERT(buf->pos == 16, "4: wrong UcxBuffer pos"); 136 UCX_TEST_ASSERT(buf->pos == 16, "4: wrong UcxBuffer pos");
137 137
138 writer_puts(out, S("345678abcdefgh12345678end.")); 138 writer_puts(out, cx_str("345678abcdefgh12345678end."));
139 UCX_TEST_ASSERT(!memcmp(wbuf, "end.", 4), "5: wrong content"); 139 UCX_TEST_ASSERT(!memcmp(wbuf, "end.", 4), "5: wrong content");
140 UCX_TEST_ASSERT(writer.pos == 4, "5: wrong pos"); 140 UCX_TEST_ASSERT(writer.pos == 4, "5: wrong pos");
141 UCX_TEST_ASSERT(!memcmp( 141 UCX_TEST_ASSERT(!memcmp(
142 buf->space, 142 buf->space,
143 "abcdefgh12345678xx345678abcdefgh12345678", 143 "abcdefgh12345678xx345678abcdefgh12345678",

mercurial