Mon, 01 Jan 2024 16:43:18 +0100
some text replacements to prepare migration of list tests
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 { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
266 | int result = cxBufferSeek(&buf, 6, SEEK_SET); |
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 { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
318 | 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
|
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); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
345 | // the (past-the-)end position is always invalid |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
346 | CX_TEST_ASSERT(result != 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
347 | CX_TEST_ASSERT(buf.pos == 3); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
348 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
349 | cxBufferDestroy(&buf); |
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 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
352 | 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
|
353 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
354 | 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
|
355 | buf.size = 6; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
356 | buf.pos = 3; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
357 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
358 | 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
|
359 | CX_TEST_ASSERT(result == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
360 | CX_TEST_ASSERT(buf.pos == 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
361 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
362 | cxBufferDestroy(&buf); |
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 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
365 | 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
|
366 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
367 | 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
|
368 | buf.size = 6; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
369 | buf.pos = 3; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
370 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
371 | 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
|
372 | CX_TEST_ASSERT(result != 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
373 | CX_TEST_ASSERT(buf.pos == 3); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
374 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
375 | cxBufferDestroy(&buf); |
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 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
378 | 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
|
379 | CxBuffer buf; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
380 | 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
|
381 | buf.size = 6; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
382 | buf.pos = 3; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
383 | CX_TEST_DO { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
384 | int result = cxBufferSeek(&buf, 2, 9000); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
385 | CX_TEST_ASSERT(result != 0); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
386 | CX_TEST_ASSERT(buf.size == 6); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
387 | CX_TEST_ASSERT(buf.pos == 3); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
388 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
389 | cxBufferDestroy(&buf); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
390 | } |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
391 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
392 | CxTestSuite *cx_test_suite_buffer(void) { |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
393 | 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
|
394 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
395 | 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
|
396 | 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
|
397 | 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
|
398 | 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
|
399 | 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
|
400 | 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
|
401 | 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
|
402 | 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
|
403 | 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
|
404 | 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
|
405 | 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
|
406 | 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
|
407 | 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
|
408 | 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
|
409 | 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
|
410 | 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
|
411 | 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
|
412 | 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
|
413 | 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
|
414 | 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
|
415 | cx_test_register(suite, test_buffer_seek_whence_invalid); |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
416 | |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
417 | return suite; |
9b2f5661bebd
begin migration of buffer tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
418 | } |