-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_common.h
More file actions
35 lines (27 loc) · 885 Bytes
/
test_common.h
File metadata and controls
35 lines (27 loc) · 885 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef TEST_COMMON_H
#define TEST_COMMON_H
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <stdint.h>
#include <cmocka.h>
#include <assert.h> // include for safe redefines
#include "macros.h"
#include "iota/iota_types.h"
#define MAX_NUM_HASHES 5
#define NUM_TRYTES(X) (((X) / NUM_HASH_TRITS) * NUM_HASH_TRYTES)
#define NUM_BYTES(X) (((X) / NUM_HASH_TRITS) * NUM_HASH_BYTES)
#define MAX_NUM_TRITS (NUM_HASH_TRITS * MAX_NUM_HASHES)
#define MAX_NUM_BYTES NUM_BYTES(MAX_NUM_TRITS)
#define TRITS_PER_TRYTE 3
#define MAX_NUM_TRYTES (MAX_NUM_TRITS / TRITS_PER_TRYTE)
#undef assert
#define assert(X) mock_assert((int)(X), #X, __FILE__, __LINE__)
static inline void assert_all_zero(const void *a, const size_t size)
{
if (size > 0) {
assert_int_equal(((char *)a)[0], 0);
assert_memory_equal(a, a + 1, size - 1);
}
}
#endif // TEST_COMMON_H