1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements.  See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership.  The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License.  You may obtain a copy of the License at
9  *
10  *  http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied.  See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
20 #include "test_cborattr.h"
21 /*
22  * {"a": "A", "b": "B", "c": "C", "d": "D", "e": "E"}
23  */
24 static const uint8_t test_data1[] = {
25     0xa5, 0x61, 0x61, 0x61, 0x41, 0x61, 0x62, 0x61,
26     0x42, 0x61, 0x63, 0x61, 0x43, 0x61, 0x64, 0x61,
27     0x44, 0x61, 0x65, 0x61, 0x45
28 };
29 
30 const uint8_t *
test_str1(int * len)31 test_str1(int *len)
32 {
33     *len = sizeof(test_data1);
34     return (test_data1);
35 }
36 
37 void
cborattr_test_util_encode(const struct cbor_out_attr_t * attrs,const uint8_t * expected,int len)38 cborattr_test_util_encode(const struct cbor_out_attr_t *attrs,
39                           const uint8_t *expected, int len)
40 {
41     struct os_mbuf *om;
42     int rc;
43 
44     rc = cbor_write_object_msys(attrs, &om);
45     TEST_ASSERT_FATAL(rc == 0);
46 
47     TEST_ASSERT(os_mbuf_cmpf(om, 0, expected, len) == 0);
48 
49     os_mbuf_free_chain(om);
50 }
51