blob: 759406f0eee6c156266955a846ae431b8c9a3b65 [file] [log] [blame]
Laurence Lundblade2ded3d92018-10-09 21:36:11 +08001/*==============================================================================
2Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
3
4Redistribution and use in source and binary forms, with or without
5modification, are permitted provided that the following conditions are
6met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above
10 copyright notice, this list of conditions and the following
11 disclaimer in the documentation and/or other materials provided
12 with the distribution.
13 * Neither the name of The Linux Foundation nor the names of its
14 contributors may be used to endorse or promote products derived
15 from this software without specific prior written permission.
16
17THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28==============================================================================*/
29
30#ifndef __QCBOR__qcbort_decode_tests__
31#define __QCBOR__qcbort_decode_tests__
32
33#include "qcbor.h"
34
35
36/*
37 Notes:
38
39 - All the functions in qcbor.h are called once in the aggregation of all the tests below.
40
41 - All the types that are supported are given as input and parsed by these tests
42
43 - There is some hostile input such as invalid lengths and CBOR too complex
44 and types this parser doesn't handle
45
46 */
47
48
49
50
51/*
52 Parse a well-known set of integers including those around the boundaries and
53 make sure the expected values come out
54 */
55int IntegerValuesParseTest();
56
57
58
59
60
61/*
62 Decode a simple CBOR encoded array and make sure it returns all the correct values.
63 This is a decode test.
64 */
65int SimpleArrayTest();
66
67
68/*
69 Make sure a maximally deep array can be parsed and that the
70 reported nesting level is correct. This uses test vector
71 of CBOR encoded data with a depth of 10. This a parse test.
72 */
73int ParseDeepArrayTest();
74
75
76/*
77 See that the correct error is reported when parsing
78 an array of depth 11, one too large.
79 */
80int ParseTooDeepArrayTest();
81
82
83/*
84 Try to parse some legit CBOR types that this parsers
85 doesn't support.
86 */
87int UnsupportedCBORDecodeTest();
88
89
90/*
91 This takes the encoded CBOR integers used in the above test and parses
92 it over and over with one more byte less each time. It should fail
93 every time on incorrect CBOR input. This is a hostile input decode test.
94 */
95int ShortBufferParseTest();
96
97
98/*
99 Same as ShortBufferParseTest, but with a different encoded CBOR input.
100 It is another hostile input test
101 */
102int ShortBufferParseTest2();
103
104
105/*
106 Parses the somewhat complicated CBOR MAP and makes sure all the correct
107 values parse out. About 15 values are tested. This is a decode test.
108 */
109int ParseMapTest();
110
111
112
113int FloatValuesTest1();
114
115
116
117int SimpleValuesTest1();
118
119
120
121int ParseSimpleTest();
122
123
124
125/*
126 Tests a number of failure cases on bad CBOR to get the right error code
127 */
128int FailureTests();
129
130
131/*
132 Generate all possible input strings up to length x and tries to parse them completely
133 */
134int ComprehensiveInputTest();
135
136
137/*
138 Thest the date types -- epoch and strings
139 */
140int DateParseTest();
141
142
143/*
144 Test optional tags like the CBOR magic number.
145 */
146int OptTagParseTest();
147
148
149/*
150 Parse some big numbers, positive and negative
151 */
152int BignumParseTest();
153
154
155/*
156 Parse some nested maps
157 */
158int NestedMapTest();
159
160
161
162#endif /* defined(__QCBOR__qcbort_decode_tests__) */