1/*
2 * Copyright (c) 2014-2019 Pavel Kalvoda <me@pavelkalvoda.com>
3 *
4 * libcbor is free software; you can redistribute it and/or modify
5 * it under the terms of the MIT license. See LICENSE for details.
6 */
7
8#include <setjmp.h>
9#include <stdarg.h>
10#include <stddef.h>
11
12#include <cmocka.h>
13
14#include "cbor.h"
15
16unsigned char data[] = {
17    0x93, 0x01, 0x19, 0x01, 0x01, 0x1A, 0x00, 0x01, 0x05, 0xB8, 0x1B, 0x00,
18    0x00, 0x00, 0x01, 0x8F, 0x5A, 0xE8, 0xB8, 0x20, 0x39, 0x01, 0x00, 0x3A,
19    0x00, 0x01, 0x05, 0xB7, 0x3B, 0x00, 0x00, 0x00, 0x01, 0x8F, 0x5A, 0xE8,
20    0xB7, 0x5F, 0x41, 0x01, 0x41, 0x02, 0xFF, 0x7F, 0x61, 0x61, 0x61, 0x62,
21    0xFF, 0x9F, 0xFF, 0xA1, 0x61, 0x61, 0x61, 0x62, 0xC0, 0xBF, 0xFF, 0xF9,
22    0x3C, 0x00, 0xFA, 0x47, 0xC3, 0x50, 0x00, 0xFB, 0x7E, 0x37, 0xE4, 0x3C,
23    0x88, 0x00, 0x75, 0x9C, 0xF6, 0xF7, 0xF5};
24
25/* Exercise the default callbacks */
26static void test_default_callbacks(void **state) {
27  size_t read = 0;
28  while (read < 79) {
29    struct cbor_decoder_result result =
30        cbor_stream_decode(data + read, 79 - read, &cbor_empty_callbacks, NULL);
31    read += result.read;
32  }
33}
34
35int main(void) {
36  const struct CMUnitTest tests[] = {
37
38      cmocka_unit_test(test_default_callbacks)};
39  return cmocka_run_group_tests(tests, NULL, NULL);
40}
41