21ae6906b1d0980cee7703c7d0aac95dd91f8261
[com/asn1c.git] / tests / tests-c-compiler / check-src / check-46.c
1 #undef  NDEBUG
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <sys/types.h>
5 #include <string.h>
6 #include <assert.h>
7
8 #include <T.h>
9
10 uint8_t buf1[] = {
11         32 | ((2 << 6) + 3),    /* [3], constructed */
12         5,
13         ((2 << 6) + 5), /* [5], primitive */
14         3,      /* L */
15   'a',
16   'b',
17   'c',
18 };
19
20 static void
21 check(uint8_t *buf, size_t size, size_t consumed) {
22         T_t t, *tp;
23         asn_dec_rval_t rval;
24
25         tp = memset(&t, 0, sizeof(t));
26
27         fprintf(stderr, "Buf %p\n", buf);
28         rval = ber_decode(0, &asn_DEF_T, (void **)&tp, buf, size);
29         fprintf(stderr, "Returned code %d, consumed %zd\n",
30                 (int)rval.code, rval.consumed);
31
32         assert(rval.code == RC_OK);
33         assert(rval.consumed == consumed);
34         ASN_STRUCT_RESET(asn_DEF_T, tp);
35 }
36
37 int
38 main(int ac, char **av) {
39
40         (void)ac;       /* Unused argument */
41         (void)av;       /* Unused argument */
42
43         check(buf1, sizeof(buf1), sizeof(buf1));
44
45         return 0;
46 }
47