blob: 894fc6727cc87db08b3dcefe158e773bd80f0c61 [file] [log] [blame]
Ronald Cron4b8b1992020-06-09 13:52:23 +02001/**
2 * \file macros.h
3 *
4 * \brief This file contains generic macros for the purpose of testing.
5 */
6
Bence Szépkúti86974652020-06-15 11:59:37 +02007/*
Bence Szépkúti1e148272020-08-07 13:07:28 +02008 * Copyright The Mbed TLS Contributors
Dave Rodgman7ff79652023-11-03 12:04:52 +00009 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
Ronald Cron4b8b1992020-06-09 13:52:23 +020010 */
11
12#ifndef TEST_MACROS_H
13#define TEST_MACROS_H
14
15#if !defined(MBEDTLS_CONFIG_FILE)
16#include "mbedtls/config.h"
17#else
18#include MBEDTLS_CONFIG_FILE
19#endif
20
Ronald Cron849930a2020-06-03 08:06:47 +020021#include <stdlib.h>
22
Ronald Cron849930a2020-06-03 08:06:47 +020023#include "mbedtls/platform.h"
Ronald Cron849930a2020-06-03 08:06:47 +020024
25#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
26#include "mbedtls/memory_buffer_alloc.h"
27#endif
28
Chris Jonesa6d155f2021-02-09 12:09:33 +000029/**
30 * \brief This macro tests the expression passed to it as a test step or
31 * individual test in a test case.
32 *
33 * It allows a library function to return a value and return an error
34 * code that can be tested.
35 *
36 * When MBEDTLS_CHECK_PARAMS is enabled, calls to the parameter failure
37 * callback, MBEDTLS_PARAM_FAILED(), will be assumed to be a test
38 * failure.
39 *
40 * This macro is not suitable for negative parameter validation tests,
41 * as it assumes the test step will not create an error.
42 *
43 * Failing the test means:
44 * - Mark this test case as failed.
45 * - Print a message identifying the failure.
46 * - Jump to the \c exit label.
47 *
48 * This macro expands to an instruction, not an expression.
49 * It may jump to the \c exit label.
50 *
51 * \param TEST The test expression to be tested.
52 */
Gilles Peskine1b6c09a2023-01-11 14:52:35 +010053#define TEST_ASSERT(TEST) \
Chris Jonesa6d155f2021-02-09 12:09:33 +000054 do { \
Gilles Peskine1b6c09a2023-01-11 14:52:35 +010055 if (!(TEST)) \
56 { \
57 mbedtls_test_fail( #TEST, __LINE__, __FILE__); \
58 goto exit; \
59 } \
60 } while (0)
Chris Jonesa6d155f2021-02-09 12:09:33 +000061
Agathiyan Bragadeesh27e29892023-07-14 17:28:27 +010062/** This macro asserts fails the test with given output message.
63 *
64 * \param MESSAGE The message to be outputed on assertion
65 */
66#define TEST_FAIL(MESSAGE) \
67 do { \
68 mbedtls_test_fail(MESSAGE, __LINE__, __FILE__); \
Agathiyan Bragadeesh1dd20a32023-07-21 17:07:00 +010069 goto exit; \
70 } while (0)
Agathiyan Bragadeesh27e29892023-07-14 17:28:27 +010071
Gilles Peskineb4366492021-04-29 20:28:54 +020072/** Evaluate two integer expressions and fail the test case if they have
73 * different values.
Chris Jonesa6d155f2021-02-09 12:09:33 +000074 *
Gilles Peskineb4366492021-04-29 20:28:54 +020075 * The two expressions should have the same signedness, otherwise the
76 * comparison is not meaningful if the signed value is negative.
77 *
78 * \param expr1 An integral-typed expression to evaluate.
79 * \param expr2 Another integral-typed expression to evaluate.
Chris Jonesa6d155f2021-02-09 12:09:33 +000080 */
Gilles Peskine1b6c09a2023-01-11 14:52:35 +010081#define TEST_EQUAL(expr1, expr2) \
Gilles Peskineb4366492021-04-29 20:28:54 +020082 do { \
Gilles Peskine1b6c09a2023-01-11 14:52:35 +010083 if (!mbedtls_test_equal( #expr1 " == " #expr2, __LINE__, __FILE__, \
84 expr1, expr2)) \
85 goto exit; \
86 } while (0)
Chris Jonesa6d155f2021-02-09 12:09:33 +000087
Gilles Peskine063700d2022-04-13 23:59:52 +020088/** Evaluate two unsigned integer expressions and fail the test case
89 * if they are not in increasing order (left <= right).
90 *
91 * \param expr1 An integral-typed expression to evaluate.
92 * \param expr2 Another integral-typed expression to evaluate.
93 */
Gilles Peskine1b6c09a2023-01-11 14:52:35 +010094#define TEST_LE_U(expr1, expr2) \
Gilles Peskine063700d2022-04-13 23:59:52 +020095 do { \
Gilles Peskine1b6c09a2023-01-11 14:52:35 +010096 if (!mbedtls_test_le_u( #expr1 " <= " #expr2, __LINE__, __FILE__, \
97 expr1, expr2)) \
98 goto exit; \
99 } while (0)
Gilles Peskine063700d2022-04-13 23:59:52 +0200100
101/** Evaluate two signed integer expressions and fail the test case
102 * if they are not in increasing order (left <= right).
103 *
104 * \param expr1 An integral-typed expression to evaluate.
105 * \param expr2 Another integral-typed expression to evaluate.
106 */
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100107#define TEST_LE_S(expr1, expr2) \
Gilles Peskine063700d2022-04-13 23:59:52 +0200108 do { \
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100109 if (!mbedtls_test_le_s( #expr1 " <= " #expr2, __LINE__, __FILE__, \
110 expr1, expr2)) \
111 goto exit; \
112 } while (0)
Gilles Peskine063700d2022-04-13 23:59:52 +0200113
Chris Jonesa6d155f2021-02-09 12:09:33 +0000114/** Allocate memory dynamically and fail the test case if this fails.
115 * The allocated memory will be filled with zeros.
116 *
117 * You must set \p pointer to \c NULL before calling this macro and
Tom Cosgrovecd5a7c72023-07-21 11:34:44 +0100118 * put `mbedtls_free(pointer)` in the test's cleanup code.
Chris Jonesa6d155f2021-02-09 12:09:33 +0000119 *
Tom Cosgrovecd5a7c72023-07-21 11:34:44 +0100120 * If \p item_count is zero, the resulting \p pointer will be \c NULL.
Chris Jonesa6d155f2021-02-09 12:09:33 +0000121 * This is usually what we want in tests since API functions are
122 * supposed to accept null pointers when a buffer size is zero.
123 *
124 * This macro expands to an instruction, not an expression.
125 * It may jump to the \c exit label.
126 *
Tom Cosgrovecd5a7c72023-07-21 11:34:44 +0100127 * \param pointer An lvalue where the address of the allocated buffer
128 * will be stored.
129 * This expression may be evaluated multiple times.
130 * \param item_count Number of elements to allocate.
131 * This expression may be evaluated multiple times.
Chris Jonesa6d155f2021-02-09 12:09:33 +0000132 *
133 */
Tom Cosgrovecd5a7c72023-07-21 11:34:44 +0100134#define TEST_CALLOC(pointer, item_count) \
Tom Cosgrove13575022023-09-04 11:05:59 +0100135 do { \
136 TEST_ASSERT((pointer) == NULL); \
Tom Cosgrovecd5a7c72023-07-21 11:34:44 +0100137 if ((item_count) != 0) { \
Tom Cosgrove13575022023-09-04 11:05:59 +0100138 (pointer) = mbedtls_calloc(sizeof(*(pointer)), \
Tom Cosgrovecd5a7c72023-07-21 11:34:44 +0100139 (item_count)); \
Tom Cosgrove13575022023-09-04 11:05:59 +0100140 TEST_ASSERT((pointer) != NULL); \
141 } \
142 } while (0)
143
Dave Rodgman72aa6832023-09-19 17:34:39 +0100144/** Allocate memory dynamically and fail the test case if this fails.
145 * The allocated memory will be filled with zeros.
146 *
147 * You must set \p pointer to \c NULL before calling this macro and
148 * put `mbedtls_free(pointer)` in the test's cleanup code.
149 *
150 * If \p item_count is zero, the resulting \p pointer will not be \c NULL.
151 *
152 * This macro expands to an instruction, not an expression.
153 * It may jump to the \c exit label.
154 *
155 * \param pointer An lvalue where the address of the allocated buffer
156 * will be stored.
157 * This expression may be evaluated multiple times.
158 * \param item_count Number of elements to allocate.
159 * This expression may be evaluated multiple times.
160 *
Dave Rodgman3ca2f5c2023-09-19 18:30:25 +0100161 * Note: if passing size 0, mbedtls_calloc may return NULL. In this case,
162 * we reattempt to allocate with the smallest possible buffer to assure a
163 * non-NULL pointer.
Dave Rodgman72aa6832023-09-19 17:34:39 +0100164 */
165#define TEST_CALLOC_NONNULL(pointer, item_count) \
166 do { \
167 TEST_ASSERT((pointer) == NULL); \
168 (pointer) = mbedtls_calloc(sizeof(*(pointer)), \
169 (item_count)); \
Dave Rodgman3ca2f5c2023-09-19 18:30:25 +0100170 if (((pointer) == NULL) && ((item_count) == 0)) { \
171 (pointer) = mbedtls_calloc(1, 1); \
172 } \
Dave Rodgman72aa6832023-09-19 17:34:39 +0100173 TEST_ASSERT((pointer) != NULL); \
174 } while (0)
175
Tom Cosgrove13575022023-09-04 11:05:59 +0100176/* For backwards compatibility */
Tom Cosgrovecd5a7c72023-07-21 11:34:44 +0100177#define ASSERT_ALLOC(pointer, item_count) TEST_CALLOC(pointer, item_count)
Chris Jonesa6d155f2021-02-09 12:09:33 +0000178
179/** Allocate memory dynamically. If the allocation fails, skip the test case.
180 *
Tom Cosgrove30ceb232023-09-04 11:20:19 +0100181 * This macro behaves like #TEST_CALLOC, except that if the allocation
Chris Jonesa6d155f2021-02-09 12:09:33 +0000182 * fails, it marks the test as skipped rather than failed.
183 */
Tom Cosgrovecd5a7c72023-07-21 11:34:44 +0100184#define TEST_CALLOC_OR_SKIP(pointer, item_count) \
Tom Cosgrove20e27de2023-09-04 11:09:08 +0100185 do { \
186 TEST_ASSERT((pointer) == NULL); \
Tom Cosgrovecd5a7c72023-07-21 11:34:44 +0100187 if ((item_count) != 0) { \
Tom Cosgrove20e27de2023-09-04 11:09:08 +0100188 (pointer) = mbedtls_calloc(sizeof(*(pointer)), \
Tom Cosgrovecd5a7c72023-07-21 11:34:44 +0100189 (item_count)); \
Tom Cosgrove20e27de2023-09-04 11:09:08 +0100190 TEST_ASSUME((pointer) != NULL); \
191 } \
192 } while (0)
193
194/* For backwards compatibility */
Tom Cosgrovecd5a7c72023-07-21 11:34:44 +0100195#define ASSERT_ALLOC_WEAK(pointer, item_count) TEST_CALLOC_OR_SKIP(pointer, item_count)
Chris Jonesa6d155f2021-02-09 12:09:33 +0000196
197/** Compare two buffers and fail the test case if they differ.
198 *
199 * This macro expands to an instruction, not an expression.
200 * It may jump to the \c exit label.
201 *
202 * \param p1 Pointer to the start of the first buffer.
203 * \param size1 Size of the first buffer in bytes.
204 * This expression may be evaluated multiple times.
205 * \param p2 Pointer to the start of the second buffer.
206 * \param size2 Size of the second buffer in bytes.
207 * This expression may be evaluated multiple times.
208 */
Tom Cosgroveba3b14d2023-09-04 11:23:02 +0100209#define TEST_MEMORY_COMPARE(p1, size1, p2, size2) \
Tom Cosgrovef88ee8b2023-09-04 11:04:40 +0100210 do { \
Manuel Pégourié-Gonnard3c301912023-02-09 09:15:04 +0100211 TEST_EQUAL((size1), (size2)); \
Tom Cosgrovef88ee8b2023-09-04 11:04:40 +0100212 if ((size1) != 0) { \
213 TEST_ASSERT(memcmp((p1), (p2), (size1)) == 0); \
214 } \
215 } while (0)
216
217/* For backwards compatibility */
Tom Cosgroveba3b14d2023-09-04 11:23:02 +0100218#define ASSERT_COMPARE(p1, size1, p2, size2) TEST_MEMORY_COMPARE(p1, size1, p2, size2)
Chris Jonesa6d155f2021-02-09 12:09:33 +0000219
220/**
221 * \brief This macro tests the expression passed to it and skips the
222 * running test if it doesn't evaluate to 'true'.
223 *
224 * \param TEST The test expression to be tested.
225 */
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100226#define TEST_ASSUME(TEST) \
Chris Jonesa6d155f2021-02-09 12:09:33 +0000227 do { \
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100228 if (!(TEST)) \
Chris Jonesa6d155f2021-02-09 12:09:33 +0000229 { \
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100230 mbedtls_test_skip( #TEST, __LINE__, __FILE__); \
Chris Jonesa6d155f2021-02-09 12:09:33 +0000231 goto exit; \
232 } \
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100233 } while (0)
Chris Jonesa6d155f2021-02-09 12:09:33 +0000234
235#if defined(MBEDTLS_CHECK_PARAMS) && !defined(MBEDTLS_PARAM_FAILED_ALT)
236/**
237 * \brief This macro tests the statement passed to it as a test step or
238 * individual test in a test case. The macro assumes the test will fail
239 * and will generate an error.
240 *
241 * It allows a library function to return a value and tests the return
242 * code on return to confirm the given error code was returned.
243 *
244 * When MBEDTLS_CHECK_PARAMS is enabled, calls to the parameter failure
245 * callback, MBEDTLS_PARAM_FAILED(), are assumed to indicate the
246 * expected failure, and the test will pass.
247 *
248 * This macro is intended for negative parameter validation tests,
249 * where the failing function may return an error value or call
250 * MBEDTLS_PARAM_FAILED() to indicate the error.
251 *
252 * \param PARAM_ERROR_VALUE The expected error code.
253 *
254 * \param TEST The test expression to be tested.
255 */
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100256#define TEST_INVALID_PARAM_RET(PARAM_ERR_VALUE, TEST) \
Chris Jonesa6d155f2021-02-09 12:09:33 +0000257 do { \
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100258 mbedtls_test_param_failed_expect_call(); \
259 if (((TEST) != (PARAM_ERR_VALUE)) || \
260 (mbedtls_test_param_failed_check_expected_call() != 0)) \
Chris Jonesa6d155f2021-02-09 12:09:33 +0000261 { \
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100262 mbedtls_test_fail( #TEST, __LINE__, __FILE__); \
Chris Jonesa6d155f2021-02-09 12:09:33 +0000263 goto exit; \
264 } \
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100265 mbedtls_test_param_failed_check_expected_call(); \
266 } while (0)
Chris Jonesa6d155f2021-02-09 12:09:33 +0000267
268/**
269 * \brief This macro tests the statement passed to it as a test step or
270 * individual test in a test case. The macro assumes the test will fail
271 * and will generate an error.
272 *
273 * It assumes the library function under test cannot return a value and
274 * assumes errors can only be indicated byt calls to
275 * MBEDTLS_PARAM_FAILED().
276 *
277 * When MBEDTLS_CHECK_PARAMS is enabled, calls to the parameter failure
278 * callback, MBEDTLS_PARAM_FAILED(), are assumed to indicate the
279 * expected failure. If MBEDTLS_CHECK_PARAMS is not enabled, no test
280 * can be made.
281 *
282 * This macro is intended for negative parameter validation tests,
283 * where the failing function can only return an error by calling
284 * MBEDTLS_PARAM_FAILED() to indicate the error.
285 *
286 * \param TEST The test expression to be tested.
287 */
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100288#define TEST_INVALID_PARAM(TEST) \
Chris Jonesa6d155f2021-02-09 12:09:33 +0000289 do { \
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100290 memcpy(jmp_tmp, mbedtls_test_param_failed_get_state_buf(), \
291 sizeof(jmp_tmp)); \
292 if (setjmp(mbedtls_test_param_failed_get_state_buf()) == 0) \
Chris Jonesa6d155f2021-02-09 12:09:33 +0000293 { \
294 TEST; \
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100295 mbedtls_test_fail( #TEST, __LINE__, __FILE__); \
Chris Jonesa6d155f2021-02-09 12:09:33 +0000296 goto exit; \
297 } \
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100298 mbedtls_test_param_failed_reset_state(); \
299 } while (0)
Chris Jonesa6d155f2021-02-09 12:09:33 +0000300#endif /* MBEDTLS_CHECK_PARAMS && !MBEDTLS_PARAM_FAILED_ALT */
301
302/**
303 * \brief This macro tests the statement passed to it as a test step or
304 * individual test in a test case. The macro assumes the test will not fail.
305 *
306 * It assumes the library function under test cannot return a value and
307 * assumes errors can only be indicated by calls to
308 * MBEDTLS_PARAM_FAILED().
309 *
310 * When MBEDTLS_CHECK_PARAMS is enabled, calls to the parameter failure
311 * callback, MBEDTLS_PARAM_FAILED(), are assumed to indicate the
312 * expected failure. If MBEDTLS_CHECK_PARAMS is not enabled, no test
313 * can be made.
314 *
315 * This macro is intended to test that functions returning void
316 * accept all of the parameter values they're supposed to accept - eg
317 * that they don't call MBEDTLS_PARAM_FAILED() when a parameter
318 * that's allowed to be NULL happens to be NULL.
319 *
320 * Note: for functions that return something other that void,
321 * checking that they accept all the parameters they're supposed to
322 * accept is best done by using TEST_ASSERT() and checking the return
323 * value as well.
324 *
325 * Note: this macro is available even when #MBEDTLS_CHECK_PARAMS is
326 * disabled, as it makes sense to check that the functions accept all
327 * legal values even if this option is disabled - only in that case,
328 * the test is more about whether the function segfaults than about
329 * whether it invokes MBEDTLS_PARAM_FAILED().
330 *
331 * \param TEST The test expression to be tested.
332 */
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100333#define TEST_VALID_PARAM(TEST) \
334 TEST_ASSERT((TEST, 1));
Chris Jonesa6d155f2021-02-09 12:09:33 +0000335
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100336#define TEST_HELPER_ASSERT(a) if (!(a)) \
337 { \
338 mbedtls_fprintf(stderr, "Assertion Failed at %s:%d - %s\n", \
339 __FILE__, __LINE__, #a); \
340 mbedtls_exit(1); \
341 }
Ronald Cron849930a2020-06-03 08:06:47 +0200342
Gilles Peskinec86a1652021-02-15 12:17:00 +0100343/** \def ARRAY_LENGTH
344 * Return the number of elements of a static or stack array.
345 *
346 * \param array A value of array (not pointer) type.
347 *
348 * \return The number of elements of the array.
349 */
350/* A correct implementation of ARRAY_LENGTH, but which silently gives
351 * a nonsensical result if called with a pointer rather than an array. */
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100352#define ARRAY_LENGTH_UNSAFE(array) \
353 (sizeof(array) / sizeof(*(array)))
Gilles Peskinec86a1652021-02-15 12:17:00 +0100354
Ronald Cron849930a2020-06-03 08:06:47 +0200355#if defined(__GNUC__)
356/* Test if arg and &(arg)[0] have the same type. This is true if arg is
357 * an array but not if it's a pointer. */
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100358#define IS_ARRAY_NOT_POINTER(arg) \
359 (!__builtin_types_compatible_p(__typeof__(arg), \
360 __typeof__(&(arg)[0])))
Ronald Cron849930a2020-06-03 08:06:47 +0200361/* A compile-time constant with the value 0. If `const_expr` is not a
362 * compile-time constant with a nonzero value, cause a compile-time error. */
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100363#define STATIC_ASSERT_EXPR(const_expr) \
364 (0 && sizeof(struct { unsigned int STATIC_ASSERT : 1 - 2 * !(const_expr); }))
Gilles Peskinec86a1652021-02-15 12:17:00 +0100365
Ronald Cron849930a2020-06-03 08:06:47 +0200366/* Return the scalar value `value` (possibly promoted). This is a compile-time
367 * constant if `value` is. `condition` must be a compile-time constant.
368 * If `condition` is false, arrange to cause a compile-time error. */
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100369#define STATIC_ASSERT_THEN_RETURN(condition, value) \
370 (STATIC_ASSERT_EXPR(condition) ? 0 : (value))
Ronald Cron849930a2020-06-03 08:06:47 +0200371
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100372#define ARRAY_LENGTH(array) \
373 (STATIC_ASSERT_THEN_RETURN(IS_ARRAY_NOT_POINTER(array), \
374 ARRAY_LENGTH_UNSAFE(array)))
Ronald Cron849930a2020-06-03 08:06:47 +0200375
Gilles Peskinec86a1652021-02-15 12:17:00 +0100376#else
377/* If we aren't sure the compiler supports our non-standard tricks,
378 * fall back to the unsafe implementation. */
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100379#define ARRAY_LENGTH(array) ARRAY_LENGTH_UNSAFE(array)
Gilles Peskinec86a1652021-02-15 12:17:00 +0100380#endif
381
Ronald Cron849930a2020-06-03 08:06:47 +0200382/** Return the smaller of two values.
383 *
384 * \param x An integer-valued expression without side effects.
385 * \param y An integer-valued expression without side effects.
386 *
387 * \return The smaller of \p x and \p y.
388 */
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100389#define MIN(x, y) ((x) < (y) ? (x) : (y))
Ronald Cron849930a2020-06-03 08:06:47 +0200390
391/** Return the larger of two values.
392 *
393 * \param x An integer-valued expression without side effects.
394 * \param y An integer-valued expression without side effects.
395 *
396 * \return The larger of \p x and \p y.
397 */
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100398#define MAX(x, y) ((x) > (y) ? (x) : (y))
Ronald Cron849930a2020-06-03 08:06:47 +0200399
400/*
401 * 32-bit integer manipulation macros (big endian)
402 */
403#ifndef GET_UINT32_BE
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100404#define GET_UINT32_BE(n, b, i) \
405 { \
406 (n) = ((uint32_t) (b)[(i)] << 24) \
407 | ((uint32_t) (b)[(i) + 1] << 16) \
408 | ((uint32_t) (b)[(i) + 2] << 8) \
409 | ((uint32_t) (b)[(i) + 3]); \
410 }
Ronald Cron849930a2020-06-03 08:06:47 +0200411#endif
412
413#ifndef PUT_UINT32_BE
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100414#define PUT_UINT32_BE(n, b, i) \
415 { \
416 (b)[(i)] = (unsigned char) ((n) >> 24); \
417 (b)[(i) + 1] = (unsigned char) ((n) >> 16); \
418 (b)[(i) + 2] = (unsigned char) ((n) >> 8); \
419 (b)[(i) + 3] = (unsigned char) ((n)); \
420 }
Ronald Cron849930a2020-06-03 08:06:47 +0200421#endif
422
Ronald Cron4b8b1992020-06-09 13:52:23 +0200423#endif /* TEST_MACROS_H */