1 // Headers needed by cmocka -- must be imported first 2 #include <setjmp.h> 3 #include <stdarg.h> 4 #include <stddef.h> 5 #include <stdint.h> 6 7 #include <cmocka.h> 8 9 #include "cbor.h" 10 11 #ifndef ASSERTIONS_H_ 12 #define ASSERTIONS_H_ 13 14 void assert_uint8(cbor_item_t* item, uint8_t num); 15 void assert_uint16(cbor_item_t* item, uint16_t num); 16 void assert_uint32(cbor_item_t* item, uint32_t num); 17 void assert_uint64(cbor_item_t* item, uint64_t num); 18 19 // TODO: Fix "Yoda" parameter ordering of asserts 20 /** Verify the `actual_result.status` and `actual_result.status`. */ 21 void assert_decoder_result(size_t expected_bytes_read, 22 enum cbor_decoder_status expected_status, 23 struct cbor_decoder_result actual_result); 24 25 /** 26 * Assert that the result is set to CBOR_DECODER_NEDATA with the given 27 * `cbor_decoder_result.required` value. 28 */ 29 void assert_decoder_result_nedata(size_t expected_bytes_required, 30 struct cbor_decoder_result actual_result); 31 32 /** 33 * Check that the streaming decoder returns a correct CBOR_DECODER_NEDATA 34 * result for all inputs from data[0..1] through data[0..(expected-1)]. 35 */ 36 void assert_minimum_input_size(size_t expected, cbor_data data); 37 38 /** Check the equality of two `size_t`s. */ 39 void _assert_size_equal(size_t actual, size_t expected, const char* src_file, 40 int src_line); 41 #define assert_size_equal(actual, expected) \ 42 _assert_size_equal(actual, expected, __FILE__, __LINE__) 43 44 #endif 45