Sun, 15 Dec 2024 16:28:05 +0100
add shortcut to binary search when array size is one
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 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
218 | CX_TEST(test_buffer_reset) { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
219 | char space[16]; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
220 | strcpy(space, "reset test"); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
221 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
222 | 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
|
223 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
224 | buf.size = 5; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
225 | buf.pos = 3; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
226 | cxBufferReset(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
227 | 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
|
228 | CX_TEST_ASSERT(buf.size == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
229 | CX_TEST_ASSERT(buf.pos == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
230 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
231 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
232 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
233 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
234 | 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
|
235 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
236 | 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
|
237 | buf.size = 6; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
238 | buf.pos = 3; |
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 | 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
|
241 | CX_TEST_ASSERT(result == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
242 | CX_TEST_ASSERT(buf.pos == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
243 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
244 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
245 | } |
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 | 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
|
248 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
249 | 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
|
250 | buf.size = 6; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
251 | buf.pos = 3; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
252 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
253 | 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
|
254 | CX_TEST_ASSERT(result == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
255 | CX_TEST_ASSERT(buf.pos == 5); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
256 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
257 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
258 | } |
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 | 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
|
261 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
262 | 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
|
263 | buf.size = 6; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
264 | buf.pos = 3; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
265 | 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
|
266 | 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
|
267 | CX_TEST_ASSERT(result != 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
268 | CX_TEST_ASSERT(buf.pos == 3); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
269 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
270 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
271 | } |
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 | 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
|
274 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
275 | 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
|
276 | buf.size = 6; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
277 | buf.pos = 3; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
278 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
279 | 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
|
280 | CX_TEST_ASSERT(result == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
281 | CX_TEST_ASSERT(buf.pos == 3); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
282 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
283 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
284 | } |
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 | 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
|
287 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
288 | 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
|
289 | buf.size = 6; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
290 | buf.pos = 3; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
291 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
292 | 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
|
293 | CX_TEST_ASSERT(result == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
294 | CX_TEST_ASSERT(buf.pos == 5); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
295 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
296 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
297 | } |
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 | 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
|
300 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
301 | 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
|
302 | buf.size = 6; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
303 | buf.pos = 3; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
304 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
305 | 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
|
306 | CX_TEST_ASSERT(result == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
307 | CX_TEST_ASSERT(buf.pos == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
308 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
309 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
310 | } |
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 | 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
|
313 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
314 | 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
|
315 | buf.size = 6; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
316 | buf.pos = 3; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
317 | 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
|
318 | 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
|
319 | CX_TEST_ASSERT(result != 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
320 | CX_TEST_ASSERT(buf.pos == 3); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
321 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
322 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
323 | } |
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 | 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
|
326 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
327 | 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
|
328 | buf.size = 6; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
329 | buf.pos = 3; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
330 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
331 | 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
|
332 | CX_TEST_ASSERT(result != 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
333 | CX_TEST_ASSERT(buf.pos == 3); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
334 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
335 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
336 | } |
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 | 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
|
339 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
340 | 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
|
341 | buf.size = 6; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
342 | buf.pos = 3; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
343 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
344 | 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
|
345 | 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
|
346 | 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
|
347 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
348 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
349 | } |
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 | 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
|
352 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
353 | 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
|
354 | buf.size = 6; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
355 | buf.pos = 3; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
356 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
357 | 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
|
358 | CX_TEST_ASSERT(result == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
359 | CX_TEST_ASSERT(buf.pos == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
360 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
361 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
362 | } |
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 | 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
|
365 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
366 | 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
|
367 | buf.size = 6; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
368 | buf.pos = 3; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
369 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
370 | 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
|
371 | CX_TEST_ASSERT(result != 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
372 | CX_TEST_ASSERT(buf.pos == 3); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
373 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
374 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
375 | } |
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 | 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
|
378 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
379 | 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
|
380 | buf.size = 6; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
381 | buf.pos = 3; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
382 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
383 | int result = cxBufferSeek(&buf, 2, 9000); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
384 | CX_TEST_ASSERT(result != 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
385 | CX_TEST_ASSERT(buf.size == 6); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
386 | CX_TEST_ASSERT(buf.pos == 3); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
387 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
388 | cxBufferDestroy(&buf); |
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 | |
792
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
391 | CX_TEST(test_buffer_eof_reached) { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
392 | CxBuffer buf; |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
393 | 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
|
394 | buf.size = buf.pos = 3; |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
395 | CX_TEST_DO { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
396 | CX_TEST_ASSERT(cxBufferEof(&buf)); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
397 | buf.pos = buf.size - 1; |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
398 | CX_TEST_ASSERT(!cxBufferEof(&buf)); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
399 | cxBufferPut(&buf, 'a'); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
400 | CX_TEST_ASSERT(cxBufferEof(&buf)); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
401 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
402 | cxBufferDestroy(&buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
403 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
404 | |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
405 | 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
|
406 | CxBuffer buf; |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
407 | 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
|
408 | buf.size = 6; |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
409 | CX_TEST_DO { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
410 | buf.pos = buf.size - 1; |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
411 | CX_TEST_ASSERT(!cxBufferEof(&buf)); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
412 | buf.pos = 0; |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
413 | cxBufferWrite("test", 1, 5, &buf); |
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 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
416 | cxBufferDestroy(&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 | |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
419 | #define TEST_BUFFER_SHIFT_SETUP(buf) \ |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
420 | CxTestingAllocator talloc; \ |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
421 | cx_testing_allocator_init(&talloc); \ |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
422 | CxAllocator *alloc = &talloc.base; \ |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
423 | CxBuffer buf; \ |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
424 | 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
|
425 | memcpy(buf.space, "test____XXXXXXXX", 16); \ |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
426 | buf.capacity = 8; \ |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
427 | buf.pos = 4; \ |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
428 | buf.size = 4 |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
429 | #define TEST_BUFFER_SHIFT_TEARDOWN(buf) \ |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
430 | cxBufferDestroy(&buf); \ |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
431 | 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
|
432 | cx_testing_allocator_destroy(&talloc) |
792
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 | 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
|
436 | TEST_BUFFER_SHIFT_SETUP(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
437 | CX_TEST_DO { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
438 | int ret = cxBufferShiftLeft(&buf, 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
439 | CX_TEST_ASSERT(ret == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
440 | CX_TEST_ASSERT(buf.pos == 4); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
441 | CX_TEST_ASSERT(buf.size == 4); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
442 | 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
|
443 | TEST_BUFFER_SHIFT_TEARDOWN(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
444 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
445 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
446 | |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
447 | 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
|
448 | TEST_BUFFER_SHIFT_SETUP(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
449 | CX_TEST_DO { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
450 | int ret = cxBufferShift(&buf, -0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
451 | CX_TEST_ASSERT(ret == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
452 | CX_TEST_ASSERT(buf.pos == 4); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
453 | CX_TEST_ASSERT(buf.size == 4); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
454 | 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
|
455 | TEST_BUFFER_SHIFT_TEARDOWN(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
456 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
457 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
458 | |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
459 | 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
|
460 | TEST_BUFFER_SHIFT_SETUP(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
461 | CX_TEST_DO { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
462 | int ret = cxBufferShiftLeft(&buf, 2); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
463 | CX_TEST_ASSERT(ret == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
464 | CX_TEST_ASSERT(buf.pos == 2); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
465 | CX_TEST_ASSERT(buf.size == 2); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
466 | 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
|
467 | TEST_BUFFER_SHIFT_TEARDOWN(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
468 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
469 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
470 | |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
471 | 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
|
472 | TEST_BUFFER_SHIFT_SETUP(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
473 | CX_TEST_DO { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
474 | int ret = cxBufferShiftLeft(&buf, 6); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
475 | CX_TEST_ASSERT(ret == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
476 | CX_TEST_ASSERT(buf.pos == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
477 | CX_TEST_ASSERT(buf.size == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
478 | 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
|
479 | TEST_BUFFER_SHIFT_TEARDOWN(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
480 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
481 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
482 | |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
483 | 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
|
484 | TEST_BUFFER_SHIFT_SETUP(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
485 | buf.pos = 2; |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
486 | CX_TEST_DO { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
487 | int ret = cxBufferShiftLeft(&buf, 3); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
488 | CX_TEST_ASSERT(ret == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
489 | CX_TEST_ASSERT(buf.pos == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
490 | CX_TEST_ASSERT(buf.size == 1); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
491 | 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
|
492 | TEST_BUFFER_SHIFT_TEARDOWN(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
493 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
494 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
495 | |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
496 | 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
|
497 | TEST_BUFFER_SHIFT_SETUP(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
498 | buf.pos = 3; |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
499 | CX_TEST_DO { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
500 | int ret = cxBufferShift(&buf, -2); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
501 | CX_TEST_ASSERT(ret == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
502 | CX_TEST_ASSERT(buf.pos == 1); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
503 | CX_TEST_ASSERT(buf.size == 2); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
504 | 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
|
505 | TEST_BUFFER_SHIFT_TEARDOWN(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
506 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
507 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
508 | |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
509 | 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
|
510 | TEST_BUFFER_SHIFT_SETUP(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
511 | CX_TEST_DO { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
512 | int ret = cxBufferShiftRight(&buf, 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
513 | CX_TEST_ASSERT(ret == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
514 | CX_TEST_ASSERT(buf.pos == 4); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
515 | CX_TEST_ASSERT(buf.size == 4); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
516 | 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
|
517 | TEST_BUFFER_SHIFT_TEARDOWN(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
518 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
519 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
520 | |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
521 | 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
|
522 | TEST_BUFFER_SHIFT_SETUP(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
523 | CX_TEST_DO { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
524 | int ret = cxBufferShift(&buf, +0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
525 | CX_TEST_ASSERT(ret == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
526 | CX_TEST_ASSERT(buf.pos == 4); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
527 | CX_TEST_ASSERT(buf.size == 4); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
528 | 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
|
529 | TEST_BUFFER_SHIFT_TEARDOWN(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
530 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
531 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
532 | |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
533 | 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
|
534 | TEST_BUFFER_SHIFT_SETUP(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
535 | CX_TEST_DO { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
536 | int ret = cxBufferShiftRight(&buf, 3); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
537 | CX_TEST_ASSERT(ret == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
538 | CX_TEST_ASSERT(buf.pos == 7); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
539 | CX_TEST_ASSERT(buf.size == 7); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
540 | 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
|
541 | TEST_BUFFER_SHIFT_TEARDOWN(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
542 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
543 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
544 | |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
545 | 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
|
546 | TEST_BUFFER_SHIFT_SETUP(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
547 | CX_TEST_DO { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
548 | int ret = cxBufferShiftRight(&buf, 6); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
549 | CX_TEST_ASSERT(ret == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
550 | CX_TEST_ASSERT(buf.pos == 8); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
551 | CX_TEST_ASSERT(buf.size == 8); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
552 | CX_TEST_ASSERT(buf.capacity == 8); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
553 | 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
|
554 | TEST_BUFFER_SHIFT_TEARDOWN(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
555 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
556 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
557 | |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
558 | 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
|
559 | TEST_BUFFER_SHIFT_SETUP(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
560 | buf.flags |= CX_BUFFER_AUTO_EXTEND; |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
561 | CX_TEST_DO { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
562 | int ret = cxBufferShiftRight(&buf, 6); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
563 | CX_TEST_ASSERT(ret == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
564 | CX_TEST_ASSERT(buf.pos == 10); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
565 | CX_TEST_ASSERT(buf.size == 10); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
566 | CX_TEST_ASSERT(buf.capacity >= 10); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
567 | // 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
|
568 | // 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
|
569 | 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
|
570 | TEST_BUFFER_SHIFT_TEARDOWN(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
571 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
572 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
573 | |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
574 | 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
|
575 | TEST_BUFFER_SHIFT_SETUP(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
576 | buf.pos = 3; |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
577 | CX_TEST_DO { |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
578 | int ret = cxBufferShift(&buf, 2); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
579 | CX_TEST_ASSERT(ret == 0); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
580 | CX_TEST_ASSERT(buf.pos == 5); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
581 | CX_TEST_ASSERT(buf.size == 6); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
582 | 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
|
583 | TEST_BUFFER_SHIFT_TEARDOWN(buf); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
584 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
585 | } |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
586 | |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
587 | 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
|
588 | const void *ptr, |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
589 | size_t size, |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
890
diff
changeset
|
590 | 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
|
591 | CxBuffer *buffer |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
592 | ) { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
593 | // simulate limited target drain capacity |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
594 | static bool full = false; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
595 | if (full) { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
596 | full = false; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
597 | return 0; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
598 | } else { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
599 | full = true; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
600 | 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
|
601 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
602 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
603 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
604 | 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
|
605 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
606 | 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
|
607 | 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
|
608 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
609 | buf.size = buf.pos = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
610 | const char *data = "test"; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
611 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
612 | 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
|
613 | CX_TEST_ASSERT(written == 4); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
614 | CX_TEST_ASSERT(buf.size == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
615 | CX_TEST_ASSERT(buf.pos == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
616 | CX_TEST_ASSERT(buf.capacity == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
617 | 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
|
618 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
619 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
620 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
621 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
622 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
623 | 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
|
624 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
625 | 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
|
626 | 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
|
627 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
628 | buf.size = buf.pos = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
629 | const char *data = "testing"; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
630 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
631 | 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
|
632 | CX_TEST_ASSERT(written == 4); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
633 | CX_TEST_ASSERT(buf.size == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
634 | CX_TEST_ASSERT(buf.pos == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
635 | CX_TEST_ASSERT(buf.capacity == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
636 | 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
|
637 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
638 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
639 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
640 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
641 | 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
|
642 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
643 | 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
|
644 | 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
|
645 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
646 | buf.size = buf.pos = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
647 | buf.flags |= CX_BUFFER_AUTO_EXTEND; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
648 | const char *data = "testing"; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
649 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
650 | 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
|
651 | CX_TEST_ASSERT(written == 7); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
652 | CX_TEST_ASSERT(buf.size == 11); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
653 | CX_TEST_ASSERT(buf.pos == 11); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
654 | CX_TEST_ASSERT(buf.capacity >= 11); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
655 | 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
|
656 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
657 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
658 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
659 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
660 | 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
|
661 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
662 | 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
|
663 | 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
|
664 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
665 | buf.size = buf.pos = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
666 | const char *data = "test"; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
667 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
668 | 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
|
669 | CX_TEST_ASSERT(written == 2); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
670 | CX_TEST_ASSERT(buf.size == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
671 | CX_TEST_ASSERT(buf.pos == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
672 | CX_TEST_ASSERT(buf.capacity == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
673 | 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
|
674 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
675 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
676 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
677 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
678 | 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
|
679 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
680 | 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
|
681 | 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
|
682 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
683 | buf.size = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
684 | buf.pos = 3; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
685 | const char *data = "testing"; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
686 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
687 | 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
|
688 | // 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
|
689 | CX_TEST_ASSERT(written == 2); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
690 | CX_TEST_ASSERT(buf.size == 7); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
691 | CX_TEST_ASSERT(buf.pos == 7); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
692 | CX_TEST_ASSERT(buf.capacity == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
693 | 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
|
694 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
695 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
696 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
697 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
698 | 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
|
699 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
700 | 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
|
701 | 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
|
702 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
703 | buf.size = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
704 | buf.pos = 3; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
705 | buf.flags |= CX_BUFFER_AUTO_EXTEND; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
706 | const char *data = "tester"; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
707 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
708 | 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
|
709 | // 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
|
710 | CX_TEST_ASSERT(written == 3); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
711 | CX_TEST_ASSERT(buf.size == 9); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
712 | CX_TEST_ASSERT(buf.pos == 9); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
713 | CX_TEST_ASSERT(buf.capacity >= 9); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
714 | 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
|
715 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
716 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
717 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
718 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
719 | 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
|
720 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
721 | 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
|
722 | 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
|
723 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
724 | buf.size = buf.pos = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
725 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
726 | int c = cxBufferPut(&buf, 0x200 | 'a'); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
727 | CX_TEST_ASSERT(c == 'a'); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
728 | CX_TEST_ASSERT(buf.size == 5); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
729 | CX_TEST_ASSERT(buf.pos == 5); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
730 | CX_TEST_ASSERT(buf.capacity == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
731 | 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
|
732 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
733 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
734 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
735 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
736 | 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
|
737 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
738 | 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
|
739 | 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
|
740 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
741 | buf.size = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
742 | buf.pos = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
743 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
744 | int c = cxBufferPut(&buf, 0x200 | 'a'); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
745 | CX_TEST_ASSERT(c == EOF); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
746 | CX_TEST_ASSERT(buf.size == 4); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
747 | CX_TEST_ASSERT(buf.pos == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
748 | CX_TEST_ASSERT(buf.capacity == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
749 | 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
|
750 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
751 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
752 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
753 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
754 | 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
|
755 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
756 | 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
|
757 | 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
|
758 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
759 | buf.size = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
760 | buf.pos = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
761 | buf.flags |= CX_BUFFER_AUTO_EXTEND; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
762 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
763 | int c = cxBufferPut(&buf, 0x200 | 'a'); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
764 | CX_TEST_ASSERT(c == 'a'); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
765 | CX_TEST_ASSERT(buf.size == 9); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
766 | CX_TEST_ASSERT(buf.pos == 9); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
767 | CX_TEST_ASSERT(buf.capacity >= 9); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
768 | 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
|
769 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
770 | cxBufferDestroy(&buf); |
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 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
773 | 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
|
774 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
775 | 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
|
776 | 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
|
777 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
778 | buf.size = buf.pos = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
779 | const char *data = "test"; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
780 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
781 | size_t written = cxBufferPutString(&buf, data); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
782 | CX_TEST_ASSERT(written == 4); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
783 | CX_TEST_ASSERT(buf.size == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
784 | CX_TEST_ASSERT(buf.pos == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
785 | CX_TEST_ASSERT(buf.capacity == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
786 | 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
|
787 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
788 | cxBufferDestroy(&buf); |
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 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
791 | 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
|
792 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
793 | 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
|
794 | 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
|
795 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
796 | buf.size = buf.pos = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
797 | const char *data = "testing"; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
798 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
799 | size_t written = cxBufferPutString(&buf, data); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
800 | CX_TEST_ASSERT(written == 4); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
801 | CX_TEST_ASSERT(buf.size == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
802 | CX_TEST_ASSERT(buf.pos == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
803 | CX_TEST_ASSERT(buf.capacity == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
804 | 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
|
805 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
806 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
807 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
808 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
809 | 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
|
810 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
811 | 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
|
812 | 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
|
813 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
814 | buf.size = buf.pos = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
815 | buf.flags |= CX_BUFFER_AUTO_EXTEND; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
816 | const char *data = "testing"; |
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 | size_t written = cxBufferPutString(&buf, data); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
819 | CX_TEST_ASSERT(written == 7); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
820 | CX_TEST_ASSERT(buf.size == 11); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
821 | CX_TEST_ASSERT(buf.pos == 11); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
822 | CX_TEST_ASSERT(buf.capacity >= 11); |
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, "preptesting", 11)); |
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); |
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
|
826 | } |
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
|
827 | |
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
|
828 | 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
|
829 | 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
|
830 | 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
|
831 | 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
|
832 | 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
|
833 | 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
|
834 | 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
|
835 | 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
|
836 | 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
|
837 | 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
|
838 | 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
|
839 | 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
|
840 | 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
|
841 | 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
|
842 | 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
|
843 | 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
|
844 | 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
|
845 | 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
|
846 | 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
|
847 | 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
|
848 | CX_TEST_ASSERT(0 == memcmp(buf.space, "preptest\0A", 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
|
849 | } |
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
|
850 | cxBufferDestroy(&buf); |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
851 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
852 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
853 | 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
|
854 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
855 | 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
|
856 | 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
|
857 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
858 | buf.size = buf.pos = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
859 | const char *data = "testing"; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
860 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
861 | 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
|
862 | CX_TEST_ASSERT(written == 0); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
863 | CX_TEST_ASSERT(buf.capacity == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
864 | CX_TEST_ASSERT(buf.pos == 4); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
865 | CX_TEST_ASSERT(buf.size == 4); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
866 | 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
|
867 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
868 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
869 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
870 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
871 | 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
|
872 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
873 | 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
|
874 | 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
|
875 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
876 | buf.size = buf.pos = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
877 | buf.flags |= CX_BUFFER_AUTO_EXTEND; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
878 | const char *data = "testing"; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
879 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
880 | 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
|
881 | CX_TEST_ASSERT(written == 0); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
882 | CX_TEST_ASSERT(buf.capacity == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
883 | CX_TEST_ASSERT(buf.pos == 4); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
884 | CX_TEST_ASSERT(buf.size == 4); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
885 | 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
|
886 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
887 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
888 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
889 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
890 | 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
|
891 | CxBuffer buf; |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
892 | 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
|
893 | 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
|
894 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
895 | buf.pos = 3; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
896 | buf.size = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
897 | buf.flags |= CX_BUFFER_AUTO_EXTEND; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
898 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
899 | 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
|
900 | CX_TEST_ASSERT(written == 2); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
901 | CX_TEST_ASSERT(buf.capacity == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
902 | CX_TEST_ASSERT(buf.size == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
903 | CX_TEST_ASSERT(buf.pos == 7); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
904 | 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
|
905 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
906 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
907 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
908 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
909 | 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
|
910 | CxBuffer buf, target; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
911 | 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
|
912 | 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
|
913 | 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
|
914 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
915 | buf.size = buf.pos = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
916 | buf.flush_target = ⌖ |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
917 | 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
|
918 | buf.flush_blkmax = 1; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
919 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
920 | 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
|
921 | CX_TEST_ASSERT(written == 3); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
922 | CX_TEST_ASSERT(buf.pos == 7); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
923 | CX_TEST_ASSERT(buf.size == 7); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
924 | CX_TEST_ASSERT(target.pos == 0); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
925 | CX_TEST_ASSERT(target.size == 0); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
926 | written = cxBufferWrite("hello", 1, 5, &buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
927 | CX_TEST_ASSERT(written == 5); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
928 | CX_TEST_ASSERT(buf.pos == 0); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
929 | CX_TEST_ASSERT(buf.size == 0); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
930 | CX_TEST_ASSERT(buf.capacity == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
931 | CX_TEST_ASSERT(target.pos == 12); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
932 | CX_TEST_ASSERT(target.size == 12); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
933 | 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
|
934 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
935 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
936 | cxBufferDestroy(&target); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
937 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
938 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
939 | 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
|
940 | CxBuffer buf, target; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
941 | 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
|
942 | 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
|
943 | 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
|
944 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
945 | buf.size = buf.pos = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
946 | buf.flush_target = ⌖ |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
947 | 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
|
948 | buf.flush_blkmax = 1; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
949 | buf.flush_threshold = 12; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
950 | buf.flags |= CX_BUFFER_AUTO_EXTEND; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
951 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
952 | 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
|
953 | CX_TEST_ASSERT(written == 6); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
954 | CX_TEST_ASSERT(buf.pos == 10); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
955 | CX_TEST_ASSERT(buf.size == 10); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
956 | CX_TEST_ASSERT(buf.capacity >= 10); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
957 | CX_TEST_ASSERT(buf.capacity <= 12); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
958 | CX_TEST_ASSERT(target.pos == 0); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
959 | CX_TEST_ASSERT(target.size == 0); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
960 | written = cxBufferWrite("hello", 1, 5, &buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
961 | CX_TEST_ASSERT(written == 5); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
962 | CX_TEST_ASSERT(buf.pos == 0); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
963 | CX_TEST_ASSERT(buf.size == 0); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
964 | CX_TEST_ASSERT(buf.capacity <= 12); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
965 | CX_TEST_ASSERT(target.pos == 15); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
966 | CX_TEST_ASSERT(target.size == 15); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
967 | 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
|
968 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
969 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
970 | cxBufferDestroy(&target); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
971 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
972 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
973 | 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
|
974 | CxBuffer buf, target; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
975 | 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
|
976 | 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
|
977 | 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
|
978 | buf.capacity = 8; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
979 | buf.size = buf.pos = 4; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
980 | buf.flush_target = ⌖ |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
981 | buf.flush_blkmax = 1; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
982 | // 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
|
983 | 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
|
984 | target.capacity = 16; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
985 | target.flags &= ~CX_BUFFER_AUTO_EXTEND; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
986 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
987 | 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
|
988 | CX_TEST_ASSERT(written == 3); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
989 | CX_TEST_ASSERT(buf.pos == 7); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
990 | CX_TEST_ASSERT(buf.size == 7); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
991 | CX_TEST_ASSERT(target.pos == 0); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
992 | CX_TEST_ASSERT(target.size == 0); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
993 | 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
|
994 | // " 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
|
995 | CX_TEST_ASSERT(written == 13); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
996 | CX_TEST_ASSERT(buf.pos == 7); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
997 | CX_TEST_ASSERT(buf.size == 7); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
998 | CX_TEST_ASSERT(buf.capacity == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
999 | 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
|
1000 | CX_TEST_ASSERT(target.pos == 13); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1001 | CX_TEST_ASSERT(target.size == 13); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1002 | CX_TEST_ASSERT(target.capacity == 16); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1003 | 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
|
1004 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1005 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1006 | cxBufferDestroy(&target); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1007 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1008 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1009 | CX_TEST(test_buffer_get) { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1010 | CxBuffer buf; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1011 | 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
|
1012 | 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
|
1013 | buf.capacity = 12; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1014 | buf.size = 9; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1015 | buf.pos = 2; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1016 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1017 | CX_TEST_ASSERT(cxBufferGet(&buf) == 'm'); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1018 | CX_TEST_ASSERT(cxBufferGet(&buf) == 'e'); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1019 | CX_TEST_ASSERT(cxBufferGet(&buf) == ' '); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1020 | CX_TEST_ASSERT(cxBufferGet(&buf) == 'd'); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1021 | CX_TEST_ASSERT(buf.pos == 6); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1022 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1023 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1024 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1025 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1026 | CX_TEST(test_buffer_get_eof) { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1027 | CxBuffer buf; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1028 | 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
|
1029 | 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
|
1030 | buf.capacity = 12; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1031 | buf.pos = buf.size = 9; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1032 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1033 | CX_TEST_ASSERT(cxBufferGet(&buf) == EOF); |
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 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1036 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1037 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1038 | CX_TEST(test_buffer_read) { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1039 | CxBuffer buf; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1040 | 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
|
1041 | 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
|
1042 | buf.capacity = 12; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1043 | buf.size = 9; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1044 | buf.pos = 2; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1045 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1046 | char target[4]; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1047 | 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
|
1048 | CX_TEST_ASSERT(read == 4); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1049 | 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
|
1050 | CX_TEST_ASSERT(buf.pos == 6); |
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 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1053 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1054 | |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1055 | CX_TEST(test_buffer_read_oob) { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1056 | CxBuffer buf; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1057 | 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
|
1058 | 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
|
1059 | buf.capacity = 12; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1060 | buf.size = 9; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1061 | buf.pos = 6; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1062 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1063 | char target[4]; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1064 | 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
|
1065 | CX_TEST_ASSERT(read == 3); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1066 | 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
|
1067 | CX_TEST_ASSERT(buf.pos == 9); |
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_read_oob_multibyte) { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1073 | CxBuffer buf; |
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, "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
|
1076 | buf.capacity = 12; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1077 | buf.size = 9; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1078 | buf.pos = 6; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1079 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1080 | char target[4]; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1081 | target[2] = '\0'; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1082 | 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
|
1083 | CX_TEST_ASSERT(read == 1); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1084 | 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
|
1085 | CX_TEST_ASSERT(buf.pos == 8); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1086 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1087 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1088 | } |
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 | CX_TEST(test_buffer_read_eof) { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1091 | CxBuffer buf; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1092 | 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
|
1093 | 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
|
1094 | buf.capacity = 12; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1095 | buf.size = buf.pos = 9; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1096 | CX_TEST_DO { |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1097 | char target[4]; |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1098 | 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
|
1099 | CX_TEST_ASSERT(read == 0); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1100 | CX_TEST_ASSERT(buf.pos == 9); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1101 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1102 | cxBufferDestroy(&buf); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1103 | } |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1104 | |
789
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1105 | CxTestSuite *cx_test_suite_buffer(void) { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1106 | 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
|
1107 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1108 | 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
|
1109 | 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
|
1110 | 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
|
1111 | 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
|
1112 | 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
|
1113 | 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
|
1114 | 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
|
1115 | cx_test_register(suite, test_buffer_clear); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1116 | 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
|
1117 | 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
|
1118 | 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
|
1119 | 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
|
1120 | 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
|
1121 | 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
|
1122 | 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
|
1123 | 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
|
1124 | 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
|
1125 | 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
|
1126 | 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
|
1127 | 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
|
1128 | 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
|
1129 | 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
|
1130 | 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
|
1131 | 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
|
1132 | 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
|
1133 | 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
|
1134 | 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
|
1135 | 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
|
1136 | cx_test_register(suite, test_buffer_shift_left_offset_interface); |
3ca984931e1d
migrate more buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
789
diff
changeset
|
1137 | 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
|
1138 | 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
|
1139 | 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
|
1140 | 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
|
1141 | 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
|
1142 | cx_test_register(suite, test_buffer_shift_right_offset_interface); |
793
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1143 | 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
|
1144 | 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
|
1145 | 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
|
1146 | 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
|
1147 | 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
|
1148 | cx_test_register(suite, test_buffer_write_multibyte_extend); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1149 | 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
|
1150 | 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
|
1151 | cx_test_register(suite, test_buffer_put_extend); |
db1c8dfe403a
migrate remaining buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
792
diff
changeset
|
1152 | 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
|
1153 | 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
|
1154 | cx_test_register(suite, 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
|
1155 | 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
|
1156 | 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
|
1157 | 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
|
1158 | 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
|
1159 | 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
|
1160 | 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
|
1161 | 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
|
1162 | 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
|
1163 | 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
|
1164 | 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
|
1165 | 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
|
1166 | 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
|
1167 | 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
|
1168 | |
789
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1169 | return suite; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1170 | } |