blob: c20756f836dfcc9ce339aa985d5b6d66f34d1159 [file] [log] [blame]
Laurence Lundblade2ded3d92018-10-09 21:36:11 +08001/*==============================================================================
Laurence Lundbladed92a6162018-11-01 11:38:35 +07002 Copyright (c) 2016-2018, The Linux Foundation.
3 Copyright (c) 2018, Laurence Lundblade.
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are
8 met:
9 * Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11 * Redistributions in binary form must reproduce the above
12 copyright notice, this list of conditions and the following
13 disclaimer in the documentation and/or other materials provided
14 with the distribution.
15 * Neither the name of The Linux Foundation nor the names of its
16 contributors, nor the name "Laurence Lundblade" may be used to
17 endorse or promote products derived from this software without
18 specific prior written permission.
19
20 THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
21 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
24 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
30 IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 ==============================================================================*/
Laurence Lundblade2ded3d92018-10-09 21:36:11 +080032
33#ifndef __QCBOR__qcbor_encode_tests__
34#define __QCBOR__qcbor_encode_tests__
35
36#include "qcbor.h"
37
38
39/*
40 Notes:
41
42 - All the functions in qcbor.h are called once in the aggregation of all the tests below.
43
44 - All the types that are supported are given as input and parsed by these tests
45
46 - There is some hostile input such as invalid lengths and CBOR too complex
47 and types this parser doesn't handle
48
49 */
50
51
52/*
Laurence Lundblade4d1ecba2018-10-12 21:22:30 +080053 Most basic test.
54 */
Laurence Lundblade369b90a2018-10-22 02:04:37 +053055int BasicEncodeTest(void);
Laurence Lundblade4d1ecba2018-10-12 21:22:30 +080056
57
58/*
Laurence Lundblade2ded3d92018-10-09 21:36:11 +080059 Encode lots of integer values, particularly around the boundary and make sure they
60 Match the expected binary output. Primarily an encoding test.
61 */
Laurence Lundbladedc6e28e2018-10-11 19:19:27 +053062int IntegerValuesTest1(void);
Laurence Lundblade2ded3d92018-10-09 21:36:11 +080063
64
65
66/*
67 Create nested arrays to the max depth allowed and make sure it succeeds.
68 This is an encoding test.
69 */
Laurence Lundbladedc6e28e2018-10-11 19:19:27 +053070int ArrayNestingTest1(void);
Laurence Lundblade2ded3d92018-10-09 21:36:11 +080071
72
73/*
74 Create nested arrays to one more than the meax depth and make sure it fails.
75 This is an encoding test.
76 */
Laurence Lundbladedc6e28e2018-10-11 19:19:27 +053077int ArrayNestingTest2(void);
Laurence Lundblade2ded3d92018-10-09 21:36:11 +080078
79
80/*
81 Encoding test.
82 Create arrays to max depth and close one extra time and look for correct error code
83 */
Laurence Lundbladedc6e28e2018-10-11 19:19:27 +053084int ArrayNestingTest3(void);
Laurence Lundblade2ded3d92018-10-09 21:36:11 +080085
86
87/*
88 This tests the QCBOREncode_AddRaw() function by adding two chunks or RAWCBOR to an
89 array and comparing with expected values. This is an encoding test.
90 */
Laurence Lundbladedc6e28e2018-10-11 19:19:27 +053091int EncodeRawTest(void);
Laurence Lundblade2ded3d92018-10-09 21:36:11 +080092
93
94/*
95 This creates a somewhat complicated CBOR MAP and verifies it against expected
96 data. This is an encoding test.
97 */
Laurence Lundbladedc6e28e2018-10-11 19:19:27 +053098int MapEncodeTest(void);
Laurence Lundblade2ded3d92018-10-09 21:36:11 +080099
100
101
102/*
103 Encodes a goodly number of floats and doubles and checks encoding is right
104 */
Laurence Lundbladedc6e28e2018-10-11 19:19:27 +0530105int FloatValuesTest1(void);
Laurence Lundblade2ded3d92018-10-09 21:36:11 +0800106
107
108/*
109 Encodes true, false and the like
110 */
Laurence Lundbladedc6e28e2018-10-11 19:19:27 +0530111int SimpleValuesTest1(void);
Laurence Lundblade2ded3d92018-10-09 21:36:11 +0800112
113
114/*
115 Encodes most data formats that are supported */
Laurence Lundbladedc6e28e2018-10-11 19:19:27 +0530116int EncodeDateTest(void);
Laurence Lundblade2ded3d92018-10-09 21:36:11 +0800117
118
119/*
120 Encodes particular data structure that a particular app will need...
121 */
Laurence Lundbladedc6e28e2018-10-11 19:19:27 +0530122int RTICResultsTest(void);
Laurence Lundblade2ded3d92018-10-09 21:36:11 +0800123
124
125/*
126 Calls all public encode methods in qcbor.h once.
127 */
Laurence Lundbladedc6e28e2018-10-11 19:19:27 +0530128int AllAddMethodsTest(void);
Laurence Lundblade2ded3d92018-10-09 21:36:11 +0800129
130/*
131 The binary string wrapping of maps and arrays used by COSE
132 */
Laurence Lundblade369b90a2018-10-22 02:04:37 +0530133int BstrWrapTest(void);
Laurence Lundblade684aec22018-10-12 19:33:53 +0800134
Laurence Lundblade369b90a2018-10-22 02:04:37 +0530135int BstrWrapErrorTest(void);
Laurence Lundblade684aec22018-10-12 19:33:53 +0800136
Laurence Lundblade369b90a2018-10-22 02:04:37 +0530137int BstrWrapNestTest(void);
Laurence Lundblade684aec22018-10-12 19:33:53 +0800138
Laurence Lundblade369b90a2018-10-22 02:04:37 +0530139int CoseSign1TBSTest(void);
Laurence Lundblade2ded3d92018-10-09 21:36:11 +0800140
141
142
143#endif /* defined(__QCBOR__qcbor_encode_tests__) */