41 cxBufferSeek(&source, 0, SEEK_SET); |
41 cxBufferSeek(&source, 0, SEEK_SET); |
42 char tmp[4]; |
42 char tmp[4]; |
43 |
43 |
44 CX_TEST_DO { |
44 CX_TEST_DO { |
45 size_t result = cx_stream_bncopy(&source, &target, |
45 size_t result = cx_stream_bncopy(&source, &target, |
46 (cx_read_func) cxBufferRead, |
46 cxBufferReadFunc, |
47 (cx_write_func) cxBufferWrite, |
47 cxBufferWriteFunc, |
48 tmp, 4, 0); |
48 tmp, 4, 0); |
49 CX_TEST_ASSERT(result == 0); |
49 CX_TEST_ASSERT(result == 0); |
50 CX_TEST_ASSERT(target.size == 0); |
50 CX_TEST_ASSERT(target.size == 0); |
51 |
51 |
52 result = cx_stream_bncopy(&source, &target, |
52 result = cx_stream_bncopy(&source, &target, |
53 (cx_read_func) cxBufferRead, |
53 cxBufferReadFunc, |
54 (cx_write_func) cxBufferWrite, |
54 cxBufferWriteFunc, |
55 tmp, 4, 20); |
55 tmp, 4, 20); |
56 CX_TEST_ASSERT(result == 20); |
56 CX_TEST_ASSERT(result == 20); |
57 CX_TEST_ASSERT(target.size == 20); |
57 CX_TEST_ASSERT(target.size == 20); |
58 CX_TEST_ASSERT(strcmp("This is a stream cop\0", tbuf) == 0); |
58 CX_TEST_ASSERT(strcmp("This is a stream cop\0", tbuf) == 0); |
59 |
59 |
60 result = cx_stream_bcopy(&source, &target, |
60 result = cx_stream_bcopy(&source, &target, |
61 (cx_read_func) cxBufferRead, |
61 cxBufferReadFunc, |
62 (cx_write_func) cxBufferWrite, |
62 cxBufferWriteFunc, |
63 NULL, 16); |
63 NULL, 16); |
64 |
64 |
65 CX_TEST_ASSERT(result == 7); |
65 CX_TEST_ASSERT(result == 7); |
66 CX_TEST_ASSERT(target.size == 27); |
66 CX_TEST_ASSERT(target.size == 27); |
67 CX_TEST_ASSERT(strcmp("This is a stream copy test.\0", tbuf) == 0); |
67 CX_TEST_ASSERT(strcmp("This is a stream copy test.\0", tbuf) == 0); |
80 cxBufferPutString(&source, "This is a stream copy test."); |
80 cxBufferPutString(&source, "This is a stream copy test."); |
81 cxBufferSeek(&source, 0, SEEK_SET); |
81 cxBufferSeek(&source, 0, SEEK_SET); |
82 |
82 |
83 CX_TEST_DO { |
83 CX_TEST_DO { |
84 size_t result = cx_stream_ncopy(&source, &target, |
84 size_t result = cx_stream_ncopy(&source, &target, |
85 (cx_read_func) cxBufferRead, |
85 cxBufferReadFunc, |
86 (cx_write_func) cxBufferWrite, |
86 cxBufferWriteFunc, |
87 20); |
87 20); |
88 CX_TEST_ASSERT(result == 20); |
88 CX_TEST_ASSERT(result == 20); |
89 CX_TEST_ASSERT(target.size == 20); |
89 CX_TEST_ASSERT(target.size == 20); |
90 CX_TEST_ASSERT(strcmp("This is a stream cop\0", tbuf) == 0); |
90 CX_TEST_ASSERT(strcmp("This is a stream cop\0", tbuf) == 0); |
91 |
91 |
92 result = cx_stream_copy(&source, &target, |
92 result = cx_stream_copy(&source, &target, |
93 (cx_read_func) cxBufferRead, |
93 cxBufferReadFunc, |
94 (cx_write_func) cxBufferWrite); |
94 cxBufferWriteFunc); |
95 |
95 |
96 CX_TEST_ASSERT(result == 7); |
96 CX_TEST_ASSERT(result == 7); |
97 CX_TEST_ASSERT(target.size == 27); |
97 CX_TEST_ASSERT(target.size == 27); |
98 CX_TEST_ASSERT(strcmp("This is a stream copy test.\0", tbuf) == 0); |
98 CX_TEST_ASSERT(strcmp("This is a stream copy test.\0", tbuf) == 0); |
99 } |
99 } |