Mistake on this page?
Report an issue in GitHub or email us
qcbor_decode_tests.h
1 /*==============================================================================
2  Copyright (c) 2016-2018, The Linux Foundation.
3  Copyright (c) 2018-2019, Laurence Lundblade.
4  All rights reserved.
5  SPDX-License-Identifier: BSD-3-Clause
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are
9 met:
10  * Redistributions of source code must retain the above copyright
11  notice, this list of conditions and the following disclaimer.
12  * Redistributions in binary form must reproduce the above
13  copyright notice, this list of conditions and the following
14  disclaimer in the documentation and/or other materials provided
15  with the distribution.
16  * Neither the name of The Linux Foundation nor the names of its
17  contributors, nor the name "Laurence Lundblade" may be used to
18  endorse or promote products derived from this software without
19  specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
22 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
24 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
25 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
28 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
30 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
31 IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  ==============================================================================*/
33 
34 #ifndef __QCBOR__qcbort_decode_tests__
35 #define __QCBOR__qcbort_decode_tests__
36 
37 #include "qcbor.h"
38 
39 
40 /*
41  Notes:
42 
43  - All the functions in qcbor.h are called once in the aggregation of all the tests below.
44 
45  - All the types that are supported are given as input and parsed by these tests
46 
47  - There is some hostile input such as invalid lengths and CBOR too complex
48  and types this parser doesn't handle
49 
50  */
51 
52 
53 
54 
55 /*
56  Parse a well-known set of integers including those around the boundaries and
57  make sure the expected values come out
58  */
59 int IntegerValuesParseTest(void);
60 
61 
62 
63 
64 
65 /*
66  Decode a simple CBOR encoded array and make sure it returns all the correct values.
67  This is a decode test.
68  */
69 int SimpleArrayTest(void);
70 
71 
72 /*
73  Make sure a maximally deep array can be parsed and that the
74  reported nesting level is correct. This uses test vector
75  of CBOR encoded data with a depth of 10. This a parse test.
76  */
77 int ParseDeepArrayTest(void);
78 
79 
80 /*
81  See that the correct error is reported when parsing
82  an array of depth 11, one too large.
83  */
84 int ParseTooDeepArrayTest(void);
85 
86 
87 /*
88  Try to parse some legit CBOR types that this parsers
89  doesn't support.
90  */
91 int UnsupportedCBORDecodeTest(void);
92 
93 
94 /*
95  This takes the encoded CBOR integers used in the above test and parses
96  it over and over with one more byte less each time. It should fail
97  every time on incorrect CBOR input. This is a hostile input decode test.
98  */
99 int ShortBufferParseTest(void);
100 
101 
102 /*
103  Same as ShortBufferParseTest, but with a different encoded CBOR input.
104  It is another hostile input test
105  */
106 int ShortBufferParseTest2(void);
107 
108 
109 /*
110  Parses the somewhat complicated CBOR MAP and makes sure all the correct
111  values parse out. About 15 values are tested. This is a decode test.
112  */
113 int ParseMapTest(void);
114 
115 
116 
117 int FloatValuesTest1(void);
118 
119 
120 
121 int SimpleValuesTest1(void);
122 
123 
124 /*
125 
126  */
127 int ParseMapAsArrayTest(void);
128 
129 
130 
131 int ParseSimpleTest(void);
132 
133 
134 
135 /*
136  Tests a number of failure cases on bad CBOR to get the right error code
137  */
138 int FailureTests(void);
139 
140 
141 /*
142  Parses all possible inputs that are two bytes long. Main point
143  is that the test doesn't crash as it doesn't evaluate the
144  input for correctness in any way.
145 
146  (Parsing all possible 3 byte strings takes too long on all but
147  very fast machines).
148  */
149 int ComprehensiveInputTest(void);
150 
151 
152 /*
153  Parses all possible inputs that are four bytes long. Main point
154  is that the test doesn't crash as it doesn't evaluate the
155  input for correctness in any way. This runs very slow, so it
156  is only practical as a once-in-a-while regression test on
157  fast machines.
158  */
159 int BigComprehensiveInputTest(void);
160 
161 
162 /*
163  Thest the date types -- epoch and strings
164  */
165 int DateParseTest(void);
166 
167 
168 /*
169  Test optional tags like the CBOR magic number.
170  */
171 int OptTagParseTest(void);
172 
173 
174 /*
175  Parse some big numbers, positive and negative
176  */
177 int BignumParseTest(void);
178 
179 
180 int StringDecoderModeFailTest(void);
181 
182 
183 /*
184  Parse some nested maps
185  */
186 int NestedMapTest(void);
187 
188 
189 /*
190  Parse maps with indefinite lengths
191  */
192 int NestedMapTestIndefLen(void);
193 
194 
195 /*
196  Parse some maps and arrays with indefinite lengths.
197  Includes some error cases.
198  */
199 int IndefiniteLengthArrayMapTest(void);
200 
201 
202 /*
203  Parse indefinite length strings. Uses
204  MemPool. Includes error cases.
205  */
206 int IndefiniteLengthStringTest(void);
207 
208 
209 /*
210  Test deep nesting of indefinite length
211  maps and arrays including too deep.
212  */
213 int IndefiniteLengthNestTest(void);
214 
215 
216 /*
217  Test parsing strings were all strings, not
218  just indefinite length strings, are
219  allocated. Includes error test cases.
220  */
221 int AllocAllStringsTest(void);
222 
223 
224 /*
225  Direct test of MemPool string allocator
226  */
227 int MemPoolTest(void);
228 
229 
230 #endif /* defined(__QCBOR__qcbort_decode_tests__) */
Q C B O R E n c o d e / D e c o d e.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.