From c5e2ebc18ec867caf6f7c2edf2305f1cdb65b053 Mon Sep 17 00:00:00 2001 From: kartofen Date: Tue, 25 Mar 2025 01:55:32 +0200 Subject: unit testing in main.c --- msgpack.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'msgpack.c') diff --git a/msgpack.c b/msgpack.c index b5ba7ae..bd4efdf 100644 --- a/msgpack.c +++ b/msgpack.c @@ -184,8 +184,21 @@ int msgpack_read_map (msgpack_t *pack, size_t *length); int msgpack_read_array2 (const msgpack_t *pack, struct mp_array *m); int msgpack_read_map2 (const msgpack_t *pack, struct mp_map *m); +#define CHECK_WRITE_ARGS(type, pack, m) \ + do { \ + if(!(pack) || !(pack)->bin || (pack)->size == 0) \ + return ERROR((type), MSGPACK_ERROR_INVALID_PACK); \ + if((pack)->bin[0] == 0xc) \ + return ERROR2((type), MSGPACK_ERROR_WRONG_TYPE, MSGPACK_NIL); \ + if(!(m)) \ + return ERROR((type), MSGPACK_ERROR_INVALID_ARGUMENT); \ + } while(0) + +int msgpack_write_int (msgpack_t *pack, const union mp_int *m, int subtype) + ;// { + +// } -int msgpack_write_int (msgpack_t *pack, const union mp_int *m, int subtype); int msgpack_write_bool (msgpack_t *pack, const int *m); int msgpack_write_float (msgpack_t *pack, const union mp_float *m, int subtype); -- cgit v1.2.3