Mon, 23 Dec 2024 18:32:25 +0100
fix missing definition of SSIZE_MAX in windows
789
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1 | /* |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
3 | * |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
4 | * Copyright 2023 Mike Becker, Olaf Wintermann All rights reserved. |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
5 | * |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
8 | * |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
11 | * |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
15 | * |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
27 | */ |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
28 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
29 | #include "cx/test.h" |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
30 | #include "util_allocator.h" |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
31 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
32 | #include "cx/buffer.h" |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
33 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
34 | static CX_TEST_SUBROUTINE(expect_default_flush_config, CxBuffer *buf) { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
35 | CX_TEST_ASSERT(buf->flush_blkmax == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
36 | CX_TEST_ASSERT(buf->flush_blksize == 4096); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
37 | CX_TEST_ASSERT(buf->flush_threshold == SIZE_MAX); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
38 | CX_TEST_ASSERT(buf->flush_func == NULL); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
39 | CX_TEST_ASSERT(buf->flush_target == NULL); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
40 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
41 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
42 | CX_TEST(test_buffer_init_wrap_space) { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
43 | CxTestingAllocator talloc; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
44 | cx_testing_allocator_init(&talloc); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
45 | CxAllocator *alloc = &talloc.base; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
46 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
47 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
48 | void *space = cxMalloc(alloc, 16); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
49 | cxBufferInit(&buf, space, 16, alloc, CX_BUFFER_DEFAULT); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
50 | CX_TEST_CALL_SUBROUTINE(expect_default_flush_config, &buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
51 | CX_TEST_ASSERT(buf.space == space); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
52 | CX_TEST_ASSERT((buf.flags & CX_BUFFER_AUTO_EXTEND) == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
53 | CX_TEST_ASSERT((buf.flags & CX_BUFFER_FREE_CONTENTS) == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
54 | CX_TEST_ASSERT(buf.pos == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
55 | CX_TEST_ASSERT(buf.size == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
56 | CX_TEST_ASSERT(buf.capacity == 16); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
57 | CX_TEST_ASSERT(buf.allocator == alloc); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
58 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
59 | CX_TEST_ASSERT(!cx_testing_allocator_verify(&talloc)); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
60 | cxFree(alloc, space); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
61 | CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
62 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
63 | cx_testing_allocator_destroy(&talloc); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
64 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
65 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
66 | CX_TEST(test_buffer_init_wrap_space_auto_extend) { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
67 | CxTestingAllocator talloc; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
68 | cx_testing_allocator_init(&talloc); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
69 | CxAllocator *alloc = &talloc.base; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
70 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
71 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
72 | void *space = cxMalloc(alloc, 16); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
73 | cxBufferInit(&buf, space, 16, alloc, CX_BUFFER_AUTO_EXTEND); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
74 | CX_TEST_CALL_SUBROUTINE(expect_default_flush_config, &buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
75 | CX_TEST_ASSERT(buf.space == space); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
76 | CX_TEST_ASSERT((buf.flags & CX_BUFFER_AUTO_EXTEND) == CX_BUFFER_AUTO_EXTEND); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
77 | CX_TEST_ASSERT((buf.flags & CX_BUFFER_FREE_CONTENTS) == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
78 | CX_TEST_ASSERT(buf.pos == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
79 | CX_TEST_ASSERT(buf.size == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
80 | CX_TEST_ASSERT(buf.capacity == 16); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
81 | CX_TEST_ASSERT(buf.allocator == alloc); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
82 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
83 | CX_TEST_ASSERT(!cx_testing_allocator_verify(&talloc)); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
84 | cxFree(alloc, space); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
85 | CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
86 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
87 | cx_testing_allocator_destroy(&talloc); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
88 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
89 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
90 | CX_TEST(test_buffer_init_wrap_space_auto_free) { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
91 | CxTestingAllocator talloc; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
92 | cx_testing_allocator_init(&talloc); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
93 | CxAllocator *alloc = &talloc.base; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
94 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
95 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
96 | void *space = cxMalloc(alloc, 16); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
97 | cxBufferInit(&buf, space, 16, alloc, CX_BUFFER_FREE_CONTENTS); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
98 | CX_TEST_CALL_SUBROUTINE(expect_default_flush_config, &buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
99 | CX_TEST_ASSERT(buf.space == space); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
100 | CX_TEST_ASSERT((buf.flags & CX_BUFFER_AUTO_EXTEND) == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
101 | CX_TEST_ASSERT((buf.flags & CX_BUFFER_FREE_CONTENTS) == CX_BUFFER_FREE_CONTENTS); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
102 | CX_TEST_ASSERT(buf.pos == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
103 | CX_TEST_ASSERT(buf.size == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
104 | CX_TEST_ASSERT(buf.capacity == 16); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
105 | CX_TEST_ASSERT(buf.allocator == alloc); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
106 | CX_TEST_ASSERT(!cx_testing_allocator_verify(&talloc)); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
107 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
108 | CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
109 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
110 | cx_testing_allocator_destroy(&talloc); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
111 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
112 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
113 | CX_TEST(test_buffer_init_fresh_space) { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
114 | CxTestingAllocator talloc; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
115 | cx_testing_allocator_init(&talloc); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
116 | CxAllocator *alloc = &talloc.base; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
117 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
118 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
119 | cxBufferInit(&buf, NULL, 8, alloc, CX_BUFFER_DEFAULT); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
120 | CX_TEST_CALL_SUBROUTINE(expect_default_flush_config, &buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
121 | CX_TEST_ASSERT(buf.space != NULL); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
122 | CX_TEST_ASSERT((buf.flags & CX_BUFFER_AUTO_EXTEND) == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
123 | CX_TEST_ASSERT((buf.flags & CX_BUFFER_FREE_CONTENTS) == CX_BUFFER_FREE_CONTENTS); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
124 | CX_TEST_ASSERT(buf.pos == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
125 | CX_TEST_ASSERT(buf.size == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
126 | CX_TEST_ASSERT(buf.capacity == 8); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
127 | CX_TEST_ASSERT(buf.allocator == alloc); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
128 | CX_TEST_ASSERT(!cx_testing_allocator_verify(&talloc)); // space is still allocated |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
129 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
130 | CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
131 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
132 | cx_testing_allocator_destroy(&talloc); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
133 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
134 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
135 | CX_TEST(test_buffer_init_on_heap) { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
136 | CxTestingAllocator talloc; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
137 | cx_testing_allocator_init(&talloc); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
138 | CxAllocator *alloc = &talloc.base; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
139 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
140 | CxBuffer *buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
141 | void *space = cxMalloc(alloc, 16); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
142 | buf = cxBufferCreate(space, 16, alloc, CX_BUFFER_FREE_CONTENTS); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
143 | CX_TEST_ASSERT(buf != NULL); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
144 | CX_TEST_CALL_SUBROUTINE(expect_default_flush_config, buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
145 | CX_TEST_ASSERT(buf->space == space); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
146 | CX_TEST_ASSERT((buf->flags & CX_BUFFER_AUTO_EXTEND) == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
147 | CX_TEST_ASSERT((buf->flags & CX_BUFFER_FREE_CONTENTS) == CX_BUFFER_FREE_CONTENTS); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
148 | CX_TEST_ASSERT(buf->pos == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
149 | CX_TEST_ASSERT(buf->size == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
150 | CX_TEST_ASSERT(buf->capacity == 16); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
151 | CX_TEST_ASSERT(buf->allocator == alloc); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
152 | cxBufferFree(buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
153 | CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
154 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
155 | cx_testing_allocator_destroy(&talloc); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
156 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
157 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
158 | CX_TEST(test_buffer_minimum_capacity_sufficient) { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
159 | CxTestingAllocator talloc; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
160 | cx_testing_allocator_init(&talloc); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
161 | CxAllocator *alloc = &talloc.base; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
162 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
163 | void *space = cxMalloc(alloc, 8); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
164 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
165 | cxBufferInit(&buf, space, 8, alloc, CX_BUFFER_FREE_CONTENTS); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
166 | memcpy(space, "Testing", 8); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
167 | buf.size = 8; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
168 | cxBufferMinimumCapacity(&buf, 6); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
169 | CX_TEST_ASSERT(buf.capacity == 8); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
170 | CX_TEST_ASSERT(buf.size == 8); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
171 | CX_TEST_ASSERT(memcmp(buf.space, "Testing", 8) == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
172 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
173 | CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
174 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
175 | cx_testing_allocator_destroy(&talloc); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
176 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
177 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
178 | CX_TEST(test_buffer_minimum_capacity_extend) { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
179 | CxTestingAllocator talloc; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
180 | cx_testing_allocator_init(&talloc); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
181 | CxAllocator *alloc = &talloc.base; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
182 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
183 | void *space = cxMalloc(alloc, 8); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
184 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
185 | cxBufferInit(&buf, space, 8, alloc, CX_BUFFER_FREE_CONTENTS); // NO auto extend! |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
186 | memcpy(space, "Testing", 8); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
187 | buf.size = 8; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
188 | cxBufferMinimumCapacity(&buf, 16); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
189 | CX_TEST_ASSERT(buf.capacity == 16); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
190 | CX_TEST_ASSERT(buf.size == 8); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
191 | CX_TEST_ASSERT(memcmp(buf.space, "Testing", 8) == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
192 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
193 | CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
194 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
195 | cx_testing_allocator_destroy(&talloc); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
196 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
197 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
198 | CX_TEST(test_buffer_clear) { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
199 | char space[16]; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
200 | strcpy(space, "clear test"); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
201 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
202 | cxBufferInit(&buf, space, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
203 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
204 | CX_TEST_ASSERT(buf.size == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
205 | // only clear the used part of the buffer |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
206 | cxBufferClear(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
207 | CX_TEST_ASSERT(0 == memcmp(space, "clear test", 10)); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
208 | buf.size = 5; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
209 | buf.pos = 3; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
210 | cxBufferClear(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
211 | CX_TEST_ASSERT(0 == memcmp(space, "\0\0\0\0\0 test", 10)); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
212 | CX_TEST_ASSERT(buf.size == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
213 | CX_TEST_ASSERT(buf.pos == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
214 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
215 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
216 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
217 | |
1024
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
218 | CX_TEST(test_buffer_clear_copy_on_write) { |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
219 | char space[16]; |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
220 | strcpy(space, "clear test"); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
221 | CxBuffer buf; |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
222 | cxBufferInit(&buf, space, 16, cxDefaultAllocator, CX_BUFFER_COPY_ON_WRITE); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
223 | CX_TEST_DO { |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
224 | buf.size = 5; |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
225 | buf.pos = 3; |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
226 | cxBufferClear(&buf); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
227 | CX_TEST_ASSERT(0 == memcmp(space, "clear test", 10)); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
228 | CX_TEST_ASSERT(buf.size == 0); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
229 | CX_TEST_ASSERT(buf.pos == 0); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
230 | } |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
231 | cxBufferDestroy(&buf); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
232 | } |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
233 | |
789
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
234 | CX_TEST(test_buffer_reset) { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
235 | char space[16]; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
236 | strcpy(space, "reset test"); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
237 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
238 | cxBufferInit(&buf, space, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
239 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
240 | buf.size = 5; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
241 | buf.pos = 3; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
242 | cxBufferReset(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
243 | CX_TEST_ASSERT(0 == memcmp(space, "reset test", 10)); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
244 | CX_TEST_ASSERT(buf.size == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
245 | CX_TEST_ASSERT(buf.pos == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
246 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
247 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
248 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
249 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
250 | CX_TEST(test_buffer_seek_set_zero) { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
251 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
252 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
253 | buf.size = 6; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
254 | buf.pos = 3; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
255 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
256 | int result = cxBufferSeek(&buf, 0, SEEK_SET); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
257 | CX_TEST_ASSERT(result == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
258 | CX_TEST_ASSERT(buf.pos == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
259 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
260 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
261 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
262 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
263 | CX_TEST(test_buffer_seek_set_valid) { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
264 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
265 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
266 | buf.size = 6; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
267 | buf.pos = 3; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
268 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
269 | int result = cxBufferSeek(&buf, 5, SEEK_SET); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
270 | CX_TEST_ASSERT(result == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
271 | CX_TEST_ASSERT(buf.pos == 5); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
272 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
273 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
274 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
275 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
276 | CX_TEST(test_buffer_seek_set_invalid) { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
277 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
278 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
279 | buf.size = 6; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
280 | buf.pos = 3; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
281 | CX_TEST_DO { |
1007
81b2986d2b04
fix that cxBufferSeek() cannot move pos past the end - fixes #523
Mike Becker <universe@uap-core.de>
parents:
1006
diff
changeset
|
282 | int result = cxBufferSeek(&buf, 7, SEEK_SET); |
789
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
283 | CX_TEST_ASSERT(result != 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
284 | CX_TEST_ASSERT(buf.pos == 3); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
285 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
286 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
287 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
288 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
289 | CX_TEST(test_buffer_seek_cur_zero) { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
290 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
291 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
292 | buf.size = 6; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
293 | buf.pos = 3; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
294 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
295 | int result = cxBufferSeek(&buf, 0, SEEK_CUR); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
296 | CX_TEST_ASSERT(result == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
297 | CX_TEST_ASSERT(buf.pos == 3); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
298 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
299 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
300 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
301 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
302 | CX_TEST(test_buffer_seek_cur_valid_positive) { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
303 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
304 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
305 | buf.size = 6; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
306 | buf.pos = 3; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
307 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
308 | int result = cxBufferSeek(&buf, 2, SEEK_CUR); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
309 | CX_TEST_ASSERT(result == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
310 | CX_TEST_ASSERT(buf.pos == 5); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
311 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
312 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
313 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
314 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
315 | CX_TEST(test_buffer_seek_cur_valid_negative) { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
316 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
317 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
318 | buf.size = 6; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
319 | buf.pos = 3; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
320 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
321 | int result = cxBufferSeek(&buf, -3, SEEK_CUR); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
322 | CX_TEST_ASSERT(result == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
323 | CX_TEST_ASSERT(buf.pos == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
324 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
325 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
326 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
327 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
328 | CX_TEST(test_buffer_seek_cur_invalid_positive) { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
329 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
330 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
331 | buf.size = 6; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
332 | buf.pos = 3; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
333 | CX_TEST_DO { |
1007
81b2986d2b04
fix that cxBufferSeek() cannot move pos past the end - fixes #523
Mike Becker <universe@uap-core.de>
parents:
1006
diff
changeset
|
334 | int result = cxBufferSeek(&buf, 4, SEEK_CUR); |
789
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
335 | CX_TEST_ASSERT(result != 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
336 | CX_TEST_ASSERT(buf.pos == 3); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
337 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
338 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
339 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
340 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
341 | CX_TEST(test_buffer_seek_cur_invalid_negative) { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
342 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
343 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
344 | buf.size = 6; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
345 | buf.pos = 3; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
346 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
347 | int result = cxBufferSeek(&buf, -4, SEEK_CUR); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
348 | CX_TEST_ASSERT(result != 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
349 | CX_TEST_ASSERT(buf.pos == 3); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
350 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
351 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
352 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
353 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
354 | CX_TEST(test_buffer_seek_end_zero) { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
355 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
356 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
357 | buf.size = 6; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
358 | buf.pos = 3; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
359 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
360 | int result = cxBufferSeek(&buf, 0, SEEK_END); |
1007
81b2986d2b04
fix that cxBufferSeek() cannot move pos past the end - fixes #523
Mike Becker <universe@uap-core.de>
parents:
1006
diff
changeset
|
361 | CX_TEST_ASSERT(result == 0); |
81b2986d2b04
fix that cxBufferSeek() cannot move pos past the end - fixes #523
Mike Becker <universe@uap-core.de>
parents:
1006
diff
changeset
|
362 | CX_TEST_ASSERT(buf.pos == 6); |
789
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
363 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
364 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
365 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
366 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
367 | CX_TEST(test_buffer_seek_end_valid) { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
368 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
369 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
370 | buf.size = 6; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
371 | buf.pos = 3; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
372 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
373 | int result = cxBufferSeek(&buf, -6, SEEK_END); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
374 | CX_TEST_ASSERT(result == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
375 | CX_TEST_ASSERT(buf.pos == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
376 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
377 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
378 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
379 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
380 | CX_TEST(test_buffer_seek_end_invalid) { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
381 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
382 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
383 | buf.size = 6; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
384 | buf.pos = 3; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
385 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
386 | int result = cxBufferSeek(&buf, 1, SEEK_END); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
387 | CX_TEST_ASSERT(result != 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
388 | CX_TEST_ASSERT(buf.pos == 3); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
389 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
390 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
391 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
392 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
393 | CX_TEST(test_buffer_seek_whence_invalid) { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
394 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
395 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
396 | buf.size = 6; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
397 | buf.pos = 3; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
398 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
399 | int result = cxBufferSeek(&buf, 2, 9000); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
400 | CX_TEST_ASSERT(result != 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
401 | CX_TEST_ASSERT(buf.size == 6); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
402 | CX_TEST_ASSERT(buf.pos == 3); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
403 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
404 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
405 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
406 | |
792
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
407 | CX_TEST(test_buffer_eof_reached) { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
408 | CxBuffer buf; |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
409 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
410 | buf.size = buf.pos = 3; |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
411 | CX_TEST_DO { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
412 | CX_TEST_ASSERT(cxBufferEof(&buf)); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
413 | buf.pos = buf.size - 1; |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
414 | CX_TEST_ASSERT(!cxBufferEof(&buf)); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
415 | cxBufferPut(&buf, 'a'); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
416 | CX_TEST_ASSERT(cxBufferEof(&buf)); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
417 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
418 | cxBufferDestroy(&buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
419 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
420 | |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
421 | CX_TEST(test_buffer_eof_not_reached) { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
422 | CxBuffer buf; |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
423 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
424 | buf.size = 6; |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
425 | CX_TEST_DO { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
426 | buf.pos = buf.size - 1; |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
427 | CX_TEST_ASSERT(!cxBufferEof(&buf)); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
428 | buf.pos = 0; |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
429 | cxBufferWrite("test", 1, 5, &buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
430 | CX_TEST_ASSERT(!cxBufferEof(&buf)); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
431 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
432 | cxBufferDestroy(&buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
433 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
434 | |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
435 | #define TEST_BUFFER_SHIFT_SETUP(buf) \ |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
436 | CxTestingAllocator talloc; \ |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
437 | cx_testing_allocator_init(&talloc); \ |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
438 | CxAllocator *alloc = &talloc.base; \ |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
439 | CxBuffer buf; \ |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
440 | cxBufferInit(&buf, NULL, 16, alloc, CX_BUFFER_DEFAULT); \ |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
441 | memcpy(buf.space, "test____XXXXXXXX", 16); \ |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
442 | buf.capacity = 8; \ |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
443 | buf.pos = 4; \ |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
444 | buf.size = 4 |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
445 | #define TEST_BUFFER_SHIFT_TEARDOWN(buf) \ |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
446 | cxBufferDestroy(&buf); \ |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
447 | CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); \ |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
448 | cx_testing_allocator_destroy(&talloc) |
792
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
449 | |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
450 | |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
451 | CX_TEST(test_buffer_shift_left_zero) { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
452 | TEST_BUFFER_SHIFT_SETUP(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
453 | CX_TEST_DO { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
454 | int ret = cxBufferShiftLeft(&buf, 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
455 | CX_TEST_ASSERT(ret == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
456 | CX_TEST_ASSERT(buf.pos == 4); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
457 | CX_TEST_ASSERT(buf.size == 4); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
458 | CX_TEST_ASSERT(memcmp(buf.space, "test____XXXXXXXX", 16) == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
459 | TEST_BUFFER_SHIFT_TEARDOWN(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
460 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
461 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
462 | |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
463 | CX_TEST(test_buffer_shift_left_zero_offset_interface) { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
464 | TEST_BUFFER_SHIFT_SETUP(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
465 | CX_TEST_DO { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
466 | int ret = cxBufferShift(&buf, -0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
467 | CX_TEST_ASSERT(ret == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
468 | CX_TEST_ASSERT(buf.pos == 4); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
469 | CX_TEST_ASSERT(buf.size == 4); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
470 | CX_TEST_ASSERT(memcmp(buf.space, "test____XXXXXXXX", 16) == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
471 | TEST_BUFFER_SHIFT_TEARDOWN(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
472 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
473 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
474 | |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
475 | CX_TEST(test_buffer_shift_left_standard) { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
476 | TEST_BUFFER_SHIFT_SETUP(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
477 | CX_TEST_DO { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
478 | int ret = cxBufferShiftLeft(&buf, 2); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
479 | CX_TEST_ASSERT(ret == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
480 | CX_TEST_ASSERT(buf.pos == 2); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
481 | CX_TEST_ASSERT(buf.size == 2); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
482 | CX_TEST_ASSERT(memcmp(buf.space, "stst____XXXXXXXX", 16) == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
483 | TEST_BUFFER_SHIFT_TEARDOWN(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
484 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
485 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
486 | |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
487 | CX_TEST(test_buffer_shift_left_overshift) { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
488 | TEST_BUFFER_SHIFT_SETUP(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
489 | CX_TEST_DO { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
490 | int ret = cxBufferShiftLeft(&buf, 6); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
491 | CX_TEST_ASSERT(ret == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
492 | CX_TEST_ASSERT(buf.pos == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
493 | CX_TEST_ASSERT(buf.size == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
494 | CX_TEST_ASSERT(memcmp(buf.space, "test____XXXXXXXX", 16) == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
495 | TEST_BUFFER_SHIFT_TEARDOWN(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
496 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
497 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
498 | |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
499 | CX_TEST(test_buffer_shift_left_overshift_pos_only) { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
500 | TEST_BUFFER_SHIFT_SETUP(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
501 | buf.pos = 2; |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
502 | CX_TEST_DO { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
503 | int ret = cxBufferShiftLeft(&buf, 3); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
504 | CX_TEST_ASSERT(ret == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
505 | CX_TEST_ASSERT(buf.pos == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
506 | CX_TEST_ASSERT(buf.size == 1); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
507 | CX_TEST_ASSERT(memcmp(buf.space, "test____XXXXXXXX", 16) == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
508 | TEST_BUFFER_SHIFT_TEARDOWN(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
509 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
510 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
511 | |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
512 | CX_TEST(test_buffer_shift_left_offset_interface) { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
513 | TEST_BUFFER_SHIFT_SETUP(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
514 | buf.pos = 3; |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
515 | CX_TEST_DO { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
516 | int ret = cxBufferShift(&buf, -2); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
517 | CX_TEST_ASSERT(ret == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
518 | CX_TEST_ASSERT(buf.pos == 1); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
519 | CX_TEST_ASSERT(buf.size == 2); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
520 | CX_TEST_ASSERT(memcmp(buf.space, "stst____XXXXXXXX", 16) == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
521 | TEST_BUFFER_SHIFT_TEARDOWN(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
522 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
523 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
524 | |
1024
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
525 | CX_TEST(test_buffer_shift_left_copy_on_write) { |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
526 | TEST_BUFFER_SHIFT_SETUP(buf); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
527 | buf.flags |= CX_BUFFER_COPY_ON_WRITE; |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
528 | char *original = buf.space; |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
529 | CX_TEST_DO { |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
530 | int ret = cxBufferShiftLeft(&buf, 2); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
531 | CX_TEST_ASSERT(0 == (buf.flags & CX_BUFFER_COPY_ON_WRITE)); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
532 | CX_TEST_ASSERT(0 != (buf.flags & CX_BUFFER_FREE_CONTENTS)); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
533 | CX_TEST_ASSERT(ret == 0); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
534 | CX_TEST_ASSERT(buf.pos == 2); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
535 | CX_TEST_ASSERT(buf.size == 2); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
536 | CX_TEST_ASSERT(memcmp(original, "test____XXXXXXXX", 16) == 0); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
537 | CX_TEST_ASSERT(memcmp(buf.space, "st", 2) == 0); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
538 | cxFree(buf.allocator, original); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
539 | TEST_BUFFER_SHIFT_TEARDOWN(buf); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
540 | } |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
541 | } |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
542 | |
792
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
543 | CX_TEST(test_buffer_shift_right_zero) { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
544 | TEST_BUFFER_SHIFT_SETUP(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
545 | CX_TEST_DO { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
546 | int ret = cxBufferShiftRight(&buf, 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
547 | CX_TEST_ASSERT(ret == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
548 | CX_TEST_ASSERT(buf.pos == 4); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
549 | CX_TEST_ASSERT(buf.size == 4); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
550 | CX_TEST_ASSERT(memcmp(buf.space, "test____XXXXXXXX", 16) == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
551 | TEST_BUFFER_SHIFT_TEARDOWN(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
552 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
553 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
554 | |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
555 | CX_TEST(test_buffer_shift_right_zero_offset_interface) { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
556 | TEST_BUFFER_SHIFT_SETUP(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
557 | CX_TEST_DO { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
558 | int ret = cxBufferShift(&buf, +0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
559 | CX_TEST_ASSERT(ret == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
560 | CX_TEST_ASSERT(buf.pos == 4); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
561 | CX_TEST_ASSERT(buf.size == 4); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
562 | CX_TEST_ASSERT(memcmp(buf.space, "test____XXXXXXXX", 16) == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
563 | TEST_BUFFER_SHIFT_TEARDOWN(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
564 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
565 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
566 | |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
567 | CX_TEST(test_buffer_shift_right_standard) { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
568 | TEST_BUFFER_SHIFT_SETUP(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
569 | CX_TEST_DO { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
570 | int ret = cxBufferShiftRight(&buf, 3); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
571 | CX_TEST_ASSERT(ret == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
572 | CX_TEST_ASSERT(buf.pos == 7); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
573 | CX_TEST_ASSERT(buf.size == 7); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
574 | CX_TEST_ASSERT(memcmp(buf.space, "testest_XXXXXXXX", 16) == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
575 | TEST_BUFFER_SHIFT_TEARDOWN(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
576 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
577 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
578 | |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
579 | CX_TEST(test_buffer_shift_right_overshift_discard) { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
580 | TEST_BUFFER_SHIFT_SETUP(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
581 | CX_TEST_DO { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
582 | int ret = cxBufferShiftRight(&buf, 6); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
583 | CX_TEST_ASSERT(ret == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
584 | CX_TEST_ASSERT(buf.pos == 8); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
585 | CX_TEST_ASSERT(buf.size == 8); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
586 | CX_TEST_ASSERT(buf.capacity == 8); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
587 | CX_TEST_ASSERT(memcmp(buf.space, "test__teXXXXXXXX", 16) == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
588 | TEST_BUFFER_SHIFT_TEARDOWN(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
589 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
590 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
591 | |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
592 | CX_TEST(test_buffer_shift_right_overshift_extend) { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
593 | TEST_BUFFER_SHIFT_SETUP(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
594 | buf.flags |= CX_BUFFER_AUTO_EXTEND; |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
595 | CX_TEST_DO { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
596 | int ret = cxBufferShiftRight(&buf, 6); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
597 | CX_TEST_ASSERT(ret == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
598 | CX_TEST_ASSERT(buf.pos == 10); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
599 | CX_TEST_ASSERT(buf.size == 10); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
600 | CX_TEST_ASSERT(buf.capacity >= 10); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
601 | // cannot assert more than 10 bytes because |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
602 | // the buffer was required to reallocate the space |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
603 | CX_TEST_ASSERT(memcmp(buf.space, "test__test", 10) == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
604 | TEST_BUFFER_SHIFT_TEARDOWN(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
605 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
606 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
607 | |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
608 | CX_TEST(test_buffer_shift_right_offset_interface) { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
609 | TEST_BUFFER_SHIFT_SETUP(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
610 | buf.pos = 3; |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
611 | CX_TEST_DO { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
612 | int ret = cxBufferShift(&buf, 2); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
613 | CX_TEST_ASSERT(ret == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
614 | CX_TEST_ASSERT(buf.pos == 5); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
615 | CX_TEST_ASSERT(buf.size == 6); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
616 | CX_TEST_ASSERT(memcmp(buf.space, "tetest__XXXXXXXX", 16) == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
617 | TEST_BUFFER_SHIFT_TEARDOWN(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
618 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
619 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
620 | |
1024
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
621 | CX_TEST(test_buffer_shift_right_copy_on_write) { |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
622 | TEST_BUFFER_SHIFT_SETUP(buf); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
623 | buf.flags |= CX_BUFFER_COPY_ON_WRITE; |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
624 | char *original = buf.space; |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
625 | CX_TEST_DO { |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
626 | int ret = cxBufferShiftRight(&buf, 3); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
627 | CX_TEST_ASSERT(0 == (buf.flags & CX_BUFFER_COPY_ON_WRITE)); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
628 | CX_TEST_ASSERT(0 != (buf.flags & CX_BUFFER_FREE_CONTENTS)); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
629 | CX_TEST_ASSERT(ret == 0); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
630 | CX_TEST_ASSERT(buf.pos == 7); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
631 | CX_TEST_ASSERT(buf.size == 7); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
632 | CX_TEST_ASSERT(memcmp(original, "test____XXXXXXXX", 16) == 0); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
633 | CX_TEST_ASSERT(memcmp(buf.space, "testest", 7) == 0); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
634 | cxFree(buf.allocator, original); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
635 | TEST_BUFFER_SHIFT_TEARDOWN(buf); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
636 | } |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
637 | } |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
638 | |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
639 | static size_t mock_write_limited_rate( |
890
54565fd74e74
move all const keywords to the west - fixes #426
Mike Becker <universe@uap-core.de>
parents:
793
diff
changeset
|
640 | const void *ptr, |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
641 | size_t size, |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
890
diff
changeset
|
642 | cx_attr_unused size_t nitems, |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
643 | CxBuffer *buffer |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
644 | ) { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
645 | // simulate limited target drain capacity |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
646 | static bool full = false; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
647 | if (full) { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
648 | full = false; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
649 | return 0; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
650 | } else { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
651 | full = true; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
652 | return cxBufferWrite(ptr, size, nitems > 2 ? 2 : nitems, buffer); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
653 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
654 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
655 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
656 | CX_TEST(test_buffer_write_size_one_fit) { |
1006
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
657 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
658 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
659 | memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
660 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
661 | buf.size = buf.pos = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
662 | const char *data = "test"; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
663 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
664 | size_t written = cxBufferWrite(data, 1, 4, &buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
665 | CX_TEST_ASSERT(written == 4); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
666 | CX_TEST_ASSERT(buf.size == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
667 | CX_TEST_ASSERT(buf.pos == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
668 | CX_TEST_ASSERT(buf.capacity == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
669 | CX_TEST_ASSERT(0 == memcmp(buf.space, "preptest", 8)); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
670 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
671 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
672 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
673 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
674 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
675 | CX_TEST(test_buffer_write_size_one_discard) { |
1006
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
676 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
677 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
678 | memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
679 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
680 | buf.size = buf.pos = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
681 | const char *data = "testing"; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
682 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
683 | size_t written = cxBufferWrite(data, 1, 7, &buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
684 | CX_TEST_ASSERT(written == 4); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
685 | CX_TEST_ASSERT(buf.size == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
686 | CX_TEST_ASSERT(buf.pos == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
687 | CX_TEST_ASSERT(buf.capacity == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
688 | CX_TEST_ASSERT(0 == memcmp(buf.space, "preptest\0", 9)); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
689 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
690 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
691 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
692 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
693 | CX_TEST(test_buffer_write_size_one_extend) { |
1006
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
694 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
695 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
696 | memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
697 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
698 | buf.size = buf.pos = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
699 | buf.flags |= CX_BUFFER_AUTO_EXTEND; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
700 | const char *data = "testing"; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
701 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
702 | size_t written = cxBufferWrite(data, 1, 7, &buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
703 | CX_TEST_ASSERT(written == 7); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
704 | CX_TEST_ASSERT(buf.size == 11); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
705 | CX_TEST_ASSERT(buf.pos == 11); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
706 | CX_TEST_ASSERT(buf.capacity >= 11); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
707 | CX_TEST_ASSERT(0 == memcmp(buf.space, "preptesting", 11)); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
708 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
709 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
710 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
711 | |
1024
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
712 | CX_TEST(test_buffer_write_copy_on_write) { |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
713 | CxBuffer buf; |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
714 | char original[16] = "preparedXXXXXXX\0"; |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
715 | cxBufferInit(&buf, original, 16, cxDefaultAllocator, CX_BUFFER_COPY_ON_WRITE); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
716 | buf.capacity = 8; |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
717 | buf.size = 8; |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
718 | buf.pos = 0; |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
719 | const char *data = "testing"; |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
720 | CX_TEST_DO { |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
721 | size_t written = cxBufferWrite(data, 1, 7, &buf); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
722 | CX_TEST_ASSERT(written == 7); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
723 | CX_TEST_ASSERT(buf.size == 8); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
724 | CX_TEST_ASSERT(buf.pos == 7); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
725 | CX_TEST_ASSERT(buf.capacity == 8); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
726 | CX_TEST_ASSERT(0 == memcmp(buf.space, "testingd", 8)); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
727 | CX_TEST_ASSERT(0 == memcmp(original, "preparedXXXXXXX\0", 16)); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
728 | CX_TEST_ASSERT(0 == (buf.flags & CX_BUFFER_COPY_ON_WRITE)); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
729 | CX_TEST_ASSERT(0 != (buf.flags & CX_BUFFER_FREE_CONTENTS)); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
730 | } |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
731 | cxBufferDestroy(&buf); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
732 | } |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
733 | |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
734 | CX_TEST(test_buffer_write_multibyte_fit) { |
1006
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
735 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
736 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
737 | memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
738 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
739 | buf.size = buf.pos = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
740 | const char *data = "test"; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
741 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
742 | size_t written = cxBufferWrite(data, 2, 2, &buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
743 | CX_TEST_ASSERT(written == 2); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
744 | CX_TEST_ASSERT(buf.size == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
745 | CX_TEST_ASSERT(buf.pos == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
746 | CX_TEST_ASSERT(buf.capacity == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
747 | CX_TEST_ASSERT(0 == memcmp(buf.space, "preptest", 8)); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
748 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
749 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
750 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
751 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
752 | CX_TEST(test_buffer_write_multibyte_discard) { |
1006
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
753 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
754 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
755 | memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
756 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
757 | buf.size = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
758 | buf.pos = 3; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
759 | const char *data = "testing"; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
760 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
761 | size_t written = cxBufferWrite(data, 2, 4, &buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
762 | // remember: whole elements are discarded if they do not fit |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
763 | CX_TEST_ASSERT(written == 2); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
764 | CX_TEST_ASSERT(buf.size == 7); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
765 | CX_TEST_ASSERT(buf.pos == 7); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
766 | CX_TEST_ASSERT(buf.capacity == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
767 | CX_TEST_ASSERT(0 == memcmp(buf.space, "pretest\0", 8)); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
768 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
769 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
770 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
771 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
772 | CX_TEST(test_buffer_write_multibyte_extend) { |
1006
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
773 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
774 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
775 | memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
776 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
777 | buf.size = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
778 | buf.pos = 3; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
779 | buf.flags |= CX_BUFFER_AUTO_EXTEND; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
780 | const char *data = "tester"; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
781 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
782 | size_t written = cxBufferWrite(data, 2, 3, &buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
783 | // remember: whole elements are discarded if they do not fit |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
784 | CX_TEST_ASSERT(written == 3); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
785 | CX_TEST_ASSERT(buf.size == 9); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
786 | CX_TEST_ASSERT(buf.pos == 9); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
787 | CX_TEST_ASSERT(buf.capacity >= 9); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
788 | CX_TEST_ASSERT(0 == memcmp(buf.space, "pretester", 9)); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
789 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
790 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
791 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
792 | |
1030
06091e067bee
add cxBufferAppend() - fixes #534
Mike Becker <universe@uap-core.de>
parents:
1028
diff
changeset
|
793 | CX_TEST(test_buffer_append) { |
06091e067bee
add cxBufferAppend() - fixes #534
Mike Becker <universe@uap-core.de>
parents:
1028
diff
changeset
|
794 | CxBuffer buf; |
06091e067bee
add cxBufferAppend() - fixes #534
Mike Becker <universe@uap-core.de>
parents:
1028
diff
changeset
|
795 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_AUTO_EXTEND); |
06091e067bee
add cxBufferAppend() - fixes #534
Mike Becker <universe@uap-core.de>
parents:
1028
diff
changeset
|
796 | memcpy(buf.space, "prepXXXX\0\0\0\0\0\0\0\0", 16); |
06091e067bee
add cxBufferAppend() - fixes #534
Mike Becker <universe@uap-core.de>
parents:
1028
diff
changeset
|
797 | buf.capacity = 8; |
06091e067bee
add cxBufferAppend() - fixes #534
Mike Becker <universe@uap-core.de>
parents:
1028
diff
changeset
|
798 | buf.size = 6; |
06091e067bee
add cxBufferAppend() - fixes #534
Mike Becker <universe@uap-core.de>
parents:
1028
diff
changeset
|
799 | buf.pos = 4; |
06091e067bee
add cxBufferAppend() - fixes #534
Mike Becker <universe@uap-core.de>
parents:
1028
diff
changeset
|
800 | CX_TEST_DO { |
06091e067bee
add cxBufferAppend() - fixes #534
Mike Becker <universe@uap-core.de>
parents:
1028
diff
changeset
|
801 | size_t written = cxBufferAppend("testing", 1, 7, &buf); |
06091e067bee
add cxBufferAppend() - fixes #534
Mike Becker <universe@uap-core.de>
parents:
1028
diff
changeset
|
802 | CX_TEST_ASSERT(written == 7); |
06091e067bee
add cxBufferAppend() - fixes #534
Mike Becker <universe@uap-core.de>
parents:
1028
diff
changeset
|
803 | CX_TEST_ASSERT(buf.size == 13); |
06091e067bee
add cxBufferAppend() - fixes #534
Mike Becker <universe@uap-core.de>
parents:
1028
diff
changeset
|
804 | CX_TEST_ASSERT(buf.pos == 4); |
06091e067bee
add cxBufferAppend() - fixes #534
Mike Becker <universe@uap-core.de>
parents:
1028
diff
changeset
|
805 | CX_TEST_ASSERT(buf.capacity >= 13); |
06091e067bee
add cxBufferAppend() - fixes #534
Mike Becker <universe@uap-core.de>
parents:
1028
diff
changeset
|
806 | CX_TEST_ASSERT(0 == memcmp(buf.space, "prepXXtesting", 13)); |
06091e067bee
add cxBufferAppend() - fixes #534
Mike Becker <universe@uap-core.de>
parents:
1028
diff
changeset
|
807 | } |
06091e067bee
add cxBufferAppend() - fixes #534
Mike Becker <universe@uap-core.de>
parents:
1028
diff
changeset
|
808 | cxBufferDestroy(&buf); |
06091e067bee
add cxBufferAppend() - fixes #534
Mike Becker <universe@uap-core.de>
parents:
1028
diff
changeset
|
809 | } |
06091e067bee
add cxBufferAppend() - fixes #534
Mike Becker <universe@uap-core.de>
parents:
1028
diff
changeset
|
810 | |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
811 | CX_TEST(test_buffer_put_fit) { |
1006
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
812 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
813 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
814 | memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
815 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
816 | buf.size = buf.pos = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
817 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
818 | int c = cxBufferPut(&buf, 0x200 | 'a'); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
819 | CX_TEST_ASSERT(c == 'a'); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
820 | CX_TEST_ASSERT(buf.size == 5); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
821 | CX_TEST_ASSERT(buf.pos == 5); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
822 | CX_TEST_ASSERT(buf.capacity == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
823 | CX_TEST_ASSERT(0 == memcmp(buf.space, "prepa\0", 6)); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
824 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
825 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
826 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
827 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
828 | CX_TEST(test_buffer_put_discard) { |
1006
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
829 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
830 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
831 | memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
832 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
833 | buf.size = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
834 | buf.pos = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
835 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
836 | int c = cxBufferPut(&buf, 0x200 | 'a'); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
837 | CX_TEST_ASSERT(c == EOF); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
838 | CX_TEST_ASSERT(buf.size == 4); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
839 | CX_TEST_ASSERT(buf.pos == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
840 | CX_TEST_ASSERT(buf.capacity == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
841 | CX_TEST_ASSERT(0 == memcmp(buf.space, "prep\0\0\0\0\0", 9)); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
842 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
843 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
844 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
845 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
846 | CX_TEST(test_buffer_put_extend) { |
1006
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
847 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
848 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
849 | memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
850 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
851 | buf.size = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
852 | buf.pos = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
853 | buf.flags |= CX_BUFFER_AUTO_EXTEND; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
854 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
855 | int c = cxBufferPut(&buf, 0x200 | 'a'); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
856 | CX_TEST_ASSERT(c == 'a'); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
857 | CX_TEST_ASSERT(buf.size == 9); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
858 | CX_TEST_ASSERT(buf.pos == 9); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
859 | CX_TEST_ASSERT(buf.capacity >= 9); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
860 | CX_TEST_ASSERT(0 == memcmp(buf.space, "prep\0\0\0\0a", 9)); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
861 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
862 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
863 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
864 | |
1024
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
865 | CX_TEST(test_buffer_put_copy_on_write) { |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
866 | CxBuffer buf; |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
867 | char original[16] = "preparedXXXXXXX\0"; |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
868 | cxBufferInit(&buf, original, 16, cxDefaultAllocator, CX_BUFFER_COPY_ON_WRITE); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
869 | buf.capacity = 8; |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
870 | buf.size = 8; |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
871 | buf.pos = 8; |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
872 | CX_TEST_DO { |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
873 | int c = cxBufferPut(&buf, 0x200 | 'a'); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
874 | CX_TEST_ASSERT(c == EOF); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
875 | CX_TEST_ASSERT(buf.size == 8); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
876 | CX_TEST_ASSERT(buf.pos == 8); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
877 | CX_TEST_ASSERT(buf.capacity == 8); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
878 | CX_TEST_ASSERT(0 == memcmp(buf.space, "prepared", 8)); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
879 | // discarded, no write happend! |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
880 | CX_TEST_ASSERT(original == buf.space); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
881 | CX_TEST_ASSERT(0 != (buf.flags & CX_BUFFER_COPY_ON_WRITE)); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
882 | CX_TEST_ASSERT(0 == (buf.flags & CX_BUFFER_FREE_CONTENTS)); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
883 | // now actually write somewhere |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
884 | buf.pos = 2; |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
885 | c = cxBufferPut(&buf, 0x200 | 'a'); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
886 | CX_TEST_ASSERT(c == 'a'); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
887 | CX_TEST_ASSERT(buf.size == 8); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
888 | CX_TEST_ASSERT(buf.pos == 3); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
889 | CX_TEST_ASSERT(buf.capacity == 8); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
890 | CX_TEST_ASSERT(0 == memcmp(buf.space, "prapared", 8)); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
891 | CX_TEST_ASSERT(original != buf.space); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
892 | CX_TEST_ASSERT(0 == memcmp(original, "preparedXXXXXXX\0", 16)); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
893 | CX_TEST_ASSERT(0 == (buf.flags & CX_BUFFER_COPY_ON_WRITE)); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
894 | CX_TEST_ASSERT(0 != (buf.flags & CX_BUFFER_FREE_CONTENTS)); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
895 | } |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
896 | cxBufferDestroy(&buf); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
897 | } |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
898 | |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
899 | CX_TEST(test_buffer_put_string_fit) { |
1006
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
900 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
901 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
902 | memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
903 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
904 | buf.size = buf.pos = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
905 | const char *data = "test"; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
906 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
907 | size_t written = cxBufferPutString(&buf, data); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
908 | CX_TEST_ASSERT(written == 4); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
909 | CX_TEST_ASSERT(buf.size == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
910 | CX_TEST_ASSERT(buf.pos == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
911 | CX_TEST_ASSERT(buf.capacity == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
912 | CX_TEST_ASSERT(0 == memcmp(buf.space, "preptest", 8)); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
913 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
914 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
915 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
916 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
917 | CX_TEST(test_buffer_put_string_discard) { |
1006
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
918 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
919 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
920 | memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
921 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
922 | buf.size = buf.pos = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
923 | const char *data = "testing"; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
924 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
925 | size_t written = cxBufferPutString(&buf, data); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
926 | CX_TEST_ASSERT(written == 4); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
927 | CX_TEST_ASSERT(buf.size == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
928 | CX_TEST_ASSERT(buf.pos == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
929 | CX_TEST_ASSERT(buf.capacity == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
930 | CX_TEST_ASSERT(0 == memcmp(buf.space, "preptest\0", 9)); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
931 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
932 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
933 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
934 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
935 | CX_TEST(test_buffer_put_string_extend) { |
1006
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
936 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
937 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
938 | memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
939 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
940 | buf.size = buf.pos = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
941 | buf.flags |= CX_BUFFER_AUTO_EXTEND; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
942 | const char *data = "testing"; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
943 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
944 | size_t written = cxBufferPutString(&buf, data); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
945 | CX_TEST_ASSERT(written == 7); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
946 | CX_TEST_ASSERT(buf.size == 11); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
947 | CX_TEST_ASSERT(buf.pos == 11); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
948 | CX_TEST_ASSERT(buf.capacity >= 11); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
949 | CX_TEST_ASSERT(0 == memcmp(buf.space, "preptesting", 11)); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
950 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
951 | cxBufferDestroy(&buf); |
1006
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
952 | } |
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
953 | |
1028
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
954 | CX_TEST(test_buffer_put_string_copy_on_extend) { |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
955 | CxTestingAllocator talloc; |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
956 | cx_testing_allocator_init(&talloc); |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
957 | const CxAllocator *alloc = &talloc.base; |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
958 | CxBuffer buf; |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
959 | char original[16] = "preparedXXXXXXX\0"; |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
960 | CX_TEST_DO { |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
961 | cxBufferInit(&buf, original, 16, alloc, CX_BUFFER_COPY_ON_EXTEND); |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
962 | buf.capacity = 8; |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
963 | buf.size = buf.pos = 4; |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
964 | size_t written = cxBufferPutString(&buf, "test"); |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
965 | CX_TEST_ASSERT(written == 4); |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
966 | CX_TEST_ASSERT(buf.size == 8); |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
967 | CX_TEST_ASSERT(buf.pos == 8); |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
968 | CX_TEST_ASSERT(buf.capacity == 8); |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
969 | CX_TEST_ASSERT(0 == memcmp(buf.space, "preptest", 8)); |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
970 | CX_TEST_ASSERT(original == buf.space); |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
971 | written = cxBufferPutString(&buf, "ing"); |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
972 | CX_TEST_ASSERT(written == 3); |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
973 | CX_TEST_ASSERT(buf.size == 11); |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
974 | CX_TEST_ASSERT(buf.pos == 11); |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
975 | CX_TEST_ASSERT(buf.capacity >= 11); |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
976 | CX_TEST_ASSERT(0 == memcmp(buf.space, "preptesting", 11)); |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
977 | CX_TEST_ASSERT(original != buf.space); |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
978 | CX_TEST_ASSERT(0 == memcmp(original, "preptestXXXXXXX\0", 16)); |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
979 | CX_TEST_ASSERT(!cx_testing_allocator_verify(&talloc)); |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
980 | cxBufferDestroy(&buf); |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
981 | CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
982 | cx_testing_allocator_destroy(&talloc); |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
983 | } |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
984 | } |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
985 | |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
986 | CX_TEST(test_buffer_put_string_copy_on_write) { |
1024
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
987 | CxBuffer buf; |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
988 | char original[16] = "preparedXXXXXXX\0"; |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
989 | cxBufferInit(&buf, original, 16, cxDefaultAllocator, CX_BUFFER_COPY_ON_WRITE); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
990 | buf.capacity = 8; |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
991 | buf.size = 8; |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
992 | buf.pos = 4; |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
993 | buf.flags |= CX_BUFFER_AUTO_EXTEND; |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
994 | const char *data = "testing"; |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
995 | CX_TEST_DO { |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
996 | size_t written = cxBufferPutString(&buf, data); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
997 | CX_TEST_ASSERT(written == 7); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
998 | CX_TEST_ASSERT(buf.size == 11); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
999 | CX_TEST_ASSERT(buf.pos == 11); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
1000 | CX_TEST_ASSERT(buf.capacity >= 11); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
1001 | CX_TEST_ASSERT(0 == memcmp(buf.space, "preptesting", 11)); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
1002 | CX_TEST_ASSERT(original != buf.space); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
1003 | CX_TEST_ASSERT(0 == memcmp(original, "preparedXXXXXXX\0", 16)); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
1004 | CX_TEST_ASSERT(0 == (buf.flags & CX_BUFFER_COPY_ON_WRITE)); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
1005 | CX_TEST_ASSERT(0 != (buf.flags & CX_BUFFER_FREE_CONTENTS)); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
1006 | } |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
1007 | cxBufferDestroy(&buf); |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
1008 | } |
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
1009 | |
1006
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
1010 | CX_TEST(test_buffer_terminate) { |
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
1011 | CxBuffer buf; |
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
1012 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
1013 | memcpy(buf.space, "prepAAAAAA\0\0\0\0\0\0", 16); |
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
1014 | buf.capacity = 8; |
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
1015 | buf.size = buf.pos = 4; |
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
1016 | const char *data = "test"; |
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
1017 | CX_TEST_DO { |
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
1018 | size_t written = cxBufferPutString(&buf, data); |
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
1019 | CX_TEST_ASSERT(0 != cxBufferTerminate(&buf)); |
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
1020 | CX_TEST_ASSERT(written == 4); |
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
1021 | CX_TEST_ASSERT(buf.size == 8); |
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
1022 | CX_TEST_ASSERT(buf.pos == 8); |
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
1023 | CX_TEST_ASSERT(buf.capacity == 8); |
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
1024 | CX_TEST_ASSERT(0 == memcmp(buf.space, "preptestAA", 10)); |
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
1025 | buf.flags |= CX_BUFFER_AUTO_EXTEND; |
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
1026 | CX_TEST_ASSERT(0 == cxBufferTerminate(&buf)); |
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
1027 | CX_TEST_ASSERT(buf.size == 8); |
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
1028 | CX_TEST_ASSERT(buf.pos == 8); |
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
1029 | CX_TEST_ASSERT(buf.capacity > 8); |
1023
989e144c912a
fix out of range access in test on platforms which are actually shrinking the buffer
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
1030 | CX_TEST_ASSERT(0 == memcmp(buf.space, "preptest\0", 9)); |
1006
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
1031 | } |
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
1032 | cxBufferDestroy(&buf); |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1033 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1034 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1035 | CX_TEST(test_buffer_write_size_overflow) { |
1006
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
1036 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1037 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1038 | memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1039 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1040 | buf.size = buf.pos = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1041 | const char *data = "testing"; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1042 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1043 | size_t written = cxBufferWrite(data, 8, SIZE_MAX / 4, &buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1044 | CX_TEST_ASSERT(written == 0); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1045 | CX_TEST_ASSERT(buf.capacity == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1046 | CX_TEST_ASSERT(buf.pos == 4); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1047 | CX_TEST_ASSERT(buf.size == 4); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1048 | CX_TEST_ASSERT(0 == memcmp(buf.space, "prep\0", 5)); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1049 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1050 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1051 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1052 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1053 | CX_TEST(test_buffer_write_capacity_overflow) { |
1006
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
1054 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1055 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1056 | memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1057 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1058 | buf.size = buf.pos = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1059 | buf.flags |= CX_BUFFER_AUTO_EXTEND; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1060 | const char *data = "testing"; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1061 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1062 | size_t written = cxBufferWrite(data, 1, SIZE_MAX - 2, &buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1063 | CX_TEST_ASSERT(written == 0); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1064 | CX_TEST_ASSERT(buf.capacity == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1065 | CX_TEST_ASSERT(buf.pos == 4); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1066 | CX_TEST_ASSERT(buf.size == 4); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1067 | CX_TEST_ASSERT(0 == memcmp(buf.space, "prep\0", 5)); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1068 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1069 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1070 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1071 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1072 | CX_TEST(test_buffer_write_only_overwrite) { |
1006
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
1073 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1074 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1075 | memcpy(buf.space, "preptest\0\0\0\0\0\0\0\0", 16); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1076 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1077 | buf.pos = 3; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1078 | buf.size = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1079 | buf.flags |= CX_BUFFER_AUTO_EXTEND; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1080 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1081 | size_t written = cxBufferWrite("XXX", 2, 2, &buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1082 | CX_TEST_ASSERT(written == 2); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1083 | CX_TEST_ASSERT(buf.capacity == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1084 | CX_TEST_ASSERT(buf.size == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1085 | CX_TEST_ASSERT(buf.pos == 7); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1086 | CX_TEST_ASSERT(0 == memcmp(buf.space, "preXXX\0t", 8)); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1087 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1088 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1089 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1090 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1091 | CX_TEST(test_buffer_write_flush_at_capacity) { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1092 | CxBuffer buf, target; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1093 | cxBufferInit(&target, NULL, 16, cxDefaultAllocator, CX_BUFFER_AUTO_EXTEND); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1094 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1095 | memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1096 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1097 | buf.size = buf.pos = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1098 | buf.flush_target = ⌖ |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1099 | buf.flush_func = (cx_write_func)cxBufferWrite; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1100 | buf.flush_blkmax = 1; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1101 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1102 | size_t written = cxBufferWrite("foo", 1, 3, &buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1103 | CX_TEST_ASSERT(written == 3); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1104 | CX_TEST_ASSERT(buf.pos == 7); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1105 | CX_TEST_ASSERT(buf.size == 7); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1106 | CX_TEST_ASSERT(target.pos == 0); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1107 | CX_TEST_ASSERT(target.size == 0); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1108 | written = cxBufferWrite("hello", 1, 5, &buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1109 | CX_TEST_ASSERT(written == 5); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1110 | CX_TEST_ASSERT(buf.pos == 0); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1111 | CX_TEST_ASSERT(buf.size == 0); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1112 | CX_TEST_ASSERT(buf.capacity == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1113 | CX_TEST_ASSERT(target.pos == 12); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1114 | CX_TEST_ASSERT(target.size == 12); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1115 | CX_TEST_ASSERT(0 == memcmp(target.space, "prepfoohello", 12)); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1116 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1117 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1118 | cxBufferDestroy(&target); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1119 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1120 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1121 | CX_TEST(test_buffer_write_flush_at_threshold) { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1122 | CxBuffer buf, target; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1123 | cxBufferInit(&target, NULL, 16, cxDefaultAllocator, CX_BUFFER_AUTO_EXTEND); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1124 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1125 | memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1126 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1127 | buf.size = buf.pos = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1128 | buf.flush_target = ⌖ |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1129 | buf.flush_func = (cx_write_func)cxBufferWrite; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1130 | buf.flush_blkmax = 1; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1131 | buf.flush_threshold = 12; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1132 | buf.flags |= CX_BUFFER_AUTO_EXTEND; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1133 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1134 | size_t written = cxBufferWrite("foobar", 1, 6, &buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1135 | CX_TEST_ASSERT(written == 6); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1136 | CX_TEST_ASSERT(buf.pos == 10); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1137 | CX_TEST_ASSERT(buf.size == 10); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1138 | CX_TEST_ASSERT(buf.capacity >= 10); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1139 | CX_TEST_ASSERT(buf.capacity <= 12); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1140 | CX_TEST_ASSERT(target.pos == 0); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1141 | CX_TEST_ASSERT(target.size == 0); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1142 | written = cxBufferWrite("hello", 1, 5, &buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1143 | CX_TEST_ASSERT(written == 5); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1144 | CX_TEST_ASSERT(buf.pos == 0); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1145 | CX_TEST_ASSERT(buf.size == 0); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1146 | CX_TEST_ASSERT(buf.capacity <= 12); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1147 | CX_TEST_ASSERT(target.pos == 15); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1148 | CX_TEST_ASSERT(target.size == 15); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1149 | CX_TEST_ASSERT(0 == memcmp(target.space, "prepfoobarhello", 15)); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1150 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1151 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1152 | cxBufferDestroy(&target); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1153 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1154 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1155 | CX_TEST(test_buffer_write_flush_rate_limited) { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1156 | CxBuffer buf, target; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1157 | cxBufferInit(&target, NULL, 16, cxDefaultAllocator, CX_BUFFER_AUTO_EXTEND); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1158 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1159 | memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1160 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1161 | buf.size = buf.pos = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1162 | buf.flush_target = ⌖ |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1163 | buf.flush_blkmax = 1; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1164 | // limit the rate of the flush function and the capacity of the target |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1165 | buf.flush_func = (cx_write_func) mock_write_limited_rate; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1166 | target.capacity = 16; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1167 | target.flags &= ~CX_BUFFER_AUTO_EXTEND; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1168 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1169 | size_t written = cxBufferWrite("foo", 1, 3, &buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1170 | CX_TEST_ASSERT(written == 3); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1171 | CX_TEST_ASSERT(buf.pos == 7); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1172 | CX_TEST_ASSERT(buf.size == 7); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1173 | CX_TEST_ASSERT(target.pos == 0); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1174 | CX_TEST_ASSERT(target.size == 0); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1175 | written = cxBufferWrite("hello, world!", 1, 13, &buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1176 | // " world!" fits into this buffer, the remaining stuff is flushed out |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1177 | CX_TEST_ASSERT(written == 13); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1178 | CX_TEST_ASSERT(buf.pos == 7); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1179 | CX_TEST_ASSERT(buf.size == 7); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1180 | CX_TEST_ASSERT(buf.capacity == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1181 | CX_TEST_ASSERT(0 == memcmp(buf.space, " world!", 7)); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1182 | CX_TEST_ASSERT(target.pos == 13); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1183 | CX_TEST_ASSERT(target.size == 13); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1184 | CX_TEST_ASSERT(target.capacity == 16); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1185 | CX_TEST_ASSERT(0 == memcmp(target.space, "prepfoohello,", 13)); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1186 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1187 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1188 | cxBufferDestroy(&target); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1189 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1190 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1191 | CX_TEST(test_buffer_get) { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1192 | CxBuffer buf; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1193 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1194 | memcpy(buf.space, "some data\0\0\0\0\0\0\0", 16); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1195 | buf.capacity = 12; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1196 | buf.size = 9; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1197 | buf.pos = 2; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1198 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1199 | CX_TEST_ASSERT(cxBufferGet(&buf) == 'm'); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1200 | CX_TEST_ASSERT(cxBufferGet(&buf) == 'e'); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1201 | CX_TEST_ASSERT(cxBufferGet(&buf) == ' '); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1202 | CX_TEST_ASSERT(cxBufferGet(&buf) == 'd'); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1203 | CX_TEST_ASSERT(buf.pos == 6); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1204 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1205 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1206 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1207 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1208 | CX_TEST(test_buffer_get_eof) { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1209 | CxBuffer buf; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1210 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1211 | memcpy(buf.space, "some data\0\0\0\0\0\0\0", 16); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1212 | buf.capacity = 12; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1213 | buf.pos = buf.size = 9; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1214 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1215 | CX_TEST_ASSERT(cxBufferGet(&buf) == EOF); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1216 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1217 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1218 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1219 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1220 | CX_TEST(test_buffer_read) { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1221 | CxBuffer buf; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1222 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1223 | memcpy(buf.space, "some data\0\0\0\0\0\0\0", 16); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1224 | buf.capacity = 12; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1225 | buf.size = 9; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1226 | buf.pos = 2; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1227 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1228 | char target[4]; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1229 | size_t read = cxBufferRead(&target, 1, 4, &buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1230 | CX_TEST_ASSERT(read == 4); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1231 | CX_TEST_ASSERT(0 == memcmp(&target, "me d", 4)); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1232 | CX_TEST_ASSERT(buf.pos == 6); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1233 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1234 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1235 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1236 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1237 | CX_TEST(test_buffer_read_oob) { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1238 | CxBuffer buf; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1239 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1240 | memcpy(buf.space, "some data\0\0\0\0\0\0\0", 16); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1241 | buf.capacity = 12; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1242 | buf.size = 9; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1243 | buf.pos = 6; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1244 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1245 | char target[4]; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1246 | size_t read = cxBufferRead(&target, 1, 4, &buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1247 | CX_TEST_ASSERT(read == 3); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1248 | CX_TEST_ASSERT(0 == memcmp(&target, "ata", 3)); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1249 | CX_TEST_ASSERT(buf.pos == 9); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1250 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1251 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1252 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1253 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1254 | CX_TEST(test_buffer_read_oob_multibyte) { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1255 | CxBuffer buf; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1256 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1257 | memcpy(buf.space, "some data\0\0\0\0\0\0\0", 16); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1258 | buf.capacity = 12; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1259 | buf.size = 9; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1260 | buf.pos = 6; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1261 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1262 | char target[4]; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1263 | target[2] = '\0'; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1264 | size_t read = cxBufferRead(&target, 2, 2, &buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1265 | CX_TEST_ASSERT(read == 1); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1266 | CX_TEST_ASSERT(0 == memcmp(&target, "at\0", 3)); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1267 | CX_TEST_ASSERT(buf.pos == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1268 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1269 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1270 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1271 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1272 | CX_TEST(test_buffer_read_eof) { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1273 | CxBuffer buf; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1274 | cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1275 | memcpy(buf.space, "some data\0\0\0\0\0\0\0", 16); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1276 | buf.capacity = 12; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1277 | buf.size = buf.pos = 9; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1278 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1279 | char target[4]; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1280 | size_t read = cxBufferRead(&target, 1, 1, &buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1281 | CX_TEST_ASSERT(read == 0); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1282 | CX_TEST_ASSERT(buf.pos == 9); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1283 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1284 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1285 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1286 | |
789
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1287 | CxTestSuite *cx_test_suite_buffer(void) { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1288 | CxTestSuite *suite = cx_test_suite_new("buffer"); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1289 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1290 | cx_test_register(suite, test_buffer_init_wrap_space); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1291 | cx_test_register(suite, test_buffer_init_wrap_space_auto_extend); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1292 | cx_test_register(suite, test_buffer_init_wrap_space_auto_free); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1293 | cx_test_register(suite, test_buffer_init_fresh_space); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1294 | cx_test_register(suite, test_buffer_init_on_heap); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1295 | cx_test_register(suite, test_buffer_minimum_capacity_sufficient); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1296 | cx_test_register(suite, test_buffer_minimum_capacity_extend); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1297 | cx_test_register(suite, test_buffer_clear); |
1024
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
1298 | cx_test_register(suite, test_buffer_clear_copy_on_write); |
789
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1299 | cx_test_register(suite, test_buffer_reset); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1300 | cx_test_register(suite, test_buffer_seek_set_zero); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1301 | cx_test_register(suite, test_buffer_seek_set_valid); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1302 | cx_test_register(suite, test_buffer_seek_set_invalid); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1303 | cx_test_register(suite, test_buffer_seek_cur_zero); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1304 | cx_test_register(suite, test_buffer_seek_cur_valid_positive); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1305 | cx_test_register(suite, test_buffer_seek_cur_valid_negative); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1306 | cx_test_register(suite, test_buffer_seek_cur_invalid_positive); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1307 | cx_test_register(suite, test_buffer_seek_cur_invalid_negative); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1308 | cx_test_register(suite, test_buffer_seek_end_zero); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1309 | cx_test_register(suite, test_buffer_seek_end_valid); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1310 | cx_test_register(suite, test_buffer_seek_end_invalid); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1311 | cx_test_register(suite, test_buffer_seek_whence_invalid); |
792
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
1312 | cx_test_register(suite, test_buffer_eof_reached); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
1313 | cx_test_register(suite, test_buffer_eof_not_reached); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
1314 | cx_test_register(suite, test_buffer_shift_left_zero); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
1315 | cx_test_register(suite, test_buffer_shift_left_zero_offset_interface); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
1316 | cx_test_register(suite, test_buffer_shift_left_standard); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
1317 | cx_test_register(suite, test_buffer_shift_left_overshift); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
1318 | cx_test_register(suite, test_buffer_shift_left_overshift_pos_only); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
1319 | cx_test_register(suite, test_buffer_shift_left_offset_interface); |
1024
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
1320 | cx_test_register(suite, test_buffer_shift_left_copy_on_write); |
792
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
1321 | cx_test_register(suite, test_buffer_shift_right_zero); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
1322 | cx_test_register(suite, test_buffer_shift_right_zero_offset_interface); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
1323 | cx_test_register(suite, test_buffer_shift_right_standard); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
1324 | cx_test_register(suite, test_buffer_shift_right_overshift_discard); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
1325 | cx_test_register(suite, test_buffer_shift_right_overshift_extend); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
1326 | cx_test_register(suite, test_buffer_shift_right_offset_interface); |
1024
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
1327 | cx_test_register(suite, test_buffer_shift_right_copy_on_write); |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1328 | cx_test_register(suite, test_buffer_write_size_one_fit); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1329 | cx_test_register(suite, test_buffer_write_size_one_discard); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1330 | cx_test_register(suite, test_buffer_write_size_one_extend); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1331 | cx_test_register(suite, test_buffer_write_multibyte_fit); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1332 | cx_test_register(suite, test_buffer_write_multibyte_discard); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1333 | cx_test_register(suite, test_buffer_write_multibyte_extend); |
1024
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
1334 | cx_test_register(suite, test_buffer_write_copy_on_write); |
1030
06091e067bee
add cxBufferAppend() - fixes #534
Mike Becker <universe@uap-core.de>
parents:
1028
diff
changeset
|
1335 | cx_test_register(suite, test_buffer_append); |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1336 | cx_test_register(suite, test_buffer_put_fit); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1337 | cx_test_register(suite, test_buffer_put_discard); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1338 | cx_test_register(suite, test_buffer_put_extend); |
1024
8f99f6c28bd3
add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents:
1007
diff
changeset
|
1339 | cx_test_register(suite, test_buffer_put_copy_on_write); |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1340 | cx_test_register(suite, test_buffer_put_string_fit); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1341 | cx_test_register(suite, test_buffer_put_string_discard); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1342 | cx_test_register(suite, test_buffer_put_string_extend); |
1028
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
1343 | cx_test_register(suite, test_buffer_put_string_copy_on_extend); |
3e4905241838
add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents:
1026
diff
changeset
|
1344 | cx_test_register(suite, test_buffer_put_string_copy_on_write); |
1006
8ee818fa29f7
fix stupid initialization of target buffer in tests where no flush target is used
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
1345 | cx_test_register(suite, test_buffer_terminate); |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1346 | cx_test_register(suite, test_buffer_write_size_overflow); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1347 | cx_test_register(suite, test_buffer_write_capacity_overflow); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1348 | cx_test_register(suite, test_buffer_write_only_overwrite); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1349 | cx_test_register(suite, test_buffer_write_flush_at_capacity); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1350 | cx_test_register(suite, test_buffer_write_flush_at_threshold); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1351 | cx_test_register(suite, test_buffer_write_flush_rate_limited); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1352 | cx_test_register(suite, test_buffer_get); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1353 | cx_test_register(suite, test_buffer_get_eof); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1354 | cx_test_register(suite, test_buffer_read); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1355 | cx_test_register(suite, test_buffer_read_oob); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1356 | cx_test_register(suite, test_buffer_read_oob_multibyte); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1357 | cx_test_register(suite, test_buffer_read_eof); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1358 | |
789
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1359 | return suite; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1360 | } |