Skip to content

Commit bf8a947

Browse files
update tests
1 parent 0a373b3 commit bf8a947

File tree

5 files changed

+102
-60
lines changed

5 files changed

+102
-60
lines changed

libcanard/canard.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ typedef unsigned char byte_t;
6363
#define TAIL_EOT 64U
6464
#define TAIL_TOGGLE 32U
6565

66-
#define FOREACH_IFACE(i) for (size_t i = 0; i < CANARD_IFACE_COUNT; i++)
66+
#define FOREACH_IFACE(i) for (size_t i = 0; (i) < CANARD_IFACE_COUNT; (i)++)
6767

6868
#define TREE_NULL (canard_tree_t){ NULL, { NULL, NULL }, 0 }
6969

tests/src/helpers.h

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ extern "C"
2626
{
2727
#endif
2828

29+
#ifdef __cplusplus
30+
#define TEST_CAST(type, value) static_cast<type>(value)
31+
#else
32+
#define TEST_CAST(type, value) ((type)(value))
33+
#endif
34+
2935
#define TEST_PANIC(message) \
3036
do { \
3137
(void)fprintf(stderr, "%s:%u: PANIC: %s\n", __FILE__, (unsigned)__LINE__, message); \
@@ -46,7 +52,7 @@ static inline void* dummy_alloc(void* const user, const size_t size)
4652
return NULL;
4753
}
4854

49-
static inline void dummy_free(void* const user, const size_t size, void* const pointer)
55+
static inline void dummy_free(void* const user, const size_t size, const void* const pointer)
5056
{
5157
(void)user;
5258
(void)size;
@@ -82,7 +88,7 @@ typedef struct
8288

8389
static inline void* instrumented_allocator_alloc(const canard_mem_t mem, const size_t size)
8490
{
85-
instrumented_allocator_t* const self = (instrumented_allocator_t*)mem.context;
91+
instrumented_allocator_t* const self = TEST_CAST(instrumented_allocator_t*, mem.context);
8692
void* result = NULL; // NOLINT(*-const-correctness)
8793
self->count_alloc++;
8894
if ((size > 0U) && //
@@ -91,9 +97,9 @@ static inline void* instrumented_allocator_alloc(const canard_mem_t mem, const s
9197
const size_t size_with_canaries = size + ((size_t)INSTRUMENTED_ALLOCATOR_CANARY_SIZE * 2U);
9298
void* origin = malloc(size_with_canaries);
9399
TEST_PANIC_UNLESS(origin != NULL);
94-
*((size_t*)origin) = size;
95-
uint_least8_t* p = ((uint_least8_t*)origin) + sizeof(size_t); // NOLINT(*-const-correctness)
96-
result = ((uint_least8_t*)origin) + INSTRUMENTED_ALLOCATOR_CANARY_SIZE;
100+
*TEST_CAST(size_t*, origin) = size;
101+
uint_least8_t* p = TEST_CAST(uint_least8_t*, origin) + sizeof(size_t); // NOLINT(*-const-correctness)
102+
result = TEST_CAST(uint_least8_t*, origin) + INSTRUMENTED_ALLOCATOR_CANARY_SIZE;
97103
for (size_t i = sizeof(size_t); i < INSTRUMENTED_ALLOCATOR_CANARY_SIZE; i++) // Fill the front canary.
98104
{
99105
*p++ = self->canary[i];
@@ -114,12 +120,12 @@ static inline void* instrumented_allocator_alloc(const canard_mem_t mem, const s
114120

115121
static inline void instrumented_allocator_free(const canard_mem_t mem, const size_t size, void* const pointer)
116122
{
117-
instrumented_allocator_t* const self = (instrumented_allocator_t*)mem.context;
123+
instrumented_allocator_t* const self = TEST_CAST(instrumented_allocator_t*, mem.context);
118124
self->count_free++;
119125
if (pointer != NULL) { // NOLINTNEXTLINE(*-const-correctness)
120-
uint_least8_t* p = ((uint_least8_t*)pointer) - INSTRUMENTED_ALLOCATOR_CANARY_SIZE;
126+
uint_least8_t* p = TEST_CAST(uint_least8_t*, pointer) - INSTRUMENTED_ALLOCATOR_CANARY_SIZE;
121127
void* const origin = p;
122-
const size_t true_size = *((const size_t*)origin);
128+
const size_t true_size = *TEST_CAST(const size_t*, origin);
123129
TEST_PANIC_UNLESS(size == true_size);
124130
p += sizeof(size_t);
125131
for (size_t i = sizeof(size_t); i < INSTRUMENTED_ALLOCATOR_CANARY_SIZE; i++) // Check the front canary.
@@ -189,6 +195,8 @@ static inline void seed_prng(void)
189195
}
190196
#endif
191197

198+
#undef TEST_CAST
199+
192200
// NOLINTEND(*-cstyle-cast)
193201
// NOLINTEND(*DeprecatedOrUnsafeBufferHandling,*err34-c,*-vararg,*-use-auto,*-use-nullptr,*-redundant-void-arg)
194202
// NOLINTEND(*-unchecked-string-to-number-conversion,*-deprecated-headers,*-designated-initializers,*-loop-convert)

tests/src/test_api_tx.cpp

Lines changed: 80 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static bool mock_filter(canard_t* const, const size_t, const canard_filter_t*) {
3535
// Shared vtable and memory resources used by canard_new() tests.
3636
static const canard_vtable_t kTestVtable = {
3737
.now = mock_now,
38-
.on_p2p = NULL,
38+
.on_p2p = nullptr,
3939
.tx = mock_tx,
4040
.filter = mock_filter,
4141
};
@@ -45,45 +45,55 @@ static const canard_mem_vtable_t kStdMemVtable = {
4545
.alloc = std_alloc_mem,
4646
};
4747

48-
static canard_mem_set_t make_std_memory(void)
48+
static canard_mem_set_t make_std_memory()
4949
{
50-
const canard_mem_t r = { &kStdMemVtable, NULL };
51-
return canard_mem_set_t{ r, r, r, r };
50+
const canard_mem_t r = { .vtable = &kStdMemVtable, .context = nullptr };
51+
return canard_mem_set_t{
52+
.tx_transfer = r,
53+
.tx_frame = r,
54+
.rx_session = r,
55+
.rx_payload = r,
56+
};
5257
}
5358

5459
// Basic constructor argument validation.
55-
static void test_canard_new_validation(void)
60+
static void test_canard_new_validation()
5661
{
5762
canard_t self = {};
5863
canard_filter_t filters = {};
5964
const canard_mem_set_t mem = make_std_memory();
60-
const canard_mem_vtable_t bad_mv = { .free = std_free_mem, .alloc = NULL };
61-
const canard_mem_t bad_mr = { &bad_mv, NULL };
62-
const canard_mem_set_t bad_mem = canard_mem_set_t{ bad_mr, bad_mr, bad_mr, bad_mr };
65+
const canard_mem_vtable_t bad_mv = { .free = std_free_mem, .alloc = nullptr };
66+
const canard_mem_t bad_mr = { .vtable = &bad_mv, .context = nullptr };
67+
const canard_mem_set_t bad_mem = canard_mem_set_t{
68+
.tx_transfer = bad_mr,
69+
.tx_frame = bad_mr,
70+
.rx_session = bad_mr,
71+
.rx_payload = bad_mr,
72+
};
6373

64-
TEST_ASSERT_FALSE(canard_new(NULL, &kTestVtable, mem, 16, 1, 1234, 0, NULL)); // Invalid self.
65-
TEST_ASSERT_FALSE(canard_new(&self, NULL, mem, 16, 1, 1234, 0, NULL)); // Invalid vtable.
74+
TEST_ASSERT_FALSE(canard_new(nullptr, &kTestVtable, mem, 16, 1, 1234, 0, nullptr)); // Invalid self.
75+
TEST_ASSERT_FALSE(canard_new(&self, nullptr, mem, 16, 1, 1234, 0, nullptr)); // Invalid vtable.
6676
TEST_ASSERT_FALSE(
67-
canard_new(&self, &kTestVtable, mem, 16, CANARD_NODE_ID_MAX + 1U, 1234, 0, NULL)); // Invalid node-ID.
68-
TEST_ASSERT_FALSE(canard_new(&self, &kTestVtable, mem, 16, 1, 1234, 1, NULL)); // Missing filter storage.
69-
TEST_ASSERT_FALSE(canard_new(&self, &kTestVtable, bad_mem, 16, 1, 1234, 0, NULL)); // Invalid memory callbacks.
70-
TEST_ASSERT_TRUE(canard_new(&self, &kTestVtable, mem, 16, 1, 1234, 1, &filters)); // Valid constructor call.
77+
canard_new(&self, &kTestVtable, mem, 16, CANARD_NODE_ID_MAX + 1U, 1234, 0, nullptr)); // Invalid node-ID.
78+
TEST_ASSERT_FALSE(canard_new(&self, &kTestVtable, mem, 16, 1, 1234, 1, nullptr)); // Missing filter storage.
79+
TEST_ASSERT_FALSE(canard_new(&self, &kTestVtable, bad_mem, 16, 1, 1234, 0, nullptr)); // Invalid memory callbacks.
80+
TEST_ASSERT_TRUE(canard_new(&self, &kTestVtable, mem, 16, 1, 1234, 1, &filters)); // Valid constructor call.
7181
canard_destroy(&self);
7282
}
7383

7484
// Constructor initializes state; destroy purges enqueued TX state.
75-
static void test_canard_new_and_destroy(void)
85+
static void test_canard_new_and_destroy()
7686
{
7787
canard_t self = {};
7888
const canard_mem_set_t mem = make_std_memory();
79-
TEST_ASSERT_TRUE(canard_new(&self, &kTestVtable, mem, 16, 42, 0x0123456789ABCDEFULL, 0, NULL));
89+
TEST_ASSERT_TRUE(canard_new(&self, &kTestVtable, mem, 16, 42, 0x0123456789ABCDEFULL, 0, nullptr));
8090
TEST_ASSERT_EQUAL_UINT8(42U, (uint8_t)self.node_id);
8191
TEST_ASSERT_TRUE(self.tx.fd);
8292
TEST_ASSERT_EQUAL_size_t(16U, self.tx.queue_capacity);
8393
TEST_ASSERT_EQUAL_UINT64(0x0123456789ABCDEFULL, self.prng_state);
8494

8595
// Queue one transfer and ensure destroy purges it.
86-
const canard_bytes_chain_t payload = { .bytes = { .size = 0, .data = NULL }, .next = NULL };
96+
const canard_bytes_chain_t payload = { .bytes = { .size = 0, .data = nullptr }, .next = nullptr };
8797
TEST_ASSERT_TRUE(canard_publish(&self, 1000, 1, canard_prio_nominal, 123, 0, payload, CANARD_USER_CONTEXT_NULL));
8898
TEST_ASSERT_NOT_NULL(self.tx.agewise.head);
8999
TEST_ASSERT_NOT_EQUAL_size_t(0U, self.tx.queue_size);
@@ -95,13 +105,13 @@ static void test_canard_new_and_destroy(void)
95105
}
96106

97107
// Pending interface bitmap reports all interfaces that currently have pending TX.
98-
static void test_canard_pending_ifaces(void)
108+
static void test_canard_pending_ifaces()
99109
{
100110
canard_t self = {};
101111
const canard_mem_set_t mem = make_std_memory();
102-
TEST_ASSERT_TRUE(canard_new(&self, &kTestVtable, mem, 16, 1, 1234, 0, NULL));
112+
TEST_ASSERT_TRUE(canard_new(&self, &kTestVtable, mem, 16, 1, 1234, 0, nullptr));
103113

104-
const canard_bytes_chain_t payload = { .bytes = { .size = 0, .data = NULL }, .next = NULL };
114+
const canard_bytes_chain_t payload = { .bytes = { .size = 0, .data = nullptr }, .next = nullptr };
105115
TEST_ASSERT_EQUAL_UINT8(0U, canard_pending_ifaces(&self));
106116
TEST_ASSERT_TRUE(canard_publish(&self, 1000, 1U, canard_prio_nominal, 10U, 0U, payload, CANARD_USER_CONTEXT_NULL));
107117
TEST_ASSERT_TRUE(canard_publish(&self, 1000, 2U, canard_prio_nominal, 11U, 1U, payload, CANARD_USER_CONTEXT_NULL));
@@ -111,73 +121,96 @@ static void test_canard_pending_ifaces(void)
111121
}
112122

113123
// Golden signatures generated from pydronecan (dronecan 1.0.24), standard uavcan.* types.
114-
static void test_canard_0v1_crc_seed_from_data_type_signature_golden(void)
124+
static void test_canard_0v1_crc_seed_from_data_type_signature_golden()
115125
{
116126
struct test_vector_t
117127
{
118128
uint64_t signature;
119129
uint16_t expected_seed;
120130
};
121131
static const test_vector_t vectors[] = {
122-
{ 0xD8A7486238EC3AF3ULL, 0x5E37U }, { 0x5E9BBA44FAF1EA04ULL, 0x9A63U }, { 0xE2A7D4A9460BC2F2ULL, 0x037CU },
123-
{ 0xB6AC0C442430297EULL, 0xBA25U }, { 0x8280632C40E574B5ULL, 0x4E3EU }, { 0x72A63A3C6F41FA9BULL, 0x2055U },
124-
{ 0xD5513C3F7AFAC74EULL, 0x94ADU }, { 0x0A1892D72AB8945FULL, 0x02CFU }, { 0xC77DF38BA122F5DAULL, 0x506EU },
125-
{ 0x7B48E55FCFF42A57ULL, 0xC02BU }, { 0xCDC7C43412BDC89AULL, 0xEBF4U }, { 0x49272A6477D96271ULL, 0x17A4U },
126-
{ 0x306F69E0A591AFAAULL, 0x472DU }, { 0x4AF6E57B2B2BE29CULL, 0xCD1FU }, { 0x9371428A92F01FD6ULL, 0x87DBU },
127-
{ 0xB9F127865BE0D61EULL, 0xEFD0U }, { 0x70261C28A94144C6ULL, 0x5D7EU }, { 0xCE0F9F621CF7E70BULL, 0xF8B4U },
128-
{ 0x217F5C87D7EC951DULL, 0xE4B8U }, { 0xA9AF28AEA2FBB254ULL, 0x1591U }, { 0x9BE8BDC4C3DBBFD2ULL, 0x24AEU },
129-
{ 0x54C1572B9E07F297ULL, 0x9510U }, { 0xCA41E7000F37435FULL, 0xC798U }, { 0x1F56030ECB171501ULL, 0x897EU },
130-
{ 0xA1A036268B0C3455ULL, 0x3004U }, { 0x624A519D42553D82ULL, 0xAEE4U }, { 0x286B4A387BA84BC4ULL, 0xBF2EU },
131-
{ 0xD38AA3EE75537EC6ULL, 0x41D9U }, { 0xBE9EA9FEC2B15D52ULL, 0xDFBDU }, { 0x2031D93C8BDD1EC4ULL, 0x9E31U },
132-
{ 0x249C26548A711966ULL, 0xF674U }, { 0x8313D33D0DDDA115ULL, 0x2CB7U }, { 0xBBA05074AD757480ULL, 0x591FU },
133-
{ 0x68FFFE70FC771952ULL, 0x049CU }, { 0x8700F375556A8003ULL, 0x1890U }, { 0x463B10CCCBE51C3DULL, 0x1D70U },
132+
{ .signature = 0xD8A7486238EC3AF3ULL, .expected_seed = 0x5E37U },
133+
{ .signature = 0x5E9BBA44FAF1EA04ULL, .expected_seed = 0x9A63U },
134+
{ .signature = 0xE2A7D4A9460BC2F2ULL, .expected_seed = 0x037CU },
135+
{ .signature = 0xB6AC0C442430297EULL, .expected_seed = 0xBA25U },
136+
{ .signature = 0x8280632C40E574B5ULL, .expected_seed = 0x4E3EU },
137+
{ .signature = 0x72A63A3C6F41FA9BULL, .expected_seed = 0x2055U },
138+
{ .signature = 0xD5513C3F7AFAC74EULL, .expected_seed = 0x94ADU },
139+
{ .signature = 0x0A1892D72AB8945FULL, .expected_seed = 0x02CFU },
140+
{ .signature = 0xC77DF38BA122F5DAULL, .expected_seed = 0x506EU },
141+
{ .signature = 0x7B48E55FCFF42A57ULL, .expected_seed = 0xC02BU },
142+
{ .signature = 0xCDC7C43412BDC89AULL, .expected_seed = 0xEBF4U },
143+
{ .signature = 0x49272A6477D96271ULL, .expected_seed = 0x17A4U },
144+
{ .signature = 0x306F69E0A591AFAAULL, .expected_seed = 0x472DU },
145+
{ .signature = 0x4AF6E57B2B2BE29CULL, .expected_seed = 0xCD1FU },
146+
{ .signature = 0x9371428A92F01FD6ULL, .expected_seed = 0x87DBU },
147+
{ .signature = 0xB9F127865BE0D61EULL, .expected_seed = 0xEFD0U },
148+
{ .signature = 0x70261C28A94144C6ULL, .expected_seed = 0x5D7EU },
149+
{ .signature = 0xCE0F9F621CF7E70BULL, .expected_seed = 0xF8B4U },
150+
{ .signature = 0x217F5C87D7EC951DULL, .expected_seed = 0xE4B8U },
151+
{ .signature = 0xA9AF28AEA2FBB254ULL, .expected_seed = 0x1591U },
152+
{ .signature = 0x9BE8BDC4C3DBBFD2ULL, .expected_seed = 0x24AEU },
153+
{ .signature = 0x54C1572B9E07F297ULL, .expected_seed = 0x9510U },
154+
{ .signature = 0xCA41E7000F37435FULL, .expected_seed = 0xC798U },
155+
{ .signature = 0x1F56030ECB171501ULL, .expected_seed = 0x897EU },
156+
{ .signature = 0xA1A036268B0C3455ULL, .expected_seed = 0x3004U },
157+
{ .signature = 0x624A519D42553D82ULL, .expected_seed = 0xAEE4U },
158+
{ .signature = 0x286B4A387BA84BC4ULL, .expected_seed = 0xBF2EU },
159+
{ .signature = 0xD38AA3EE75537EC6ULL, .expected_seed = 0x41D9U },
160+
{ .signature = 0xBE9EA9FEC2B15D52ULL, .expected_seed = 0xDFBDU },
161+
{ .signature = 0x2031D93C8BDD1EC4ULL, .expected_seed = 0x9E31U },
162+
{ .signature = 0x249C26548A711966ULL, .expected_seed = 0xF674U },
163+
{ .signature = 0x8313D33D0DDDA115ULL, .expected_seed = 0x2CB7U },
164+
{ .signature = 0xBBA05074AD757480ULL, .expected_seed = 0x591FU },
165+
{ .signature = 0x68FFFE70FC771952ULL, .expected_seed = 0x049CU },
166+
{ .signature = 0x8700F375556A8003ULL, .expected_seed = 0x1890U },
167+
{ .signature = 0x463B10CCCBE51C3DULL, .expected_seed = 0x1D70U },
134168
};
135-
for (size_t i = 0; i < (sizeof(vectors) / sizeof(vectors[0])); i++) {
136-
TEST_ASSERT_EQUAL_HEX16(vectors[i].expected_seed,
137-
canard_0v1_crc_seed_from_data_type_signature(vectors[i].signature));
169+
for (const test_vector_t& vector : vectors) {
170+
TEST_ASSERT_EQUAL_HEX16(vector.expected_seed, canard_0v1_crc_seed_from_data_type_signature(vector.signature));
138171
}
139172
}
140173

141-
static void test_canard_publish_validation(void)
174+
static void test_canard_publish_validation()
142175
{
143176
canard_t self = {};
144177

145178
// Invalid interface bitmap.
146-
const canard_bytes_chain_t payload = { .bytes = { .size = 0, .data = NULL }, .next = NULL };
179+
const canard_bytes_chain_t payload = { .bytes = { .size = 0, .data = nullptr }, .next = nullptr };
147180
TEST_ASSERT_FALSE(canard_publish(&self, 0, 0, canard_prio_nominal, 0, 0, payload, CANARD_USER_CONTEXT_NULL));
148181

149182
// Invalid payload.
150-
const canard_bytes_chain_t bad_payload = { .bytes = { .size = 1, .data = NULL }, .next = NULL };
183+
const canard_bytes_chain_t bad_payload = { .bytes = { .size = 1, .data = nullptr }, .next = nullptr };
151184
TEST_ASSERT_FALSE(canard_publish(&self, 0, 1, canard_prio_nominal, 0, 0, bad_payload, CANARD_USER_CONTEXT_NULL));
152185
}
153186

154-
static void test_canard_publish_oom(void)
187+
static void test_canard_publish_oom()
155188
{
156189
canard_mem_vtable_t vtable = {};
157190
vtable.free = dummy_free_mem;
158191
vtable.alloc = dummy_alloc_mem;
159192
canard_t self = {};
160-
self.mem.tx_transfer = canard_mem_t{ &vtable, NULL };
161-
self.mem.tx_frame = canard_mem_t{ &vtable, NULL };
193+
self.mem.tx_transfer = canard_mem_t{ .vtable = &vtable, .context = nullptr };
194+
self.mem.tx_frame = canard_mem_t{ .vtable = &vtable, .context = nullptr };
162195

163196
// Allocation failure in txfer_new should return false.
164-
const canard_bytes_chain_t payload = { .bytes = { .size = 0, .data = NULL }, .next = NULL };
197+
const canard_bytes_chain_t payload = { .bytes = { .size = 0, .data = nullptr }, .next = nullptr };
165198
TEST_ASSERT_FALSE(canard_publish(&self, 0, 1, canard_prio_nominal, 0, 0, payload, CANARD_USER_CONTEXT_NULL));
166199
}
167200

168-
static void test_canard_0v1_publish_requires_node_id(void)
201+
static void test_canard_0v1_publish_requires_node_id()
169202
{
170203
canard_t self = {};
171204

172205
// Node-ID zero should reject the request.
173-
const canard_bytes_chain_t payload = { .bytes = { .size = 0, .data = NULL }, .next = NULL };
206+
const canard_bytes_chain_t payload = { .bytes = { .size = 0, .data = nullptr }, .next = nullptr };
174207
TEST_ASSERT_FALSE(
175208
canard_0v1_publish(&self, 0, 1, canard_prio_nominal, 1, 0xFFFF, 0, payload, CANARD_USER_CONTEXT_NULL));
176209
}
177210

178-
static void test_canard_publish_subject_id_out_of_range(void)
211+
static void test_canard_publish_subject_id_out_of_range()
179212
{
180-
const canard_bytes_chain_t payload = { .bytes = { .size = 0, .data = NULL }, .next = NULL };
213+
const canard_bytes_chain_t payload = { .bytes = { .size = 0, .data = nullptr }, .next = nullptr };
181214
canard_t self = {};
182215
TEST_ASSERT_FALSE(canard_publish(
183216
&self, 0, 1, canard_prio_nominal, CANARD_SUBJECT_ID_MAX + 1U, 0, payload, CANARD_USER_CONTEXT_NULL));

tests/src/test_helpers.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@ static void test_instrumented_allocator(void)
2727
TEST_ASSERT_EQUAL_UINT64(2, al.count_alloc);
2828
TEST_ASSERT_EQUAL_UINT64(0, al.count_free);
2929

30-
al.limit_bytes = 600;
31-
al.limit_fragments = 2;
30+
al.limit_bytes = 600;
3231

3332
TEST_ASSERT_EQUAL_PTR(NULL, resource.vtable->alloc(resource, 100));
3433
TEST_ASSERT_EQUAL_size_t(2, al.allocated_fragments);
3534
TEST_ASSERT_EQUAL_size_t(579, al.allocated_bytes);
3635
TEST_ASSERT_EQUAL_UINT64(3, al.count_alloc);
3736
TEST_ASSERT_EQUAL_UINT64(0, al.count_free);
3837

38+
al.limit_fragments = 2;
3939
TEST_ASSERT_EQUAL_PTR(NULL, resource.vtable->alloc(resource, 21));
4040
TEST_ASSERT_EQUAL_size_t(2, al.allocated_fragments);
4141
TEST_ASSERT_EQUAL_size_t(579, al.allocated_bytes);
4242
TEST_ASSERT_EQUAL_UINT64(4, al.count_alloc);
4343
TEST_ASSERT_EQUAL_UINT64(0, al.count_free);
44-
al.limit_fragments = 4;
44+
al.limit_fragments += 2;
4545

4646
void* c = resource.vtable->alloc(resource, 21);
4747
TEST_ASSERT_EQUAL_size_t(3, al.allocated_fragments);

tests/src/test_intrusive_util.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ static void test_math_helpers(void)
101101
static void test_crc_add(void)
102102
{
103103
// Empty input returns initial CRC unchanged.
104-
TEST_ASSERT_EQUAL_HEX16(0xFFFF, crc_add(CRC_INITIAL, 0, NULL));
104+
const uint8_t unused = 0U;
105+
TEST_ASSERT_EQUAL_HEX16(0xFFFF, crc_add(CRC_INITIAL, 0, &unused));
105106

106107
// Single bytes.
107108
uint8_t data = 0x00;

0 commit comments

Comments
 (0)